[RESOLVED] Streaming Audio from one PC to another over a Local Network
Hello, I did search before I posted this and could not find a solution to my problem.
I want to stream Audio one way from one PC to another.
[PC-1]------>------[Router]------>------[PC-2]
This code I have included is a modified version of MS Voice Chat from the Visual Basic 6 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.
But I have included the original Microsoft source code for the DLL.
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.
Last edited by BriansBrain; October 14th, 2009 at 01:51 PM.
Reason: WizBang found the solution
Re: Streaming Audio from one PC to another over a Local Network
I don't think you can write an app in VB6 that does streaming. There's a Windows Server that streams, and you can also have a host stream a file for you (good for low bandwith uploads)
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by dglienna
I don't think you can write an app in VB6 that does streaming. There's a Windows Server that streams, and you can also have a host stream a file for you (good for low bandwith uploads)
Hello, thanks for replying,
I don't think you read all my post, I app will stream over the network, but I can't get it to stream at PCM 44100Hz, 16bit, Stereo.
Re: Streaming Audio from one PC to another over a Local Network
The first thing that comes to mind is that VB may not be quick enough. Sometimes it'll be noticeably faster once compiled, so try that if you haven't already.
The other thing I'd be looking at is the sound card. Cheesy cards might not work as well as good ones. Also, since it's only one way, that means you can take full advantage of the sound card, rather than duplexing. So if the code allows for two-way communication, it may be that half the bits are being reserved for the other direction. This might explain why the formats which work are 8 bit.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by WizBang
The first thing that comes to mind is that VB may not be quick enough. Sometimes it'll be noticeably faster once compiled, so try that if you haven't already.
The code for WaveStream.dll originaly was a microsoft code, but unsupported demo only.
I have tried with the compiled DLL as well as the WaveStream being included in the app as a ClassModule, same resulting error, where the error ocours is when the stream is getting bigger.
The original demo was only set at 8khz 8bit, I don't this microsoft tested there their code at a higher bit rate.
If you did not take a look at the code here is the offending snippet
Code:
'================== The TCPSocket is Winsock =============================
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(Index) = 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(Index) = TCPSocket(Index).BytesReceived ' Save Extra bytes
Call TCPSocket(Index).GetData(ExData(Index), vbByte + vbArray, ExBytes(Index)) ' Get Extra data
End If
Else
Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize - ExBytes(Index)) ' Get leftover bits
ExData(Index) = MidB(ExData(Index), 1) & MidB(WaveData, 1) ' Sync wave bits...
Call .SaveStreamBuffer(Index, ExData(Index)) ' Save the current wave data to the wave buffer Error occurs here
Call .AddStreamToQueue(Index) ' Queue the current wave stream
ExBytes(Index) = 0 ' Clear Extra byte count
ExData(Index) = "" ' 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 cmdTalk_Click ' Start PlayBack...
End If
End If
End With
'=================================================================
The error ocours at >> ' Save the current wave data to the wave buffer
Someone suggested...>>>
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?)
But I am not in that sort of VB level.
Originally Posted by WizBang
The other thing I'd be looking at is the sound card. Cheesy cards might not work as well as good ones. Also, since it's only one way, that means you can take full advantage of the sound card, rather than duplexing. So if the code allows for two-way communication, it may be that half the bits are being reserved for the other direction. This might explain why the formats which work are 8 bit.
It's nothing to do with the card, as the card cannot create an error 13 within the project.
Also I have had 8000Hz. 16bit, Mono working so it will work with 16bit.
Thanks for looking.
Last edited by WizBang; October 6th, 2009 at 02:59 PM.
Reason: Added [code] tags
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by dglienna
Is this over your own network, or from one pc across the Internet?
I'm sorry I should have made it clear.
I want to stream Audio one way from one PC to another, the PCs are on the same LAN connected to the same router, there are on the same table next to each other, in the same room.
Re: Streaming Audio from one PC to another over a Local Network
Scanning over the code you posted, it appears it is playing as well as sending, no? See the last few lines of the code.
I should have mentioned in my previous post, that not all sound cards are full-duplex. This means that although they can handle 16 bit sound, they cannot do 16 bits in both directions simultaneously. In such a case, 8 bits are used for each direction.
Since one 16 bit mode worked only momentarily, I wonder if it was until playback was supposed to start. With a half-duplex card, it won't be able to maintain the 16 bit outgoing stream. This may or may not be a factor in the error you're getting, but I wouldn't rule it out without verifying.
As to why the error is a type mismatch, I'm not sure. But if you didn't change the type, then it seems the bottleneck is elsewhere.
Incidentally, which end gives the error; send or receive? I'm guessing send?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by WizBang
Scanning over the code you posted, it appears it is playing as well as sending, no? See the last few lines of the code.
I should have mentioned in my previous post, that not all sound cards are full-duplex. This means that although they can handle 16 bit sound, they cannot do 16 bits in both directions simultaneously. In such a case, 8 bits are used for each direction.
As I mentiond in my first post...
I want to stream Audio one way from one PC to another.
[PC-1]------>------[Router]------>------[PC-2]
One way from a Server >>> to a single Client, both the PCs are connected to the same router, in fact both the PCs are in the same room.
The original Microsoft code was both ways, send and recieve, but I only require One Way.
Originally Posted by WizBang
As to why the error is a type mismatch, I'm not sure. But if you didn't change the type, then it seems the bottleneck is elsewhere.
Incidentally, which end gives the error; send or receive? I'm guessing send?
Sorry I did not mention, the error is at the receive end, when the Winsock recieves Data.
There are two Calls to SaveStreamBuffer in the same Sub, the first one works, the second gives the error.
Someone commented on the problem...
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?)
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.