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
72179400200true129170164_Browse11911335123{e34d9fad-e494-4adc-a38c-41fd0dd4cd22}true0-3left
Lucida Grande
103000242241240nobackground_Browse137811110030{f8cc5a8e-5d74-4e6a-b0ef-14b3536bee69}true0-3value1.00000000/home/linux/Joachim/Materialien/SamplesKlangbearbeitung/TrommelStereo.aiffOpen File/falsefalsedb11726213631{10f84ac4-d6cc-468a-87f8-92cf47247d27}true0-3-18.0000000018.000000000.00000000lincontinuous-1.00000000falsedb_disp2582629831{d5d4423c-8a1f-45f4-bff6-99b8c93ac27c}true0-3right
Lucida Grande
183000255255255noborder11201487826{c0de047a-de03-4e6d-a942-b71b2821460d}true0-3event1.00000000Play/i 2 0 1 0falsefalse2231508025{539bf852-6d92-4e53-a7ce-a478772c8a44}true0-3event1.00000000Stop/i 1 0 .1falsefalseskip212168725{d697a9c4-6c99-4f8a-b884-8d537fc7a24b}true0-3right
Lucida Grande
100002552552550.00100000-1e+121e+12false1.4091221498025{ae8f2ca0-5960-4a9b-853d-22682c1c7916}true0-3event1.00000000Pause/i 3 0 .1falsefalseloop1522162020{855b6884-ed0d-41cc-9a8d-0f3c0315c598}true0-3false1falsemin3443483730{e1155724-576d-4aae-8754-ae799eb0c75f}true0-3right
Lucida Grande
183000255255255noborder11sec3913483531{6058c806-9a20-44fa-8bf8-90de2a58b2df}true0-3right
DejaVu Sans
183000255255255noborder113793481429{e9e4b8b3-f548-4ced-919a-5f6c720396f2}true0-3center
Lucida Grande
183000255255255noborder11211908830{bd6fb429-6df6-4f5a-8c1c-4f6dc140ba25}true0-3center
Lucida Grande
143000255255255noborder111301925930{7a8c2d5d-63af-4119-a8fe-ef9729ae54d7}true0-3center
Lucida Grande
143000255255255noborder11222618830{aa0fbe1b-dc9c-4327-aea7-150a02671a6c}true0-3center
Lucida Grande
183000255255255noborder11message2445646093{060268f7-354f-4607-9414-e03dde72fec9}true0-3center
DejaVu Sans
143000217217217border112542246035{6f1c335f-3050-4a5f-9064-b548712251e3}true00center
DejaVu Sans
183000255255255noborder11outL2432825019{e53212e6-26b1-4255-8dd1-29982a5f376d}true0-3out1_post0.000000001.000000000.000000001.000000000.000000000.57894700fill10.00000000jump02340false000outLover2713282119{1ac98e63-ff22-42c2-b9b4-211a3387ff55}true0-3outLover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jump1961412false000outR2435525019{5cbb1b94-11b9-40e7-9138-067e4f80499c}true0-3out2_post0.000000001.000000000.000000001.000000000.000000001.00000000fill10.00000000jump02340false000outRover2713552119{b7f5355c-78ed-416f-ac68-29ae4c154f8a}true0-3outRover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jump1961412false000dbrange1093908025{6d740e31-aaaf-436a-9453-71580162329e}true0-3left
Lucida Grande
100002552552550.10000000-1e+121e+12false482438913127{9fc8a154-0fe8-4fde-bb06-8dba5528d450}true0-3left
Helvetica
143000255255255noborder11peakhold3573905725{b473b128-28a5-4d0d-9b45-72c54f2ed380}true0-3left
Lucida Grande
100002552552551.00000000-1e+121e+12false323538913127{a867c3ca-9514-41aa-aa8d-9ff0601663b5}true0-3left
DejaVu Sans
143000255255255noborder11convertsr2242162020{57f660c3-d691-455f-adc2-8dc2b9ad37dc}true0-3false1false2021926230{3c00cb24-4168-42b6-9712-2c3b164a713f}true0-3center
Lucida Grande
143000255255255noborder11hor3023473232{87ddb84f-bf28-4d96-873e-a0c53debc142}true0-3right
Lucida Grande
183000255255255noborder11ms4373494430{8779b080-2fdf-4bbe-bf88-7ae8b8498fa6}true0-3right
DejaVu Sans
183000255255255noborder113333491429{9984c1e1-e917-4c01-83ab-2abc74e18727}true0-3center
Lucida Grande
183000255255255noborder114243481429{12212202-7a08-49ad-ab9a-a782c1cc583f}true0-3center
Lucida Grande
183000255255255noborder112993203929{cb2a8386-7d8a-48dc-9054-c28ee0f3f3a2}true0-3center
Lucida Grande
143000255255255noborder113443203929{f0b3453f-2fed-4ad0-9770-5b4f474bb9c0}true0-3center
Lucida Grande
143000255255255noborder113903203929{072b078f-ff66-412c-acf3-e3d3947ef197}true0-3center
Lucida Grande
143000255255255noborder114393203929{f1be4380-79a4-40f9-a994-cef2cee3b3c1}true0-3center
Lucida Grande
143000255255255noborder1127719418754{39ddd5a0-7219-4007-b12b-0c8269b25eab}true0-3center
Lucida Grande
123000255255255noborder11491839843{b6052bac-c509-4ba4-bcea-1249daef98d7}true0-3center
Lucida Grande
263000255255255noborder11486039843{45328377-9c80-4d16-b4fa-470ce623a64f}true0-3center
Lucida Grande
223000255255255noborder11