sr = 44100
ksmps = 16
nchnls = 2
0dbfs = 1
/*****Playing a soundfile 2b: Play from a buffer with more features*****/
;written by joachim heintz and andres cabrera
;mar 2009
opcode PlayBuf, ak, iiikiki
/*Plays a buffer (function table) with a known length,
and gives the time in the range 0-1.*/
/*input:
ifn: name or nummer of the function table
ifnlen: its length in samples resp. indices
ifnsr: its samplerate
kspeed: speed of reading (1 = normal)
iskip: skiptime in seconds
kvol: volume multiplier (1 = normal)
icnvrt: 1 = samplerate conversion if the sr of the soundfile is not the same as in the orchestra; 0 = no conversion
*/
/*output:
asig: audio signal reading the table
ktimout: time in the table in seconds
*/
ifn, ifnlen, ifnsr, kspeed, iskip, kvol, icnvrt xin
if ifnsr != sr then
setksmps 1; if sr is different, set local ksmps to 1 for best quality
endif
if icnvrt == 1 then
irel = ifnlen / ifnsr
else
irel = ifnlen / sr
endif
kcps = kspeed / irel
iphs = iskip / irel
asig poscil3 kvol, kcps, ifn, iphs
ktim phasor kcps, iphs
ktimout = ktim * irel
xout asig, ktimout
endop
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; always on
gkpaus init 0; status of the pause button
gkspeed init 1; speed for reading the buffer
gkconvertsr invalue "convertsr"
kdb invalue "db"; gain value in dB
gkskip invalue "skip"; skiptime in sec
gkloop invalue "loop"; value 1 if checked
;volume display
gkmult = ampdbfs(kdb)
Sdb_disp sprintfk "%+.2f dB", kdb
outvalue "db_disp", Sdb_disp
endin
instr 2 ;play
Sfile invalue "_Browse1"; get the name (look at the example in Examples->Reserved Channels)
gilen filelen Sfile; duration of the file
gichn filenchnls Sfile; is the file mono or stereo
gifilesr filesr Sfile
;reading the data in the buffers (function tables)
giL ftgen 0, 0, 0, -1, Sfile, 0, 0, 1
gilenbuf = ftlen(giL)
if gichn == 2 then
giR ftgen 0, 0, 0, -1, Sfile, 0, 0, 2
endif
;send a message if the sr of the file doesn't match the sr of the orchestra
if gifilesr != sr then
if i(gkconvertsr) == 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
if gkpaus == 1 then ;if pause
event "i", 4, 0, .1; call the pause instr
else
event "i", 10, 0, 1
endif
turnoff
endin
instr 3; stop
turnoff2 1, 0,0
endin
instr 4; pause/resume
if gkpaus == 0 then
gkspeed = 0
gkpaus = 1
else
gkspeed = 1
gkpaus = 0
endif
turnoff
endin
instr 10; playing
iloop = i(gkloop)
iskip = i(gkskip)
icnvrt = i(gkconvertsr)
kdbrange invalue "dbrange" ;dB range for the meters
kpeakhold invalue "peakhold" ;Duration of clip indicator hold in seconds
idur = (iloop == 1 ? 9999 : gilen - iskip)
p3 = idur
if gichn == 1 then
aL, ktimout PlayBuf giL, gilenbuf, gifilesr, gkspeed, iskip, gkmult, icnvrt
aR = aL
else
aL, ktimout PlayBuf giL, gilenbuf, gifilesr, gkspeed, iskip, gkmult, icnvrt
aR, knix PlayBuf giR, gilenbuf, gifilesr, gkspeed, iskip, gkmult, icnvrt
endif
;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
;read and show time
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
outs aL, aR
endin
i 1 0 36000; don't listen to music longer than 10 hours
e
00483539true120138170_Browse1159534524{16aca12d-8e44-4b5c-9e02-6db2c75f57e3}true00left
DejaVu Sans
103000229229229nobackground_Browse13629210030{903e3360-4b33-4c1e-8063-1d4c05bb242a}true0-3value1.00000000/home/linux/Joachim/Materialien/SamplesKlangbearbeitung/PassageMono.aiffOpen File/falsefalsedb11023516031{79bc1456-4022-44f7-8e0d-225f5e96526b}true0-3-18.0000000018.00000000-0.45000000lincontinuous-1.00000000falsedb_disp27023512031{0150cd3e-fcf9-4433-a8a2-e43791847383}true00left
DejaVu Sans
183000255255255noborder11131387826{a291df2a-9d8b-4a45-ab3d-c4bb52537abb}true0-3event1.00000000Play/i 2 0 .1falsefalse_Stop2211388025{e3508832-4264-4f71-becd-61be2a132d5b}true0-3value1.00000000Stop/i 3 0 .1falsetrueskip132038725{d6f2a1f3-eb8b-4082-8b03-eca92a7db848}true0-3right
Lucida Grande
100002552552550.00100000-1e+121e+12false01151378025{0e7e868a-bb71-4ed9-9f5c-8a5168d53620}true0-3event1.00000000Pause/i 4 0 .1falsefalseloop1412002020{18e70fdf-dbab-4cf7-9c33-f7e5db09ad56}true0-3false1falsemin3312963730{427186bf-14a9-4b64-8a19-d22cce59633d}true0-3right
Lucida Grande
183000255255255noborder11sec3782963531{5d54bf1a-4ba9-4a73-8b1c-821429894ba6}true0-3right
DejaVu Sans
183000255255255noborder113662961429{ad04bd24-c15e-48bd-b79a-aef90a60f8c0}true0-3center
Lucida Grande
183000255255255noborder11111728830{0989bcfd-9791-4812-b5c8-9d564434be8d}true0-3center
Lucida Grande
143000255255255noborder111201745930{8a1f863a-148c-4eea-897d-f8c4ae5bb01f}true0-3center
Lucida Grande
143000255255255noborder11122348830{e58f4db9-254f-430c-9d75-6f57d504fbe5}true0-3center
Lucida Grande
183000255255255noborder11message9399464131{a5c41213-116d-4c3b-b779-b0f2db33cb7b}true00center
DejaVu Sans
143000197197197border111136446230{057ac2d1-8533-4178-a423-87cdc6ea13fc}true0-3center
Lucida Grande
183000255255255noborder11outL1027325019{41760197-5e26-4055-8358-c6a1e7d58fa3}true0-3out1_post0.000000001.000000000.000000001.000000000.506171350.52631600fill10.00000000jump02340false000outLover2582732119{e082e5d1-8e6a-4662-8b3f-2e8cb50814e5}true0-3outLover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jump1961412false000outR1030025019{9530a3d5-9c8f-4e3f-a369-37d31ce808d8}true0-3out2_post0.000000001.000000000.000000001.000000000.506171350.52631600fill10.00000000jump02340false000outRover2583002119{8487174c-0be1-472d-bbd7-3910cb0ee79b}true0-3outRover0.000000001.000000000.000000001.000000000.000000000.00000000fill10.00000000jump1961412false000dbrange963308025{e56c5ecf-8dd6-4ab6-a692-0d0af432ec5e}true0-3left
Lucida Grande
100002552552550.10000000-1e+121e+12false48113298127{fdb9a176-d48a-47d5-a4f5-8d8206a668f0}true00left
Nimbus Sans L
143000255255255noborder11peakhold3483315725{2eec9b56-b85e-4c82-8b51-e852c51d13f3}true0-3left
Lucida Grande
100002552552551.00000000-1e+121e+12false321832913127{a2a86f3a-03d7-4069-b13c-aa66c4e1a1f2}true0-3left
DejaVu Sans
143000255255255noborder11convertsr2162012020{9a016013-437a-42fb-bec6-c8b6b26161cb}true0-3false1false1921746230{877b025c-3d7a-4143-b0b2-8bffe7ae7591}true0-3center
Lucida Grande
143000255255255noborder11hor2892953232{728567e2-f821-4f99-bc41-86d8d09ca29f}true0-3right
Lucida Grande
183000255255255noborder11ms4242974430{bdf71544-8723-4843-aa62-5bd7463479fa}true0-3right
DejaVu Sans
183000255255255noborder113202971429{c5db02d0-f14f-491a-85e3-0ae9a9fb2e17}true0-3center
Lucida Grande
183000255255255noborder114112961429{3be38656-011b-4f94-b4b4-4aaf49e4c2f7}true0-3center
Lucida Grande
183000255255255noborder112862683929{1defe710-4b95-4b28-a441-add693fb143b}true0-3center
Lucida Grande
143000255255255noborder113312683929{3e752ddf-02ab-4d1e-a8b6-75166f26b6c5}true0-3center
Lucida Grande
143000255255255noborder113772683929{f51e465c-fa73-4ab7-861d-310f7f1cdb90}true0-3center
Lucida Grande
143000255255255noborder114262683929{28af6ecc-132b-43f2-a5df-4bafbc2e9716}true0-3center
Lucida Grande
143000255255255noborder1125617321854{b4ded076-4eba-4e14-a816-056de35c4eaa}true0-3center
Lucida Grande
123000255255255noborder1115945046{d03f29ef-2f75-435d-922b-27d8b592105d}true0-3center
Lucida Grande
263000255255255noborder11145145046{17681a9f-a482-46f8-8a5e-77ad193c08ce}true0-3center
Lucida Grande
223000255255255noborder11