Public Sub GenBB (DurationMs As Double, FreqLeft As Double, FreqRight As Double)
Dim Samples As Int = 4000 * 2 * DurationMs / 1000
Dim Tone(2 * Samples) As Byte
For i = 0 To Samples - 1 Step 2
Dim Sample1 As Double = Sin(1 * cPI * i / (4000 / FreqLeft))
Dim Left As Short = Sample1 * 32767
Dim Sample2 As Double = Sin(1 * cPI * i / (4000 / FreqRight))
Dim Right As Short = Sample2 * 32767
Tone(2 * i + 1) = Bit.UnsignedShiftRight(Bit.And(Left, 0xff00), 8)
Tone(2 * i + 3) = Bit.UnsignedShiftRight(Bit.And(Right, 0xff00), 8)
Next
Streamer1.Write(Tone)
End Sub