This is very easily done because you simply display the wave data "as is".
The only problem is that you have to write separate code for 8 and 16 bit sound formats, and also for mono and stereo.
In the following code, you will see 3 functions:
DisplayWaveData8 is for displaying 8 bit data, stereo and mono.
DisplayWaveData16_8 is for displaying 16 bit data, but the data is recorded in byte arrays (instead of integer arrays), therefore, the function simply copies the array to an integer array.
DisplayWaveData16 is for displaying 16 bit data, stereo and mono.
VB Code:
Private Sub DisplayWaveData8(DataBuff() As Byte, Pic As PictureBox, Stereo As Boolean)
Dim Stp As Single, HBuffer As Long, Q As Single
Dim LX As Single, LY As Single, RX As Single, RY As Single
Dim LVal As Single, RVal As Single, K As Long
If Not Stereo Then
HBuffer = UBound(DataBuff)
Stp = HBuffer / (Pic.Width / 15)
Pic.Scale (0, 127)-(HBuffer, -127)
Pic.PSet (0, 0)
Pic.Cls
For Q = 0 To HBuffer - 2 Step Stp
Pic.Line -(Fix(Q), DataBuff(Fix(Q)) - 127)
Next Q
Else
HBuffer = UBound(DataBuff) \ 2
Stp = HBuffer / (Pic.Width / 15)
Pic.Scale (0, 256)-(HBuffer, -256)
Pic.PSet (0, 0)
Pic.Cls
LX = 0
LY = -127
RX = 0
RY = 127
For Q = 0 To HBuffer - 2 Step Stp
K = Q
K = K - (K Mod 2)
LVal = DataBuff(K + 1) - 255
RVal = DataBuff(K)
Pic.Line (LX, LY)-(K, LVal)
Pic.Line (RX, RY)-(K, RVal)
LX = K
LY = LVal
RX = K
RY = RVal
Next Q
End If
End Sub
' the sound is 16 bit, but it comes in Bytes, not Integer
Private Sub DisplayWaveData16_8(DataBuff() As Byte, Pic As PictureBox, Stereo As Boolean)