-
October 11th, 2009, 03:42 PM
#31
Re: Streaming Audio from one PC to another over a Local Network
And Yes I have tried...
Static ExData(MAXTCP) As Byte
The Same Error.
-
October 12th, 2009, 07:31 AM
#32
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.
Try the following
Declare this with the other variables:
Code:
Dim ExtraBytes() As Byte
Put this in the routine in place of the line that raises the error:
Code:
ExtraBytes = StrConv(ExData(Index), vbFromUnicode)
Call .SaveStreamBuffer(Index, ExtraBytes) ' Save the current wave data to the wave buffer
You might also change ExData to a String, but try it as is first.
Last edited by WizBang; October 12th, 2009 at 07:35 AM.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
October 12th, 2009, 11:17 AM
#33
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by WizBang
Try the following
Declare this with the other variables:
Code:
Dim ExtraBytes() As Byte
Put this in the routine in place of the line that raises the error:
Code:
ExtraBytes = StrConv(ExData(Index), vbFromUnicode)
Call .SaveStreamBuffer(Index, ExtraBytes) ' Save the current wave data to the wave buffer
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.
I also change ExData to a String = Same result.
So looks like we are getting somewhere.
Thanks again for looking.
-
October 12th, 2009, 02:12 PM
#34
Re: Streaming Audio from one PC to another over a Local Network
I'm wondering about this line:
Code:
ExData(Index) = MidB(ExData(Index), 1) & MidB(WaveData, 1) ' Sync wave bits...
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?
-
October 13th, 2009, 06:48 AM
#35
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by WizBang
I'm wondering about this line:
Code:
ExData(Index) = MidB(ExData(Index), 1) & MidB(WaveData, 1) ' Sync wave bits...
Try it this way:
Code:
ExData(Index) = ExData(Index) & StrConv(WaveData, vbUnicode)
This is all well above my skills in VB, but that is why I came to the Guru's here in the first place.
I tried that including the other mods in the code you gave me at 11025Hz, 16bit, Stereo.
Roughly the same as last time, streaming starts, sound output in the Client starts, then stops, but still streaming 50kbs through the router.
Again when I turn the Server off, the Client sounds like it tries to play the back log of sound, then it ends in crackles.
But the lower quality streaming sound is the same as before, unaffected, .
Thanks for looking.
-
October 13th, 2009, 08:13 AM
#36
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?
-
October 13th, 2009, 08:39 AM
#37
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.
Thanks again.
-
October 13th, 2009, 04:16 PM
#38
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?
-
October 14th, 2009, 05:04 AM
#39
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.
Thanks again WizBang.
-
October 14th, 2009, 11:24 AM
#40
Re: Streaming Audio from one PC to another over a Local Network
Something like the following should work, hopefully. I only included the lines effected by the changes, so if ExData or ExBytes are referenced elsewhere, you'll need to address those too.
Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal cbCopy As Long)
Code:
Static ExBytes As Long ' Extra bytes in frame buffer
Static ExData() As Byte ' Extra bytes from frame buffer
Code:
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
'ReDim ExData(0) ' Clear Extra data buffer
End If
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
October 14th, 2009, 12:35 PM
#41
Re: Streaming Audio from one PC to another over a Local Network
Originally Posted by WizBang
Something like the following should work, hopefully. I only included the lines effected by the changes, so if ExData or ExBytes are referenced elsewhere, you'll need to address those too.
I searched and ExData or ExBytes are NOT referenced elsewhere.
I put your code in, and the tests are as follows.
11025Hz, 16bit, Stereo = Now Working unbroken steady stream at +/- 45kbs
22050Hz, 16bit, Stereo = Now Working unbroken steady stream at +/- 90kbs
44100Hz, 16bit, Stereo = Now Working unbroken steady stream at +/- 180kbs
Absolutely Fantastic, WizBang you are a true Guru.
I don't know how to thank you, I can stop pulling my hair out now.
It all seams stable up to now, would there be anything to look out for memory problem wise ?
-
October 14th, 2009, 01:36 PM
#42
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?
-
October 14th, 2009, 01:53 PM
#43
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).
Done, Done & Done.
Thanks again mate, much appreciated.
-
June 20th, 2014, 02:59 PM
#44
Re: [RESOLVED] Streaming Audio from one PC to another over a Local Network
very thnx to your post ,...BriansBrain
and i need your modefied version of this project
-
June 20th, 2014, 04:03 PM
#45
Re: [RESOLVED] Streaming Audio from one PC to another over a Local Network
sorry i didnot read the solution...
now i done the solution and the fantastic project is work at stereo mode but my log is:
stereo - 8bit - 22.05 khz IS 44.3 kb/s........ really its wonderfull
but now i have problem...
i use this program via week WIFI Signal and when the signal <= 5% the program disconnected and i have to close the Server And The Client and run them again...
i want solve by ((Auto Reconnect))...
can any one help me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|