sr = 44100 ksmps = 16 nchnls = 2 0dbfs = 1 /*****Playing a soundfile 2a: Play from the Harddisk with more features*****/ ;written by joachim heintz, andres cabrera and victor lazzarini ;mar 2009 / dec 2011 opcode ShowLED_a, 0, Sakik ;Shows an audio signal in an outvalue channel. ;You can choose to show the value in dB or in raw amplitudes. ; ;Input: ;Soutchan: string with the name of the outvalue channel ;asig: audio signal which is to displayed ;kdispfreq: refresh frequency (Hz) ;idb: 1 = show in dB, 0 = show in raw amplitudes (both in the range 0-1) ;idbrange: if idb=1: how many db-steps are shown (e.g. if 36 you will not see anything from a signal below -36 dB) Soutchan, asig, ktrig, idb, kdbrange xin kdispval max_k asig, ktrig, 1 if idb != 0 then kdb = dbfsamp(kdispval) kval = (kdbrange + kdb) / kdbrange else kval = kdispval endif if ktrig == 1 then outvalue Soutchan, kval endif endop opcode ShowOver_a, 0, Sakk ;Shows if the incoming audio signal was more than 1 and stays there for some time ;Input: ;Soutchan: string with the name of the outvalue channel ;asig: audio signal which is to displayed ;kdispfreq: refresh frequency (Hz) ;khold: time in seconds to "hold the red light" Soutchan, asig, ktrig, khold xin kon init 0 ktim times kstart init 0 kend init 0 khold = (khold < .01 ? .01 : khold); avoiding too short hold times kmax max_k asig, ktrig, 1 if kon == 0 && kmax > 1 && ktrig == 1 then kstart = ktim kend = kstart + khold outvalue Soutchan, kmax kon = 1 endif if kon == 1 && ktim > kend && ktrig == 1 then outvalue Soutchan, 0 kon = 0 endif endop instr 1; stop turnoff2 4, 0, 0 turnoff2 10, 0, 0 outvalue "outL", 0 outvalue "outR", 0 outvalue "outLover", 0 outvalue "outRover", 0 gktimi10k = 0; reset the clock gkpaus = 0; reset pause status turnoff endin instr 2 ;read file info and play gSfile invalue "_Browse1"; get the name (look at the example in Examples->Reserved Channels) gilen filelen gSfile; duration of the file gichn filenchnls gSfile; is the file mono or stereo gifilesr filesr gSfile kconvertsr invalue "convertsr" giconvrt = i(kconvertsr) gktimi10k = p4; time instr 10 has performed in k-cycles gkpaus = 0; status of the pause button imaxlen = 36000; maximum length of loop play ;send a message if the sr of the file doesn't match the sr of the orchestra if gifilesr != sr then if giconvrt == 1 then Swarn sprintf "Warning:\nSamplerate of the file is %d, but samplerate of the orchestra is %d. Samplerate will be converted by changing speed of reading.", gifilesr, sr outvalue "message", Swarn else Swarn sprintf "Warning:\nSamplerate of the file is %d, but samplerate of the orchestra is %d. Samplerate will not be converted, so you will have changes in tempo and pitch.", gifilesr, sr outvalue "message", Swarn endif else Smess sprintf "Length = %.3f\nSamplerate = %d\nChannels = %d", gilen, gifilesr, gichn outvalue "message", Smess endif event_i "i", 4, 0, imaxlen turnoff endin instr 3; pause and resume if gkpaus == 0 then turnoff2 4, 0, 0 turnoff2 10, 0, 0 gkpaus = 1 else turnoff2 10, 0, 0 event "i", 2, 0, 1, gktimi10k gkpaus = 0 endif turnoff endin instr 4 ilen = gilen ilenk = ilen * kr; duration of the file in k-cycles ichn = gichn gkdb invalue "db"; gain value in dB kskip invalue "skip"; skiptime in sec iskip = i(kskip) itimi10k = i(gktimi10k) % ilenk; time instr 10 was active in control cycles in respect to the loops kloop invalue "loop"; value 1 if checked iloop = i(kloop) istart = iskip + (itimi10k / kr) ;playing iplaylen = (iloop == 1 ? p3 : ilen) event_i "i", 10, 0, iplaylen, istart, ichn, giconvrt ;time output ktimout = (gktimi10k / kr + iskip) % ilen; position in the soundfile in seconds ktimouthor = int(ktimout / 3600) Shor sprintfk "%02d", ktimouthor ktimoutmin = int(ktimout / 60) Smin sprintfk "%02d", ktimoutmin ktimoutsec = int(ktimout % 60) Ssec sprintfk "%02d", ktimoutsec ktimoutms = frac(ktimout) * 1000 Sms sprintfk "%03d", ktimoutms outvalue "hor", Shor outvalue "min", Smin outvalue "sec", Ssec outvalue "ms", Sms ;turnoff if no loop and end of file is reached if iloop == 0 && ktimout > ilen then event "i", 1, 0, .1 turnoff endif endin instr 10 iskip = p4 ichn = p5 iconvrt = (p6 == 1 ? 0 : 1) k1 = 1 kdbrange invalue "dbrange" ;dB range for the meters kpeakhold invalue "peakhold" ;Duration of clip indicator hold in seconds; if ichn == 1 then aL diskin2 gSfile, 1, iskip, 1, 0, iconvrt aR = aL else printk2 k1 aL, aR diskin2 gSfile, 1, iskip, 1, 0, iconvrt endif ;Volume kmult = ampdbfs(gkdb) Sdb_disp sprintfk "%+.2f dB", gkdb outvalue "db_disp", Sdb_disp aL = aL * kmult aR = aR * kmult ;show output kTrigDisp metro 10 ShowLED_a "outL", aL, kTrigDisp, 1, kdbrange ShowLED_a "outR", aR, kTrigDisp, 1, kdbrange ShowOver_a "outLover", aL, kTrigDisp, kpeakhold ShowOver_a "outRover", aR, kTrigDisp, kpeakhold outs aL, aR gktimi10k = gktimi10k + 1; count the time instr 10 was active endin f 0 36000; don't listen to music longer than 10 hours e 72 179 400 200 true 129 170 164 _Browse1 19 113 351 23 {e34d9fad-e494-4adc-a38c-41fd0dd4cd22} true 0 -3 left Lucida Grande 10 3 0 0 0 242 241 240 nobackground _Browse1 378 111 100 30 {f8cc5a8e-5d74-4e6a-b0ef-14b3536bee69} true 0 -3 value 1.00000000 /home/linux/Joachim/Materialien/SamplesKlangbearbeitung/TrommelStereo.aiff Open File / false false db 117 262 136 31 {10f84ac4-d6cc-468a-87f8-92cf47247d27} true 0 -3 -18.00000000 18.00000000 0.00000000 lin continuous -1.00000000 false db_disp 258 262 98 31 {d5d4423c-8a1f-45f4-bff6-99b8c93ac27c} true 0 -3 right Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 20 148 78 26 {c0de047a-de03-4e6d-a942-b71b2821460d} true 0 -3 event 1.00000000 Play / i 2 0 1 0 false false 223 150 80 25 {539bf852-6d92-4e53-a7ce-a478772c8a44} true 0 -3 event 1.00000000 Stop / i 1 0 .1 false false skip 21 216 87 25 {d697a9c4-6c99-4f8a-b884-8d537fc7a24b} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 0.00100000 -1e+12 1e+12 false 1.409 122 149 80 25 {ae8f2ca0-5960-4a9b-853d-22682c1c7916} true 0 -3 event 1.00000000 Pause / i 3 0 .1 false false loop 152 216 20 20 {855b6884-ed0d-41cc-9a8d-0f3c0315c598} true 0 -3 false min 344 348 37 30 {e1155724-576d-4aae-8754-ae799eb0c75f} true 0 -3 right Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 sec 391 348 35 31 {6058c806-9a20-44fa-8bf8-90de2a58b2df} true 0 -3 right DejaVu Sans 18 3 0 0 0 255 255 255 noborder 1 1 379 348 14 29 {e9e4b8b3-f548-4ced-919a-5f6c720396f2} true 0 -3 center Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 21 190 88 30 {bd6fb429-6df6-4f5a-8c1c-4f6dc140ba25} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 130 192 59 30 {7a8c2d5d-63af-4119-a8fe-ef9729ae54d7} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 22 261 88 30 {aa0fbe1b-dc9c-4327-aea7-150a02671a6c} true 0 -3 center Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 message 24 456 460 93 {060268f7-354f-4607-9414-e03dde72fec9} true 0 -3 center DejaVu Sans 14 3 0 0 0 217 217 217 border 1 1 25 422 460 35 {6f1c335f-3050-4a5f-9064-b548712251e3} true 0 0 center DejaVu Sans 18 3 0 0 0 255 255 255 noborder 1 1 outL 24 328 250 19 {e53212e6-26b1-4255-8dd1-29982a5f376d} true 0 -3 out1_post 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.57894700 fill 1 0.00000000 jump 0 234 0 false 0 0 0 outLover 271 328 21 19 {1ac98e63-ff22-42c2-b9b4-211a3387ff55} true 0 -3 outLover 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 196 14 12 false 0 0 0 outR 24 355 250 19 {5cbb1b94-11b9-40e7-9138-067e4f80499c} true 0 -3 out2_post 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 1.00000000 fill 1 0.00000000 jump 0 234 0 false 0 0 0 outRover 271 355 21 19 {b7f5355c-78ed-416f-ac68-29ae4c154f8a} true 0 -3 outRover 0.00000000 1.00000000 0.00000000 1.00000000 0.00000000 0.00000000 fill 1 0.00000000 jump 196 14 12 false 0 0 0 dbrange 109 390 80 25 {6d740e31-aaaf-436a-9453-71580162329e} true 0 -3 left Lucida Grande 10 0 0 0 255 255 255 0.10000000 -1e+12 1e+12 false 48 24 389 131 27 {9fc8a154-0fe8-4fde-bb06-8dba5528d450} true 0 -3 left Helvetica 14 3 0 0 0 255 255 255 noborder 1 1 peakhold 357 390 57 25 {b473b128-28a5-4d0d-9b45-72c54f2ed380} true 0 -3 left Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 3 235 389 131 27 {a867c3ca-9514-41aa-aa8d-9ff0601663b5} true 0 -3 left DejaVu Sans 14 3 0 0 0 255 255 255 noborder 1 1 convertsr 224 216 20 20 {57f660c3-d691-455f-adc2-8dc2b9ad37dc} true 0 -3 false 202 192 62 30 {3c00cb24-4168-42b6-9712-2c3b164a713f} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 hor 302 347 32 32 {87ddb84f-bf28-4d96-873e-a0c53debc142} true 0 -3 right Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 ms 437 349 44 30 {8779b080-2fdf-4bbe-bf88-7ae8b8498fa6} true 0 -3 right DejaVu Sans 18 3 0 0 0 255 255 255 noborder 1 1 333 349 14 29 {9984c1e1-e917-4c01-83ab-2abc74e18727} true 0 -3 center Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 424 348 14 29 {12212202-7a08-49ad-ab9a-a782c1cc583f} true 0 -3 center Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 299 320 39 29 {cb2a8386-7d8a-48dc-9054-c28ee0f3f3a2} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 344 320 39 29 {f0b3453f-2fed-4ad0-9770-5b4f474bb9c0} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 390 320 39 29 {072b078f-ff66-412c-acf3-e3d3947ef197} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 439 320 39 29 {f1be4380-79a4-40f9-a994-cef2cee3b3c1} true 0 -3 center Lucida Grande 14 3 0 0 0 255 255 255 noborder 1 1 277 194 187 54 {39ddd5a0-7219-4007-b12b-0c8269b25eab} true 0 -3 center Lucida Grande 12 3 0 0 0 255 255 255 noborder 1 1 49 18 398 43 {b6052bac-c509-4ba4-bcea-1249daef98d7} true 0 -3 center Lucida Grande 26 3 0 0 0 255 255 255 noborder 1 1 48 60 398 43 {45328377-9c80-4d16-b4fa-470ce623a64f} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 noborder 1 1