-
Notifications
You must be signed in to change notification settings - Fork 0
/
qpiano-fluidsynth
executable file
·470 lines (423 loc) · 13.4 KB
/
qpiano-fluidsynth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
#!/bin/sh
# This script runs qpiano with fluidsynth
# It supports JACK and ALSA both
# It switches on JACK automatically if ALSA is not available
# License: same with QPiano
# Author: Alexey Loginov <[email protected]>
MES1="Error: SoundFonts SF1 and SF2 were not found!"
MES2="Error: fluidsynth was not run!"
MES3="Error: SoundFont SF was not found!"
MES4="Supported audio drivers are jack, alsa!"
MES5="Please try again!"
MES6="Error: fluidsynth was not found or broken!"
MES7="Error: jackd was not found!"
MES8="Starting fluidsynth..."
MES9="Please wait 10 more seconds!"
MES10="Fluidsynth does not have ALSA support!"
MES11="Switching on using JACK..."
MES12="Error: qpiano was not found!"
MES13="Error: No support for audio driver:"
MES14="Ignoring..."
use_jack="0"
audioDevice="plughw:0"
bufferCounts="6"
bufferSize="128"
chorus="0"
masterGain="0.4"
reverb="0"
sampleRate="44100"
if [ -f ~/.config/QPiano/"QPiano.ini" ]
then
cp -f ~/.config/QPiano/"QPiano.ini" ~/.config/QPiano/QPiano.ini
sed -i '/\[/d' ~/.config/QPiano/QPiano.ini
sed -i '/^$/d' ~/.config/QPiano/QPiano.ini
sed -i "s|=|=\'|g" ~/.config/QPiano/QPiano.ini
sed -i "s|$|\'|g" ~/.config/QPiano/QPiano.ini
sed -i "s|''|'|g" ~/.config/QPiano/QPiano.ini
sed -i "s|'\"='\"'|'='|g" ~/.config/QPiano/QPiano.ini
. ~/.config/QPiano/QPiano.ini 2>/dev/null
rm -f ~/.config/QPiano/QPiano.ini
fi
if [ ! -z "$audioDeviceLineEdit" ]
then
audioDevice="$audioDeviceLineEdit"
fi
if [ ! -z "$bufferCountsSpin" ]
then
bufferCounts="$bufferCountsSpin"
fi
if [ ! -z "$bufferSizeSpin" ]
then
bufferSize="$bufferSizeSpin"
fi
if [ ! -z "$masterGainSpin" ]
then
masterGain="$masterGainSpin"
fi
if [ ! -z "$sampleRateCombo" ]
then
sampleRate="$sampleRateCombo"
fi
if [ "$audioDriverCombo" = "jack" ]
then
use_jack="1"
fi
if [ "$chorusCheck" = "true" ]
then
chorus="1"
fi
if [ "$reverbCheck" = "true" ]
then
reverb="1"
fi
lang=`echo $LANGUAGE|cut -d ":" -f 2`
if [ -z "$lang" ]
then
lang=`echo $LANG|cut -d "." -f 1`
if [ ! "$lang" = "pt_BR" ] && [ ! "$lang" = "bs_BA" ] && [ ! "$lang" = "zh_HK" ]
then
lang=`echo $LANG|cut -d "_" -f 1`
fi
fi
case $lang in
ru|be)
MES1="Ошибка: Звуковые шрифты SF1 и SF2 не были найдены!"
MES2="Ошибка: fluidsynth не был запущен!"
MES3="Ошибка: Звуковой шрифт SF не был найден!"
MES4="Поддерживаемые аудио драйверы - jack, alsa!"
MES5="Пожалуйста, попытайтесь снова!"
MES6="Ошибка: fluidsynth не был найден, или он неработоспособен!"
MES7="Ошибка: jackd не был найден!"
MES8="Запускается fluidsynth..."
MES9="Пожалуйста, ожидайте около 10 секунд!"
MES10="Fluidsynth не имеет поддержки ALSA!"
MES11="Переключение на использование JACK..."
MES12="Ошибка: qpiano не был найден!"
MES13="Ошибка: Нет поддержки для аудио драйвера:"
MES14="Игнорирование..."
;;
fi)
MES1="Virhe: SF1 ja SF2 ei löytynyt!"
MES2="Virhe: fluidsynth ei toimi!"
MES3="Virhe: SF ei löytynyt!"
MES5="Yritä uudelleen!"
MES6="Virhe: fluidsynth ei löytynyt tai rikki!"
MES7="Virhe: jackd ei löytynyt!"
MES8="Alkaa fluidsynth..."
MES9="Odota 10 sekuntia!"
MES10="Fluidsynthillä ei ole ALSA-tukea!"
MES11="Kytketään käyttäen JACK..."
MES12="Virhe: qpiano ei löytynyt!"
;;
de)
MES1="Fehler: SoundFonts SF1 und SF2 wurden nicht gefunden!"
MES2="Fehler: Fluidsynth wurde nicht ausgeführt!"
MES3="Fehler: SoundFont SF wurde nicht gefunden!"
MES4="Unterstützte Audio-Treiber sind JACK und ALSA!"
MES5="Bitte erneut versuchen!"
MES6="Fehler: Fluidsynth wurde nicht gefunden oder ist beschädigt!"
MES7="Fehler: jackd wurde nicht gefunden!"
MES8="Fluidsynth wird gestartet..."
MES9="Bitte noch 10 Sekunden warten!"
MES10="Fluidsynth bietet keine ALSA-Unterstützung!"
MES11="Es wird zu JACK gewechselt..."
MES12="Fehler: qpiano wurde nicht gefunden!"
MES13="Fehler: Keine Unterstützung für den Audio-Treiber."
MES14="Ignorieren..."
;;
uk)
MES1="Помилка: не знайдено звукових шрифтів SF1 та SF2!"
MES2="Помилка: fluidsynth не запущено!"
MES3="Помилка: не знайдено звукового шрифту SF!"
MES5="Будь ласка, повторіть спробу!"
MES6="Помилка: fluidsynth не знайдено або дані програми пошкоджено!"
MES7="Помилка: jackd не знайдено!"
MES8="Запускаємо fluidsynth..."
MES9="Будь ласка, зачекайте ще 10 секунд!"
MES10="У Fluidsynth не передбачено підтримки ALSA!"
MES11="Перемикаємося на використання JACK..."
MES12="Помилка: qpiano не знайдено!"
;;
cs)
MES1="Chyba: Zvukové banky SF1 a SF2 nebyly nalezeny!"
MES2="Chyba: fluidsynth nebyl spuštěn!"
MES3="Chyba: Zvuková banka SF nebyla nalezena!"
MES5="Zkuste to, prosím, znovu!"
;;
gl)
MES1="Erro: Non se atopou SoundFonts SF1 e SF2!"
MES2="Erro: o fluidsynth non foi executado!"
MES3="Erro: Non se atopou SoundFont SF!"
MES5="Tenteo de novo!"
;;
bg)
MES1="Грешка: SoundFonts SF1 и SF2 не бяха намерени!"
MES2="Грешка: Не намирам fluidsynth!"
MES5="Моля, опитайте отново!"
fr)
MES2="Erreur : fluidsynth n’a pas été démarré !"
MES6="Erreur : fluidsynth n’a pas été trouvé ou est cassé !"
MES7="Erreur : jackd n’a pas été trouvé !"
MES8="Démarrage de fluidsynth..."
MES12="Erreur : qpiano n’a pas été trouvé !"
;;
sv)
MES1="Fel: SoundFonts SF1 och SF2 hittades inte!"
MES2="Fel: fluidsynth kördes inte!"
MES3="Fel: SoundFont SF hittades inte!"
MES4="Ljuddrivrutiner som stöds är jack, alsa!"
MES5="Vänligen försök igen!"
MES6="Fel: fluidsynth kunde inte hittas eller är skadad!"
MES7="Fel: jackd hittades inte!"
MES8="Startar fluidsynth..."
MES9="Vänligen vänta 10 sekunder till!"
MES10="Fluidsynth har inte ALSA-stöd!"
MES11="Slå på med JACK..."
MES12="Fel: qpiano hittades inte!"
MES13="Fel: Inget stöd för ljuddrivrutin:"
MES14="Ignorerar..."
;;
pt_BR)
MES1="Erro: SoundFonts SF1 e SF2 não foram encontrados!"
MES2="Erro: fluidsynth não foi iniciado!"
MES3="Erro: SoundFont SF não encontrado!"
MES4="Drivers de áudio suportados: JACK e ALSA!"
MES5="Tente novamente, por favor!"
MES6="Erro: fluidsynth não foi encontrado ou está quebrado!"
MES7="Erro: jackd não foi encontrado!"
MES8="Iniciando fluidsynth..."
MES9="Espere mais 10 segundos, por favor!"
MES10="Fluidsynth não tem suporte ao ALSA!"
MES12="Erro: qpiano não encontrado!"
MES13="Erro: Não há suporte para o driver de áudio."
MES14="Ignorando..."
;;
pl)
MES1="Błąd: SoundFonts SF1 i SF2 nie zostały znalezione!"
MES2="Błąd: fluidsynth nie został uruchomiony!"
MES3="Błąd: Nie znaleziono SoundFont SF!"
MES4="Wspierane sterowniki dźwięku to: JACK, ALSA!"
MES5="Spróbuj ponownie!"
MES6="Błąd: fluidsynth nie został znaleziony lub jest uszkodzony!"
MES7="Błąd: jackd nie został znaleziony!"
MES8="Uruchamianie fludsynth..."
MES9="Poczekaj jeszcze 10 sekund!"
MES10="Fluidsynth nie ma wsparcia ALSA!"
MES11="Przełączanie na JACK..."
MES12="Błąd: qpiano nie został znaleziony!"
MES13="Błąd: Brak wsparcia dla sterownika dźwięku."
MES14="Ignorowanie..."
;;
esac
if [ -f "/usr/share/soundfonts/FluidR3_GM.sf2" ]
then
sf2_1="/usr/share/soundfonts/FluidR3_GM.sf2"
fi
if [ -f "/usr/share/soundfonts/FluidR3_GS.sf2" ]
then
sf2_2="/usr/share/soundfonts/FluidR3_GS.sf2"
fi
if [ -f "/usr/share/sounds/sf2/FluidR3_GM.sf2" ]
then
sf2_1="/usr/share/sounds/sf2/FluidR3_GM.sf2"
fi
if [ -f "/usr/share/sounds/sf2/FluidR3_GS.sf2" ]
then
sf2_2="/usr/share/sounds/sf2/FluidR3_GS.sf2"
fi
if [ -f "/usr/local/share/sounds/sf2/FluidR3_GM.sf2" ]
then
sf2_1="/usr/local/share/sounds/sf2/FluidR3_GM.sf2"
fi
if [ -f "/usr/local/share/sounds/sf2/FluidR3_GS.sf2" ]
then
sf2_2="/usr/local/share/sounds/sf2/FluidR3_GS.sf2"
fi
notify_send=`notify-send -v 2>/dev/null`
fluidsynth=`fluidsynth -V 2>/dev/null`
qpiano=`qpiano -v 2>/dev/null`
if [ -z "$qpiano" ]
then
echo "$MES12"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES12"
fi
exit 1
fi
if [ -z "$fluidsynth" ]
then
echo "$MES6"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES6"
fi
exit 1
fi
if [ ! -z "$SoundFont2_1" ]
then
if [ ! -f "$SoundFont2_1" ]
then
MES0=`echo "$MES3"|sed "s|SF|$SoundFont2_1|g"`
echo "$MES0" "$MES14"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES0 $MES14"
fi
else
sf2_1="$SoundFont2_1"
sf2_2=""
fi
fi
if [ ! -z "$SoundFont2_2" ]
then
if [ ! -f "$SoundFont2_2" ]
then
MES0=`echo "$MES3"|sed "s|SF|$SoundFont2_2|g"`
echo "$MES0" "$MES14"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES0 $MES14"
fi
else
sf2_1=""
sf2_2="$SoundFont2_2"
fi
fi
if [ ! -z "$SoundFont2_1" ] && [ ! -z "$SoundFont2_2" ]
then
if [ ! -f "$SoundFont2_1" ] && [ ! -f "$SoundFont2_2" ]
then
MES0=`echo "$MES1"|sed "s|SF1|$sf2_1|g"|sed "s|SF2|$sf2_2|g"`
echo "$MES0" "$MES14"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES0 $MES14"
fi
else
sf2_1="$SoundFont2_1"
sf2_2="$SoundFont2_2"
fi
fi
if [ -z "$sf2_1" ]
then
MES0=`echo "$MES3"|sed "s|SF|FluidR3_GM.sf2|g"`
echo "$MES0"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES0"
fi
exit 1
fi
if [ ! "$audioDriverCombo" = "jack" ] && [ ! "$audioDriverCombo" = "alsa" ] && [ ! -z "$audioDriverCombo" ]
then
echo "$MES13" "$audioDriverCombo". "$MES4" "$MES14"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES13 $audioDriverCombo. $MES4 $MES14"
fi
fi
if [ ! -z "$sf2_1" ] && [ -z "$sf2_2" ]
then
if [ ! -f "$sf2_1" ]
then
MES0=`echo "$MES3"|sed "s|SF|$sf2_1|g"`
echo "$MES0"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES0"
fi
exit 1
fi
fi
if [ -z "$sf2_1" ] && [ ! -z "$sf2_2" ]
then
if [ ! -f "$sf2_2" ]
then
MES0=`echo "$MES3"|sed "s|SF|$sf2_2|g"`
echo "$MES0"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES0"
fi
exit 1
fi
fi
alsa=`fluidsynth -o help|grep alsa`
if [ "$use_jack" = "0" ] && [ -z "$alsa" ]
then
echo "$MES10" "$MES11"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES10 $MES11"
fi
use_jack="1"
sed -i "s|audioDriverCombo=.*|audioDriverCombo=jack|g" ~/.config/QPiano/"QPiano.ini" 2>/dev/null
fi
if [ ! -f "/usr/bin/jackd" ] && [ "$use_jack" = "1" ]
then
if [ ! -f "/usr/local/bin/jackd" ]
then
echo "$MES7"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES7"
fi
exit 1
fi
fi
if [ "$use_jack" = "1" ] && [ ! -z `uname -s|grep BSD` ]
then
if [ ! -f ~/.jackdrc ]
then
echo "/usr/local/bin/jackd -r -d oss" > ~/.jackdrc
touch ~/.qpiano
fi
fi
if [ "$use_jack" = "1" ]
then
echo "$MES8" "$MES9"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES8 $MES9"
fi
fi
if [ "$use_jack" = "1" ]
then
if [ ! -z "$alsa" ]
then
fluidsynth -i -s -g $masterGain -C $chorus -R $reverb -r $sampleRate -c $bufferCounts -z $bufferSize -l -a jack -o midi.alsa_seq.id=fs -j $sf2_1 $sf2_2 &
else
fluidsynth -i -s -g $masterGain -C $chorus -R $reverb -r $sampleRate -c $bufferCounts -z $bufferSize -l -a jack -j $sf2_1 $sf2_2 &
fi
else
fluidsynth -i -s -g $masterGain -C $chorus -R $reverb -r $sampleRate -c $bufferCounts -z $bufferSize -l -a alsa -o audio.alsa.device=$audioDevice -o midi.alsa_seq.id=fs $sf2_1 $sf2_2 &
fi
PID=$!
if [ "$use_jack" = "1" ]
then
sleep 10
else
sleep 3
fi
process=`ps -p $PID -o comm= 2>/dev/null`
if [ -z $process ]
then
echo "$MES2 $MES5"
if [ ! -z "$notify_send" ]
then
notify-send -a qpiano -i qpiano "QPiano" "$MES2 $MES5"
fi
exit 1
fi
qpiano
kill $PID
if [ "$use_jack" = "1" ]
then
sleep 5
fi
if [ -f ~/.qpiano ]
then
rm -f ~/.jackdrc
rm -f ~/.qpiano
fi