Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Streaming Audio from one PC to another over a Local Network 1

Status
Not open for further replies.

BriansBrain

Programmer
Oct 21, 2002
12
ES
Hello fellow VB'ers,

I did search before I posted this and could not find a solution to my problem.

As the title says I need to stream Audio one way from one PC to another.

[PC-1]------>------[Router]------>------[PC-2]

This code is a modified version of MS Voice Chat from the Visual Basic 5 CD.

The project contains WaveStream.dll as the WaveStream.cls ClassModule.

So the application does not require the actual DLL what so ever, and it's easier to make mods to the code.

These are the only formats I can get to work...
8000Hz. 8bit, Mono
11025Hz. 8bit, Mono
22050Hz. 8bit, Mono
8000Hz. 8bit, Stereo
11025Hz. 8bit, Stereo
8000Hz. 16bit, Mono
8000Hz. 16bit, Stereo << Works for a few seconds then... Run-time error - Type mismatch at ...
Call .SaveStreamBuffer(Index, ExData(Index)) in the WaveStream.cls ClassModule.

I have tried everything to get better quality but with no luck.

I am trying for 44100Hz, 16bit, Stereo which should Stream through the Router at about 200kbs.

Delay in the system is not a problem, as long it is constant.

Any help would be abosolutly fantastic.

Thanks in advance for even looking.

BB
 
Where do you find the Wavestream.cls. I only have VB6.

Type mismatches with streams can be caused by trying to pass a string when the receiver expects a byte.

A byte implies 8 bits so perhaps you have to somehow send a "long byte" instead of an "integer byte" (ie a 16 bit byte?)
 
Thanks to everyone for looking.

But I now have found a solution.
 
How about letting us know how you fixed it?
I had in mind to do this later on and could also find it helpful
 
Sorry tedsmith, here it is.

First in a Module...>>>>>
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal cbCopy As Long)

Then in the Winsock DataArrival...>>>>>
Private Sub TCPSocket_DataArrival(Index As Integer, ByVal BytesTotal As Long)
If OnOff = 0 Then Exit Sub
' Incomming Buffer On...
Dim rc As Long ' Return Code Variable
Dim WaveData() As Byte ' Byte array of wave data
Static ExBytes As Long ' Extra bytes in frame buffer
Static ExData() As Byte ' Extra bytes from frame buffer
With wStream
If (TCPSocket(Index).BytesReceived > 0) Then ' Validate that bytes where actually received
Do While (TCPSocket(Index).BytesReceived > 0) ' While data available...
If (ExBytes = 0) Then ' Was there leftover data from last time
If (.waveChunkSize <= TCPSocket(Index).BytesReceived) Then ' Can we get and entire wave buffer of data
Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize) ' Get 1 wave buffer of data
Call .SaveStreamBuffer(Index, WaveData) ' Save wave data to buffer
Call .AddStreamToQueue(Index) ' Queue current stream for playback
Else
ExBytes = TCPSocket(Index).BytesReceived ' Save Extra bytes
Call TCPSocket(Index).GetData(ExData, vbByte + vbArray, ExBytes) ' Get Extra data
End If
Else
Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize - ExBytes) ' Get leftover bits
ReDim Preserve ExData(ExBytes + UBound(WaveData))
CopyMemory ByVal VarPtr(ExData(ExBytes)), ByVal VarPtr(WaveData(0)), UBound(WaveData) + 1
Call .SaveStreamBuffer(Index, ExData) ' Save the current wave data to the wave buffer
Call .AddStreamToQueue(Index) ' Queue the current wave stream
ExBytes = 0 ' Clear Extra byte count
' Testing this >> ReDim ExData(0) ' Clear Extra data buffer
End If
Loop ' Look for next Data Chunk

If (Not .Playing And .PlayDeviceFree And _
Not .Recording And .RecDeviceFree) Then ' Check Audio Device Status
Call StartPlayBack ' Start PlayBack...
End If
End If
End With
End Sub

That was it, it's not perfect, I'm still testing it.
Regards......... BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top