sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
0dbfs = 1.0
instr 1
ifn = p4 ; Table number to store sample
Sfile strget p5 ; File name
ichannel = p6 ; 0 = mixed mono, 1 = left, 2 = right
isamplerate filesr Sfile ; Sample rate of file
ilength filelen Sfile ; Length of sample in seconds
ilength = ilength * isamplerate ; Length of sample in sample frames
; Get the power of 2 table size that the sample fits
ipow_of_2 = 2 ^ ceil(log(ilength) / log(2))
; Create table
itemp ftgen ifn, 0, ipow_of_2, 1, Sfile, 0, 0, ichannel
turnoff
endin
instr 2
ifn = p4
isize = ftlen(ifn)
prints "Index\tValue\n"
i_index = 0
loop_start:
ivalue tab_i i_index, ifn
prints "%d:\t%f\n", i_index, ivalue
loop_lt i_index, 1, isize, loop_start
turnoff
endin
i 1 0 1 100 "./sound.aif" 0
i 2 0 1 100