| 1 |
echo Sound files... |
| 2 |
procedure test .type$ .extension$ .duration |
| 3 |
printline Testing '.type$' files... |
| 4 |
for numberOfChannels from 1 to 8 |
| 5 |
print 'numberOfChannels' channels: |
| 6 |
sound = Create Sound from formula... sound numberOfChannels 0 .duration/numberOfChannels 44100 1/4 * sin(2*pi*377*x) + randomGauss(0,0.05) |
| 7 |
Shift times to between zero and physical duration |
| 8 |
Formula: ~ round (self * 32768) / 32768 |
| 9 |
energy1 = Get energy in air |
| 10 |
Save as '.type$' file... kanweg.'.extension$' |
| 11 |
stopwatch |
| 12 |
sound2 = Read from file... kanweg.'.extension$' |
| 13 |
t = stopwatch |
| 14 |
energy2 = Get energy in air |
| 15 |
assert "'energy1:12'" = "'energy2:12'" ; 'numberOfChannels' |
| 16 |
plus sound |
| 17 |
Remove |
| 18 |
deleteFile ("kanweg." + .extension$) |
| 19 |
printline 't:4' seconds |
| 20 |
endfor |
| 21 |
endproc |
| 22 |
procedure test24 .type$ .extension$ .duration |
| 23 |
printline Testing 24-bit '.type$' files... |
| 24 |
for numberOfChannels from 1 to 8 |
| 25 |
print 'numberOfChannels' channels: |
| 26 |
sound = Create Sound from formula... sound numberOfChannels 0 .duration/numberOfChannels 44100 1/4 * sin(2*pi*377*x) + randomGauss(0,0.05) |
| 27 |
Shift times to between zero and physical duration |
| 28 |
Formula: ~ round (self * 32768*256) / (32768*256) |
| 29 |
energy1 = Get energy in air |
| 30 |
Save as 24-bit '.type$' file... kanweg.'.extension$' |
| 31 |
stopwatch |
| 32 |
sound2 = Read from file... kanweg.'.extension$' |
| 33 |
t = stopwatch |
| 34 |
energy2 = Get energy in air |
| 35 |
assert "'energy1:12'" = "'energy2:12'" |
| 36 |
plus sound |
| 37 |
Remove |
| 38 |
deleteFile ("kanweg." + .extension$) |
| 39 |
printline 't:4' seconds |
| 40 |
endfor |
| 41 |
endproc |
| 42 |
procedure test32 .type$ .extension$ .duration |
| 43 |
printline Testing 32-bit '.type$' files... |
| 44 |
for numberOfChannels from 1 to 8 |
| 45 |
print 'numberOfChannels' channels: |
| 46 |
sound = Create Sound from formula... sound numberOfChannels 0 .duration/numberOfChannels 44100 1/4 * sin(2*pi*377*x) + randomGauss(0,0.05) |
| 47 |
Shift times to between zero and physical duration |
| 48 |
Formula: ~ round (self * 32768*65536) / (32768*65536) |
| 49 |
energy1 = Get energy in air |
| 50 |
Save as 32-bit '.type$' file... kanweg.'.extension$' |
| 51 |
stopwatch |
| 52 |
sound2 = Read from file... kanweg.'.extension$' |
| 53 |
t = stopwatch |
| 54 |
energy2 = Get energy in air |
| 55 |
assert "'energy1:12'" = "'energy2:12'" ; '.type$' '.extension$' '.duration' |
| 56 |
plus sound |
| 57 |
Remove |
| 58 |
deleteFile ("kanweg." + .extension$) |
| 59 |
printline 't:4' seconds |
| 60 |
endfor |
| 61 |
endproc |
| 62 |
Debug... no 18 |
| 63 |
call test WAV wav 3 |
| 64 |
Debug... no 0 |
| 65 |
call test WAV wav 3 |
| 66 |
Debug... no 0 |
| 67 |
call test AIFF aiff 3 |
| 68 |
call test AIFC aifc 3 |
| 69 |
call test NeXT/Sun au 3 |
| 70 |
call test NIST nist 3 |
| 71 |
@test: "Kay sound", "nsp", 3 |
| 72 |
call test FLAC flac 3 |
| 73 |
Debug... no 18 |
| 74 |
call test WAV wav 30 |
| 75 |
Debug... no 0 |
| 76 |
call test WAV wav 30 |
| 77 |
call test24 WAV wav 3 |
| 78 |
Debug... no 18 |
| 79 |
call test32 WAV wav 3 |
| 80 |
Debug... no 0 |
| 81 |
call test32 WAV wav 3 |
| 82 |
|
| 83 |
procedure do |
| 84 |
Read from file... test.wav |
| 85 |
wavEnergy = Get energy in air |
| 86 |
Remove |
| 87 |
|
| 88 |
Read from file... test.flac |
| 89 |
flacEnergy = Get energy in air |
| 90 |
Remove |
| 91 |
|
| 92 |
assert "'wavEnergy:12'" = "'flacEnergy:12'" |
| 93 |
endproc |
| 94 |
printline Optimized: |
| 95 |
Debug... no 0 |
| 96 |
call do |
| 97 |
printline Portable: |
| 98 |
Debug... no 18 |
| 99 |
call do |
| 100 |
Debug... no 0 |
| 101 |
|
| 102 |
Read from file: "examples/あ あ.wav" |
| 103 |
Remove |
| 104 |
|
| 105 |
Read from file: "examples/にほん.flac" ; earlier version of FLAC did not support Unicode on Windows |
| 106 |
Remove |
| 107 |
|
| 108 |
printline OK |