CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 4 1234 LastLast
Results 1 to 15 of 54
  1. #1
    Join Date
    Oct 2009
    Posts
    34

    Resolved [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.
    Attached Files Attached Files
    Last edited by BriansBrain; October 14th, 2009 at 01:51 PM. Reason: WizBang found the solution

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by dglienna View Post
    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.

    BB

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

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

    Depends on your ISP. What's you UPLOAD speed? www.speedtest.net will tell you. that could be an issue. two routers and ports could be an issue.

    if you mean two pc's in your own network, then that could be slow machine, network traffic, etc.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by dglienna View Post
    Depends on your ISP. What's you UPLOAD speed? www.speedtest.net will tell you. that could be an issue. two routers and ports could be an issue.

    if you mean two pc's in your own network, then that could be slow machine, network traffic, etc.
    Thanks for the reply,

    If you look at my first post again, I'm streaming one pc to the other, they are physically next to each other on the same router.

    I know it is NOT a router speed problem.

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    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?

  7. #7
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by WizBang View Post
    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.


    Quote Originally Posted by WizBang View Post
    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

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

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

    Is this over your own network, or from one pc across the Internet?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by dglienna View Post
    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.

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

    Thanks for looking.

  10. #10
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

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

    Use Windows 7 (or even Vista). Media Center lets you stream to another device
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  11. #11
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by dglienna View Post
    Use Windows 7 (or even Vista). Media Center lets you stream to another device
    The programs I am wanting to use with this steaming system will NOT work on 7 or Vista.

    But thanks for the reply.

  12. #12
    Join Date
    Dec 2001
    Posts
    6,332

    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?

  13. #13
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

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

    Quote Originally Posted by BriansBrain View Post
    The programs I am wanting to use with this steaming system will NOT work on 7 or Vista.

    But thanks for the reply.
    Well, you wouldn't need a program. You can stream to any compatible device (even Xbox)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  14. #14
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by dglienna View Post
    Well, you wouldn't need a program. You can stream to any compatible device (even Xbox)
    Sorry I should have been clearer, the program I want to receive the sound on the Client will NOT work on Vista or 7

    Thanks for looking.

  15. #15
    Join Date
    Oct 2009
    Posts
    34

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

    Quote Originally Posted by WizBang View Post
    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.


    Quote Originally Posted by WizBang View Post
    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?)
    But I can't get my head around it.

    Thanks for looking.

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured