[RESOLVED] Streaming Audio from one PC to another over a Local Network - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 54

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

  1. #16
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,986

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

    Try sleep 5000 (for 5 seconds sleep) might need time to save the file

    Code:
                  Call .SaveStreamBuffer(Index, ExData(Index)) ' Save the current wave data to the wave buffer Error occurs here
     
      SLEEP 5000 ' 5 Second delay?
                   Call .AddStreamToQueue(Index)           ' Queue the current wave stream
    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!

  2. #17
    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
    Try sleep 5000 (for 5 seconds sleep) might need time to save the file

    Code:
                  Call .SaveStreamBuffer(Index, ExData(Index)) ' Save the current wave data to the wave buffer Error occurs here
     
      SLEEP 5000 ' 5 Second delay?
                   Call .AddStreamToQueue(Index)           ' Queue the current wave stream
    I can't have Sleep for 5 seconds in between every chunk of streaming audio.

    But thanks for looking.

  3. #18
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,986

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

    Well, try it first, to see if that solves the problem. Even 20ms is good for the timer
    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!

  4. #19
    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, try it first, to see if that solves the problem. Even 20ms is good for the timer
    OK I will, I think I tried a DoEvents there as well before as a test and that had little efect.

    Thanks for looking.

  5. #20
    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, try it first, to see if that solves the problem. Even 20ms is good for the timer
    I tried from 20ms >to> 5000ms in three different places in that sub.

    It it did do something but the error 13 is still there at the same point.

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

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

    Quote Originally Posted by BriansBrain View Post
    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.
    Yes, I understand that you only need one way, but have you edited the code so that it no longer attempts both ways?
    Sorry I should have been clearer, the program I want to receive the sound on the Client will NOT work on Vista or 7
    ...
    Sorry I did not mention, the error is at the receive end, when the Winsock recieves Data.
    Now I'm confused. The first quote sounds like the program you are using to receive is not the one we're discussing. The second quote does sound like you're using the program we're discussing. Can you please clarify which is it?
    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.
    I doubt this has anything to do with the error, unless the changes you've made include a change in the data type being passed.
    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. #22
    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
    I understand that you only need one way, but have you edited the code so that it no longer attempts both ways?
    Of course, it only Streams one way.

    Quote Originally Posted by WizBang View Post
    Now I'm confused. The first quote sounds like the program you are using to receive is not the one we're discussing.
    I am using the program we are discussing to recieve the sound stream on PC-2.
    The reason I said...
    Sorry I should have been clearer, the program I want to receive the sound on the Client will NOT work on Vista or 7
    It should have been >> The program I want to pass the sound too after it has been recieved by my program on PC-2 will not work on Vista or 7

    Quote Originally Posted by WizBang View Post
    I doubt this has anything to do with the error, unless the changes you've made include a change in the data type being passed.
    The only Changes I have made is to take out the not required code for Chat.
    In The TCPSocket (Winsock) Sub where the error acours this is original Microsoft code, it has NOT been modified.
    The original code was used for the demo of Chat at 8kHz, 8bit Mono.
    At that setting the code in the TCPSocket (Winsock) Sub the code only gets to the first Call to SaveStreamBuffer.

    When I set the Server to Stream at 44khz, 16bit, Stereo, Winsock recieves more Data and the code gets to the Second Call to SaveStreamBuffer, this is where the error happens.

    When Microsoft wrote the code I don't think they even tried it at a higher setting than 8kHz, 8bit Mono, but they wrote the code for the Winsock to recieve more data, but they did not test or debug it, this is what I think.

    Thanks for looking.

  8. #23
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,986

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

    [ playing music from Windows 7 on XP Media Center computer right now...]

    Being STREAMED directly from Windows 7 over my WIFI.

    I don't get it. You can send low quality, and it works fine. You can't send high quality, and you think it's MS and their API's? What do you think I'm using on the XP box? Media Player 11.

    If you do get it to work, you'll find that there is latency between the signals. Unless you are seeking a delay, then I don't think you'll be happy.
    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. #24
    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
    [ playing music from Windows 7 on XP Media Center computer right now...]

    Being STREAMED directly from Windows 7 over my WIFI.
    I know it can be done in Vista or 7, but I want to do it in XP/2000

    Quote Originally Posted by dglienna View Post
    I don't get it. You can send low quality, and it works fine. You can't send high quality, and you think it's MS and their API's?
    The Microsoft code as mentioned above was written in 1996/7, and was available as source code, it was not supported, it was for demo only, I asume Microsoft has found the error in the above Microsoft code by now.
    > > > > > > I/we on the other hand have NOT yet.

    Quote Originally Posted by dglienna View Post
    If you do get it to work, you'll find that there is latency between the signals.
    I did mention in one of my replies, latency is not a problem, as long as it's roughly constant, which it should be.

    Thanks for looking.

  10. #25
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,986

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

    If it wasn't supported THEN, why would they have fixed that? This was updated after that.

    Code:
    Option Explicit
    
    Private Const SND_APPLICATION = &H80         ' look for application specific association
    Private Const SND_ALIAS = &H10000     ' name is a WIN.INI [sounds] entry
    Private Const SND_ALIAS_ID = &H110000    ' name is a WIN.INI [sounds] entry identifier
    Private Const SND_ASYNC = &H1         ' play asynchronously
    Private Const SND_FILENAME = &H20000     ' name is a file name
    Private Const SND_LOOP = &H8         ' loop the sound until next sndPlaySound
    Private Const SND_MEMORY = &H4         ' lpszSoundName points to a memory file
    Private Const SND_NODEFAULT = &H2         ' silence not default, if sound not found
    Private Const SND_NOSTOP = &H10        ' don't stop any currently playing sound
    Private Const SND_NOWAIT = &H2000      ' don't wait if the driver is busy
    Private Const SND_PURGE = &H40               ' purge non-static events for task
    Private Const SND_RESOURCE = &H40004     ' name is a resource name or atom
    Private Const SND_SYNC = &H0         ' play synchronously (default)
    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    Dim flag As Boolean
    
    Private Sub Command1_Click()
    If Not flag Then
      Command1.Caption = "Stop"
      PlaySound SoundFile(0), ByVal 0&, SND_ASYNC Or SND_LOOP
    Else
      Command1.Caption = "Play"
      PlaySound SoundFile(0), ByVal 0&, SND_MEMORY
    End If
    flag = Not flag
    End Sub
    
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        Call LoadSounds
        Command1.Caption = "Play"
    End Sub
    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. #26
    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
    If it wasn't supported THEN, why would they have fixed that? This was updated after that.
    According to the person who copied the original code from the 1997 VB6 installation CD, he said that the documentation with the Microsoft Chat Demo stated that it was not supported by Microsoft.

    That is all I know!

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

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

    I wonder if it would help debug this thing to use the CSocket or CSocketPlus class. It provides all the functionality of winsock. But since you can use the class module in your program, rather than having a separate DLL, maybe you can step through the error. There is at least one VB preference setting pertaining to breaking, so check that too.
    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. #28
    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
    I wonder if it would help debug this thing to use the CSocket or CSocketPlus class. It provides all the functionality of winsock. But since you can use the class module in your program, rather than having a separate DLL, maybe you can step through the error. There is at least one VB preference setting pertaining to breaking, so check that too.
    But if you have a look at the sub where the error occurs, it's in the code, it's not a winsock error.
    In that sub there are two Calls to the ClassModule >>> WaveStream.cls

    It happens every time the code gets to the second >>> Call .SaveStreamBuffer
    The error is Type Mismatch so...
    If the First >>> Call .SaveStreamBuffer does NOT error
    It's probably trying to pass a string in the second Call when the receiver expects a byte.

    But I can't get my head around it... that's why I came here to ask a Guru.

    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
                    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
    '=================================================================
    Thanks for looking.

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

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

    Quote Originally Posted by BriansBrain View Post
    It's probably trying to pass a string in the second Call when the receiver expects a byte.
    No, it isn't. The type being passed is the same for both. So if it's correct the first time, then it's correct the second time too. However, one thing does catch my attention:
    Code:
    ExData(Index) = MidB(ExData(Index), 1) & MidB(WaveData, 1) ' Sync wave bits...
    Something tells me the problem is there, because MidB() works on 8 bit bytes. What is the data type of ExData?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  15. #30
    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
    What is the data type of ExData?
    Before that code is ...
    Dim rc As Long ' Return Code Variable
    Dim WaveData() As Byte ' Byte array of wave data
    Static ExBytes(MAXTCP) As Long ' Extra bytes in frame buffer
    Static ExData(MAXTCP) As Variant ' Extra bytes from frame buffer

    All I know is if I increase the wav streaming quality, whether it be 8bit or 16bit the error ocours.
    Last edited by BriansBrain; October 11th, 2009 at 01:50 PM.

Page 2 of 4 FirstFirst 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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center