[RESOLVED] Streaming Audio from one PC to another over a Local Network

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Streaming Audio from one PC to another over a Local Network

OK, ExData is a Variant, not a Byte array. That would seem to explain why the error is a type mismatch. I think m$ goofed up there. It's being used as a string however, so it would have made more sense to declare it as a string.

And declaring it as Byte didn't work because it still wasn't an array being passed, only one byte.

Two things come to mind which might work. One is to create a UDT for ExData, and the other is to use StrConv() to convert the string data into a Byte array. StrConv() would be the easier one to try, though slower.

I tried that and the error stops with 8000Hz, 16bit, Stereo
Before it used to work for a few seconds then error - Type Mismatch
And the code did get to the new Call .SaveStreamBuffer........ but just once.

I then tried 11025Hz, 16bit, Stereo
Sound output from the Client for just a second, then stops, but it's still streaming, being recieved at 50kbs from the router, No error but No sound.

But if I turn the Server OFF, the Client starts putting sound out for a few seconds, then goes into crackles.

Re: Streaming Audio from one PC to another over a Local Network

Since the second parameter being passed to MidB() is a 1, it doesn't even look like it would do anything at all. The entire string should be returned, so my only guess is that they did it because they declared ExData as a Variant. However, since WaveData is a byte array, it would appear that only one byte would be returned. I'm not so sure that's what should happen.

Try it this way:

Code:

ExData(Index) = ExData(Index) & StrConv(WaveData, vbUnicode)

This is not very efficient, and of course, it only has to be converted back to a byte array anyway. But if it works, then we can revamp the code to use byte arrays, and probably CopyMemory to put all the bytes together.

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

What is the value of the Index variable used in "ExData(Index)"? Does it change while the streaming is going on? Try putting Debug.Print Index on a line above the second call to SaveStreamBuffer, and see what it's doing. Obviously, you'll have to be running it in the IDE for debug to work.

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

What is the value of the Index variable used in "ExData(Index)"? Does it change while the streaming is going on? Try putting Debug.Print Index on a line above the second call to SaveStreamBuffer, and see what it's doing. Obviously, you'll have to be running it in the IDE for debug to work.

The Value is 1, and it does not change.

Just as a matter of testing, I tried just before the first Call to SaveStreamBuffer.
Same = 1 and it does not change when it's streaming either at the low qualities or higher.

Re: Streaming Audio from one PC to another over a Local Network

OK, so it sounds as if there is always just one element of the ExData array, which seems to suggest, by the rest of the code you've posted, that there is only one winsock being used. I'd guess it's because you're only streaming one way.

So you might be able to simplify things a bit there. What I'd suggest, is to make ExData a byte array like WaveData, and Redim Preserve it to also hold the WaveData, then CopyMemory can be use to fill in those bytes with the WaveData. Or a separate array could be used. Either way, this will avoid the use of StrConv(), and therefore may have a better chance of working.

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

OK, so it sounds as if there is always just one element of the ExData array, which seems to suggest, by the rest of the code you've posted, that there is only one winsock being used. I'd guess it's because you're only streaming one way.

There is one Winsock in ithe server, and one Winsock in the Client.

Originally Posted by WizBang

So you might be able to simplify things a bit there. What I'd suggest, is to make ExData a byte array like WaveData, and Redim Preserve it to also hold the WaveData, then CopyMemory can be use to fill in those bytes with the WaveData. Or a separate array could be used. Either way, this will avoid the use of StrConv(), and therefore may have a better chance of working.

Could you give me some Code examples/changes like before, as this is a little above me.

Re: Streaming Audio from one PC to another over a Local Network

Great! So glad to know it worked!

As for your memory question, there doesn't appear to be any potential problems related to the changes I made. But it's always good to keep an eye on the resource usage as it runs. If there's a memory leak, it will eventually show up.

I don't know how to thank you, I can stop pulling my hair out now.

You can use the "Rate this post" link for any post in any thread which you want to rate. You can also rate a thread itself, using the Rate Thread pull-down at the top of the thread. Lastly, when your own question has been resolved, use the Thread Tools pull-down to mark the thread resolved (or the related option when replying).

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

You can use the "Rate this post" link for any post in any thread which you want to rate. You can also rate a thread itself, using the Rate Thread pull-down at the top of the thread. Lastly, when your own question has been resolved, use the Thread Tools pull-down to mark the thread resolved (or the related option when replying).