Mercurial > games > semicongine
diff tests/test_audio.nim @ 1282:3308b88e53a6
did: undo part of stupid API renaming a few weeks back ;(
author | sam <sam@basx.dev> |
---|---|
date | Mon, 29 Jul 2024 16:05:09 +0700 |
parents | 4cf9872f7bb6 |
children | e0326aa067c8 |
line wrap: on
line diff
--- a/tests/test_audio.nim Mon Jul 29 15:53:03 2024 +0700 +++ b/tests/test_audio.nim Mon Jul 29 16:05:09 2024 +0700 @@ -6,42 +6,42 @@ proc test1() = - mixer[].AddSound("test1", SineSoundData(1000, 2, 44100)) - mixer[].AddSound("test2", SineSoundData(500, 2, 44100)) + mixer[].addSound("test1", sineSoundData(1000, 2, 44100)) + mixer[].addSound("test2", sineSoundData(500, 2, 44100)) - let s1 = mixer[].Play("test1", loop = true) - let s2 = mixer[].Play("test2", loop = true) + let s1 = mixer[].play("test1", loop = true) + let s2 = mixer[].play("test2", loop = true) let t0 = now() - mixer[].SetLevel(0.5) + mixer[].setLevel(0.5) while true: let runtime = (now() - t0).inMilliseconds() if runtime > 1500: - mixer[].SetLevel(0.2) + mixer[].setLevel(0.2) if runtime > 3000: - mixer[].Stop(s2) + mixer[].stop(s2) if runtime > 6000: - mixer[].Stop("") + mixer[].stop("") if runtime > 8000: break proc test2() = let # notes - c = SineSoundData(261.6256, 0.5, 44100) - d = SineSoundData(293.6648, 0.5, 44100) - e = SineSoundData(329.6276, 0.5, 44100) - f = SineSoundData(349.2282, 0.5, 44100) - g = SineSoundData(391.9954, 0.5, 44100) - a = SineSoundData(440.0000, 0.5, 44100) - b = SineSoundData(493.8833, 0.5, 44100) - bb = SineSoundData(466.1638, 0.5, 44100) - c2 = SineSoundData(523.2511, 0.5, 44100) - d2 = SineSoundData(587.3295, 0.5, 44100) - bbShort = SineSoundData(466.1638, 0.25, 44100) - c2Short = SineSoundData(523.2511, 0.25, 44100) - d2Short = SineSoundData(587.3295, 0.25, 44100) + c = sineSoundData(261.6256, 0.5, 44100) + d = sineSoundData(293.6648, 0.5, 44100) + e = sineSoundData(329.6276, 0.5, 44100) + f = sineSoundData(349.2282, 0.5, 44100) + g = sineSoundData(391.9954, 0.5, 44100) + a = sineSoundData(440.0000, 0.5, 44100) + b = sineSoundData(493.8833, 0.5, 44100) + bb = sineSoundData(466.1638, 0.5, 44100) + c2 = sineSoundData(523.2511, 0.5, 44100) + d2 = sineSoundData(587.3295, 0.5, 44100) + bbShort = sineSoundData(466.1638, 0.25, 44100) + c2Short = sineSoundData(523.2511, 0.25, 44100) + d2Short = sineSoundData(587.3295, 0.25, 44100) # song frerejaquesData = concat( @@ -55,33 +55,33 @@ f, c, f, f, ) - mixer[].AddSound("frerejaques", frerejaquesData) - discard mixer[].Play("frerejaques") + mixer[].addSound("frerejaques", frerejaquesData) + discard mixer[].play("frerejaques") - while mixer[].IsPlaying(): + while mixer[].isPlaying(): sleep(1) proc test3() = - mixer[].AddSound("toccata et fugue", LoadAudio("toccata_et_fugue.ogg")) - mixer[].AddSound("ping", SineSoundData(500, 0.05, 44100)) - mixer[].AddTrack("effects") - discard mixer[].Play("toccata et fugue") + mixer[].addSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg")) + mixer[].addSound("ping", sineSoundData(500, 0.05, 44100)) + mixer[].addTrack("effects") + discard mixer[].play("toccata et fugue") when isMainModule: test1() - mixer[].Stop() + mixer[].stop() test2() - mixer[].Stop() + mixer[].stop() test3() - while mixer[].IsPlaying(): - discard mixer[].Play("ping", track = "effects", stopOtherSounds = true, level = 0.5) + while mixer[].isPlaying(): + discard mixer[].play("ping", track = "effects", stopOtherSounds = true, level = 0.5) # on windows we re-open stdin and this will not work when defined(linux): echo "Press q and enter to exit" if stdin.readLine() == "q": - mixer[].Stop() + mixer[].stop() elif defined(windows): sleep(5) - mixer[].Stop() + mixer[].stop()