~ubuntu-branches/debian/jessie/bristol/jessie

« back to all changes in this revision

Viewing changes to bin/startBristol.in

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-11-10 12:21:04 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091110122104-432yau0haobyl122
Tags: 0.40.6-1
* Adopting this (Closes: #546954).
* Create new bristol-data runtime package, it will contain application's
  architecture-indipendent data files.
* Drop all patches, now useless.
* Switch to debhelper 7.
* debian/copyright: Update according to DEP-5 spec.
* debian/bristol.1: Fix little spelling mistake.
* Replace patch system, from dpatch to quilt.
* Add 01-spelling_errors.patch patch to fix spelling-error-in-binary.
* debian/rules: dh_makeshlibs doesn't touch shlibs/symbols file, libraries
  under /usr/lib/bristol/ are private.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
#
3
3
 
 
4
args=$*
 
5
 
4
6
engine=1
 
7
gui=1
5
8
quiet=0
6
9
verbose=0
7
10
jack=0
8
11
declare -x JACK_START_SERVER=1
9
12
midi=seq
10
13
HELP=0
 
14
PORT=5028
11
15
 
12
16
RATE=44100
13
17
DRIVER=-alsa
96
100
#fi
97
101
 
98
102
for index in $*; do
99
 
        if [ $index = "-r" ]; then
100
 
                index=$((index + 11))
101
 
                SAMPLERATE=$index
102
 
        fi
103
 
        if [ $index = "-n" ]; then
104
 
                index=$((index + 11))
105
 
                NFRAMES=$index
106
 
        fi
107
 
        if [ $index = "-p" ]; then
108
 
                index=$((index + 11))
109
 
                FRAME=$index
110
 
        fi
111
 
        if [ $index = "-synth" ]; then
112
 
                index=$((index + 11))
113
 
                SYNTH=$index
114
 
        fi
115
 
        if [ $index = "-midi" ]; then
116
 
                index=$((index + 11))
117
 
                midi=$index
118
 
        fi
119
 
 
 
103
        if [ $index = "-port" ]; then
 
104
                shift
 
105
                PORT=$1
 
106
        fi
 
107
        if [ $index = "-summary" ]; then
 
108
                brighton -summary
 
109
                exit 0
 
110
        fi
120
111
        if [ $index = "-master" ]; then
121
112
                engine=0
122
113
        fi
123
114
        if [ $index = "-engine" ]; then
124
115
                engine=0
125
116
        fi
 
117
        if [ $index = "-gui" ]; then
 
118
                gui=0
 
119
        fi
126
120
        if [ $index = "-v" ]; then
127
121
                verbose=1
128
122
        fi
174
168
        if [ $index = "-jackstart" ]; then
175
169
                unset JACK_START_SERVER
176
170
        fi
 
171
        shift
177
172
done
178
173
 
179
174
# Nokey: Does the BRISTOL directory actually exist?
206
201
# Try and get Jack driver information. If the daemon is running, use it. If
207
202
# user has a .jackdrc use that, otherwise use /etc/jackdrc
208
203
#
209
 
# Thanks to Sylvain Robitaille for this code.
210
 
#
211
204
if [ ${DRIVER} == "-jack" ]; then 
212
 
        #
213
 
        # See if the process is running
214
 
        #
215
 
        JACKD=`ps ax | grep -w jackd | grep -vw grep` 
216
 
 
217
 
        #
218
 
        # Otherwise see what would be started
219
 
        #
220
 
        if [ -z "${JACKD}" ]; then 
221
 
                echo "jack driver requested, jackd not running" 
222
 
 
223
 
                if [ -f /etc/jackdrc ]; then
224
 
                        echo "jack configuration found in /etc/jackdrc"
225
 
                        JACKD=`cat /etc/jackdrc`
226
 
                fi
227
 
 
228
 
                if [ -f ~/.jackdrc ]; then
229
 
                        echo "private jack configuration found in ~/.jackdrc"
230
 
                        JACKD=`cat ~/.jackdrc`
231
 
                fi
232
 
        fi
233
 
 
234
 
        if [ -z "${JACKD}" ]; then 
235
 
                RATE=48000 
236
 
                COUNT=1024 
 
205
        JACKPARAMS=`bristoljackstats 2>&1 | awk '/JACKSTATS/'`
 
206
 
 
207
        if [ $? == 0 ]; then
 
208
                RATE=`echo ${JACKPARAMS} | awk '{print $2}'`
 
209
                COUNT=`echo ${JACKPARAMS} | awk '{print $3}'`
 
210
 
 
211
                echo jackstats found -rate ${RATE} -count ${COUNT}
237
212
        else
238
 
                RATE=`echo ${JACKD} |grep -o -- '-r[0-9][0-9]*' |sed 's/^-r//'` 
239
 
 
240
 
                if [ -z "${RATE}" ]; then 
241
 
                        # assume Jackd's default rate: 
 
213
                #
 
214
                # We should not really get here. If jack was requested but the daemon
 
215
                # could not be reached (we did not get feedback from bristoljackstats)
 
216
                # then larger issues will occur presently
 
217
                #
 
218
                # Thanks to Sylvain Robitaille for the next code.
 
219
                #
 
220
                # See if the process is running
 
221
                #
 
222
                JACKD=`ps ax | grep -w jackd | grep -vw grep` 
 
223
 
 
224
                #
 
225
                # Otherwise see what would be started
 
226
                #
 
227
                if [ -z "${JACKD}" ]; then 
 
228
                        echo "jack driver requested, jackd not running" 
 
229
 
 
230
                        if [ -f /etc/jackdrc ]; then
 
231
                                echo "jack configuration found in /etc/jackdrc"
 
232
                                JACKD=`cat /etc/jackdrc`
 
233
                        fi
 
234
 
 
235
                        if [ -f ~/.jackdrc ]; then
 
236
                                echo "private jack configuration found in ~/.jackdrc"
 
237
                                JACKD=`cat ~/.jackdrc`
 
238
                        fi
 
239
                fi
 
240
 
 
241
                if [ -z "${JACKD}" ]; then 
242
242
                        RATE=48000 
243
 
                fi 
244
 
 
245
 
                #COUNT=`echo ${JACKD} |grep -o -- '-p[0-9][0-9]*' |sed 's/^-p//'` 
246
 
                COUNT=`echo ${JACKD} |grep -o -- '-p[0-9][0-9]*' |tail -n1 |sed 's/^-p//'`
247
 
 
248
 
                if [ -z "${COUNT}" ]; then 
249
 
                        # assume Jackd's default count: 
250
243
                        COUNT=1024 
251
 
                fi 
 
244
                else
 
245
                        RATE=`echo ${JACKD} |grep -o -- '-r[0-9][0-9]*' |sed 's/^-r//'` 
 
246
 
 
247
                        if [ -z "${RATE}" ]; then 
 
248
                                # assume Jackd's default rate: 
 
249
                                RATE=48000 
 
250
                        fi 
 
251
 
 
252
                        #COUNT=`echo ${JACKD} |grep -o -- '-p[0-9][0-9]*' |sed 's/^-p//'` 
 
253
                        COUNT=`echo ${JACKD} |grep -o -- '-p[0-9][0-9]*' |tail -n1 |sed 's/^-p//'`
 
254
 
 
255
                        if [ -z "${COUNT}" ]; then 
 
256
                                # assume Jackd's default count: 
 
257
                                COUNT=1024 
 
258
                        fi 
 
259
                fi
252
260
        fi
253
261
fi
254
262
 
303
311
fi
304
312
 
305
313
#
 
314
# Requesting an engine. This means we need a free TCP port. Our default is 
 
315
# 5028 and if it is not free then search for one from there
 
316
#
 
317
if [ $engine = 1 ]; then
 
318
        echo checking availability of TCP port $PORT
 
319
        netstat -taln | grep $PORT > /dev/null
 
320
        while [ $? = 0 ]; do
 
321
                echo -n "port looked busy, trying "
 
322
                PORT=`expr $PORT + 1`
 
323
                echo $PORT
 
324
                netstat -taln | grep $PORT > /dev/null
 
325
        done
 
326
        if [ ${PORT} -lt 1024 -a ${UID} -ne 0 ]; then
 
327
                        echo you may not have permissions for ports less than 1024
 
328
        else
 
329
                echo using port $PORT
 
330
        fi
 
331
fi
 
332
 
 
333
#
306
334
# the bristol engine has flags for -oss or -alsa drivers, -preload buffers of
307
335
# -count samples:
308
336
#       bristol -preload 4 -count 256 [-oss]
309
337
#
310
338
if [ $engine = 1 ]; then
 
339
        if [ $gui = 1 ]; then
 
340
                if [ $quiet = 0 ]; then
 
341
                        bristol -rate ${RATE} -count ${COUNT} $args -port $PORT &
 
342
                else
 
343
                        bristol -rate ${RATE} -count ${COUNT} $args -port $PORT > /dev/null 2>&1 &
 
344
                fi
 
345
        else
 
346
                if [ $quiet = 0 ]; then
 
347
                        bristol -rate ${RATE} -count ${COUNT} $args -port $PORT
 
348
                else
 
349
                        bristol -rate ${RATE} -count ${COUNT} $args -port $PORT > /dev/null 2>&1
 
350
                fi
 
351
        fi
 
352
        sleep 1
 
353
fi
 
354
 
 
355
if [ $gui = 1 ]; then
311
356
        if [ $quiet = 0 ]; then
312
 
                bristol -rate ${RATE} -count ${COUNT} $* &
 
357
                brighton $args -engine -port ${PORT}
313
358
        else
314
 
                bristol -rate ${RATE} -count ${COUNT} $* > /dev/null 2>&1 &
 
359
                brighton $args -engine -port ${PORT} > /dev/null 2>&1
315
360
        fi
316
 
        sleep 1
317
 
fi
318
 
if [ $quiet = 0 ]; then
319
 
        brighton $* -engine
320
 
else
321
 
        brighton $* -engine > /dev/null 2>&1
322
361
fi
323
362
 
 
363
# Make sure we have the children returned, prevents ugly delayed output
 
364
if [ $engine = 1 ]; then
 
365
        wait % >/dev/null 2>&1
 
366
fi
 
367