I'm just starting to learn directaudio, and want to start off not with
playing a WAV, thats all too easy, I want to generate the waveform, so
to start off I'm trying to generate white noise, using the code below,
but its erroring with a "Index out of range" Exception on the line of
code inditcated:
Private DSdev As New Device
Private DSbuffer As SecondaryBuffer
Private IOstream As System.IO.Memor yStream
Now some code to make it happen:
DSdev.SetCooper ativeLevel(Me.H andle, CooperativeLeve l.Normal)
IOstream = New System.IO.Memor yStream(22000)
Dim x As Integer
For x = 1 To 20000
IOstream.WriteB yte(Int(Rnd() * 254))
Next
DSbuffer = New SecondaryBuffer (IOstream, DSdev) '<<<< ERROR
If Not DSbuffer Is Nothing Then DSbuffer.Play(0 ,
BufferPlayFlags .Default)
----------------------
Is this the right way to go about generating white noise?
Thanks in advance,
Scott
playing a WAV, thats all too easy, I want to generate the waveform, so
to start off I'm trying to generate white noise, using the code below,
but its erroring with a "Index out of range" Exception on the line of
code inditcated:
Private DSdev As New Device
Private DSbuffer As SecondaryBuffer
Private IOstream As System.IO.Memor yStream
Now some code to make it happen:
DSdev.SetCooper ativeLevel(Me.H andle, CooperativeLeve l.Normal)
IOstream = New System.IO.Memor yStream(22000)
Dim x As Integer
For x = 1 To 20000
IOstream.WriteB yte(Int(Rnd() * 254))
Next
DSbuffer = New SecondaryBuffer (IOstream, DSdev) '<<<< ERROR
If Not DSbuffer Is Nothing Then DSbuffer.Play(0 ,
BufferPlayFlags .Default)
----------------------
Is this the right way to go about generating white noise?
Thanks in advance,
Scott
Comment