Mercurial > games > semicongine
comparison tests/test_audio.nim @ 264:dc2304a1bc0a
did: change audio-test to use ogg/vorbis
| author | Sam <sam@basx.dev> |
|---|---|
| date | Sat, 27 May 2023 13:44:42 +0700 |
| parents | 972caf83930d |
| children | b145a05c2459 |
comparison
equal
deleted
inserted
replaced
| 263:d1ee2a815fa1 | 264:dc2304a1bc0a |
|---|---|
| 59 | 59 |
| 60 while mixer[].isPlaying(): | 60 while mixer[].isPlaying(): |
| 61 sleep(1) | 61 sleep(1) |
| 62 | 62 |
| 63 proc test3() = | 63 proc test3() = |
| 64 var song: SoundData | 64 mixer[].addSound("pianosong", loadAudio("test.ogg")) |
| 65 var f = open("./tests/audiotest.PCM.s16le.48000.2") | |
| 66 var readLen = 999 | |
| 67 while readLen > 0: | |
| 68 var sample: Sample | |
| 69 readLen = f.readBuffer(addr sample, sizeof(Sample)) | |
| 70 song.add sample | |
| 71 | |
| 72 mixer[].addSound("pianosong", newSound(song)) | |
| 73 mixer[].addSound("ping", newSound(sineSoundData(500, 0.05, 44100))) | 65 mixer[].addSound("ping", newSound(sineSoundData(500, 0.05, 44100))) |
| 74 mixer[].addTrack("effects") | 66 mixer[].addTrack("effects") |
| 75 discard mixer[].play("pianosong") | 67 discard mixer[].play("pianosong") |
| 76 | 68 |
| 77 let t0 = now() | |
| 78 while mixer[].isPlaying(): | 69 while mixer[].isPlaying(): |
| 79 discard mixer[].play("ping", track="effects", stopOtherSounds=true, level=0.5) | 70 discard mixer[].play("ping", track="effects", stopOtherSounds=true, level=0.5) |
| 80 var input = stdin.readLine() | 71 discard stdin.readLine() |
| 81 | 72 |
| 82 when isMainModule: | 73 when isMainModule: |
| 83 startMixerThread() | 74 startMixerThread() |
| 84 test1() | 75 test1() |
| 85 mixer[].stop() | 76 mixer[].stop() |
| 86 test2() | 77 test2() |
| 87 mixer[].stop() | 78 mixer[].stop() |
| 79 test3() | |
| 80 mixer[].stop() |
