sr = 44100
ksmps = 16
nchnls = 2
0dbfs = 1
/*****Playing a soundfile 1b: play from a buffer*****/
;written by joachim heintz and andres cabrera
;mar 2009
instr 1; fill the buffer and play
Sfile invalue "_Browse1" ;GUI input
gichn filenchnls Sfile; check if mono or stereo
;reading the data in the buffers (function tables)
giL ftgen 0, 0, 0, 1, Sfile, 0, 0, 1
if gichn == 2 then
giR ftgen 0, 0, 0, 1, Sfile, 0, 0, 2
endif
turnon 2
endin
instr 2; read the buffer
;GUI input
kskip invalue "skip"
kloop invalue "loop"
iskip = i(kskip)
iloop = i(kloop)
;comparing the sample rates and reading the buffer
ilensmps = ftlen(giL)
idur = ilensmps / sr; duration to read the buffer
ireadfreq = sr / ilensmps; frequency of reading the buffer
iphs = iskip / idur; starting point as phase
aL poscil3 1, ireadfreq, giL, iphs
if gichn == 2 then
aR poscil3 1, ireadfreq, giR, iphs; right channel for stereo soundfile
else
aR = aL; right channel for mono soundfile
endif
;stop instr after playing the buffer if no loop
ktim timeinsts
if iloop == 0 && ktim > idur-iskip then
turnoff
endif
outs aL, aR
endin
instr 3; turns off instr 2
turnoff2 2, 0, 0
endin
f 0 36000; don't listen to music longer than 10 hours
e
127460602true127170134_Browse1279629524{4b9ff4d6-f93b-471c-8d3b-8f94f2c6f948}true0-3left
Lucida Grande
103000229229229nobackground_Browse13279310030{0bec8b20-55d0-4e86-b558-e8464ce6530a}true0-3value1.00000000Open File/falsefalse1241397826{25ac6f50-68b3-4f53-8b60-66f6a60801a1}true0-3event1.00000000Play/i 1 0 9999falsefalse2251408025{bf4f12d5-4d8b-471a-a52d-d37135249573}true0-3event1.00000000Stop/i 3 0 .1falsefalseskip1561858725{79dec561-416b-4808-bc96-71900361766c}true0-3right
Lucida Grande
100002552552550.00100000-1e+121e+12false0loop3181882020{388179e5-59be-49c1-859c-3c8ef59c5cb8}true0-3false1false761848028{2f88b481-1b38-42cd-a00f-aae03542db9f}true0-3center
Lucida Grande
143000255255255noborder112671835229{c4ddb6ad-ce7a-4624-9959-0d8475b121ae}true0-3center
Lucida Grande
143000255255255noborder11291039843{d51eabbc-9ac1-4400-bdce-abffa14335ab}true0-3center
Lucida Grande
263000255255255noborder11285239843{cde28586-8a73-4794-ac1c-09f1d5af0a2c}true0-3center
Lucida Grande
223000255255255noborder1125410410182{d7bc07b9-a49e-44b3-b942-27546029fac0}true00center
DejaVu Sans
143000255255255noborder113122839789{75ecdfe7-0ac2-433a-b89b-cc2270259ddb}true0-31.00000000scope2.000000001.000000001.000000001.000000000.000000003231439789{440fb58b-dbb2-42db-9f4e-4f15331f5a18}true0-32.00000000scope2.000000001.000000001.000000001.000000000.00000000