SuperStrict Graphics 1024,768,0,0 Global Quit:Int = False Global sample:TAudioSample = TAudioSample.Create(100000, 22050, SF_STEREO16BE) Global sampleData:Byte[100000] Print sample.length Function getSampleLength:Float(sample:TAudioSample) Return Float( (sample.length / Float( (sample.hertz * 60) ) ) * 60) End Function Function drawWave(sample:TAudioSample) Local x:Int, y:Int Local xscale:Double = sample.length/GraphicsWidth() For x = 0 Until sample.length Step 2 y = sample.samples[x] If (y > 0) Then SetColor(255,y,y) DrawLine((x/xscale)-1, sample.samples[x-1], x/xscale, y) 'DrawLine((x/xscale)-1, Abs(sample.samples[x-1]-255)+255, x/xscale, Abs(y-255)+255) End If Next End Function For Local m:Int = 0 Until 100000 sample.samples[m] = Sin(m)*100 Next Local sound:TSound = LoadSound(sample) Local channel:TChannel = PlaySound(sound) While Not Quit Cls drawWave(sample) Flip If KeyDown(KEY_ESCAPE) Then quit = True Wend End
My first attempt at sound synthesis...