comparison tests/test_audio.nim @ 1137:a4aa9f374d44

did: more renaming
author sam <sam@basx.dev>
date Tue, 04 Jun 2024 20:51:22 +0700
parents 74957cbf589b
children 114f395b9144
comparison
equal deleted inserted replaced
1136:71315636ba82 1137:a4aa9f374d44
4 4
5 import semicongine 5 import semicongine
6 6
7 7
8 proc test1() = 8 proc test1() =
9 mixer[].AddSound("test1", newSound(sineSoundData(1000, 2, 44100))) 9 mixer[].AddSound("test1", NewSound(SineSoundData(1000, 2, 44100)))
10 mixer[].AddSound("test2", newSound(sineSoundData(500, 2, 44100))) 10 mixer[].AddSound("test2", NewSound(SineSoundData(500, 2, 44100)))
11 11
12 12
13 let s1 = mixer[].Play("test1", loop = true) 13 let s1 = mixer[].Play("test1", loop = true)
14 let s2 = mixer[].Play("test2", loop = true) 14 let s2 = mixer[].Play("test2", loop = true)
15 15
27 break 27 break
28 28
29 proc test2() = 29 proc test2() =
30 let 30 let
31 # notes 31 # notes
32 c = sineSoundData(261.6256, 0.5, 44100) 32 c = SineSoundData(261.6256, 0.5, 44100)
33 d = sineSoundData(293.6648, 0.5, 44100) 33 d = SineSoundData(293.6648, 0.5, 44100)
34 e = sineSoundData(329.6276, 0.5, 44100) 34 e = SineSoundData(329.6276, 0.5, 44100)
35 f = sineSoundData(349.2282, 0.5, 44100) 35 f = SineSoundData(349.2282, 0.5, 44100)
36 g = sineSoundData(391.9954, 0.5, 44100) 36 g = SineSoundData(391.9954, 0.5, 44100)
37 a = sineSoundData(440.0000, 0.5, 44100) 37 a = SineSoundData(440.0000, 0.5, 44100)
38 b = sineSoundData(493.8833, 0.5, 44100) 38 b = SineSoundData(493.8833, 0.5, 44100)
39 bb = sineSoundData(466.1638, 0.5, 44100) 39 bb = SineSoundData(466.1638, 0.5, 44100)
40 c2 = sineSoundData(523.2511, 0.5, 44100) 40 c2 = SineSoundData(523.2511, 0.5, 44100)
41 d2 = sineSoundData(587.3295, 0.5, 44100) 41 d2 = SineSoundData(587.3295, 0.5, 44100)
42 bbShort = sineSoundData(466.1638, 0.25, 44100) 42 bbShort = SineSoundData(466.1638, 0.25, 44100)
43 c2Short = sineSoundData(523.2511, 0.25, 44100) 43 c2Short = SineSoundData(523.2511, 0.25, 44100)
44 d2Short = sineSoundData(587.3295, 0.25, 44100) 44 d2Short = SineSoundData(587.3295, 0.25, 44100)
45 45
46 # song 46 # song
47 frerejaquesData = concat( 47 frerejaquesData = concat(
48 f, g, a, f, 48 f, g, a, f,
49 f, g, a, f, 49 f, g, a, f,
53 c2Short, d2Short, c2Short, bbShort, a, f, 53 c2Short, d2Short, c2Short, bbShort, a, f,
54 f, c, f, f, 54 f, c, f, f,
55 f, c, f, f, 55 f, c, f, f,
56 ) 56 )
57 57
58 mixer[].AddSound("frerejaques", newSound(frerejaquesData)) 58 mixer[].AddSound("frerejaques", NewSound(frerejaquesData))
59 discard mixer[].Play("frerejaques") 59 discard mixer[].Play("frerejaques")
60 60
61 while mixer[].IsPlaying(): 61 while mixer[].IsPlaying():
62 sleep(1) 62 sleep(1)
63 63
64 proc test3() = 64 proc test3() =
65 mixer[].AddSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg")) 65 mixer[].AddSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg"))
66 mixer[].AddSound("ping", newSound(sineSoundData(500, 0.05, 44100))) 66 mixer[].AddSound("ping", NewSound(SineSoundData(500, 0.05, 44100)))
67 mixer[].AddTrack("effects") 67 mixer[].AddTrack("effects")
68 discard mixer[].Play("toccata et fugue") 68 discard mixer[].Play("toccata et fugue")
69 69
70 70
71 when isMainModule: 71 when isMainModule: