Capture sounds from soundcard=speakers - NOT from microphone
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Capture sounds from soundcard=speakers - NOT from microphone

  1. #1
    Join Date
    Apr 2014
    Posts
    8

    Capture sounds from soundcard=speakers - NOT from microphone

    What I would like to do is to capture the sounds you hear from the computer speakers - NOT from the microphone. I.E if you listen to song in youtube with the computer then to capture that song sound. I.E everything that is playing or should be playing on the speakers should be recorded. I found that best will be to use the waveIn* functions, such as

    waveInOpen
    waveInPrepareHeader
    waveInAddBuffer // in loop for all buffers
    waveInStart
    waveInStop
    waveInReset
    waveInUnprepareHeader // in loop for all buffers
    waveInClose

    (this wave* is new to me so sorry for any dumb question)

    My problems are:

    I think that waveInOpen records what you speak on the mic and not the speakers so i am not sure how to tell it to capture the speakers/soundcard.
    I am note sure i understand how to make the software to still be active while the recording is running I.E where to put the Wait().
    I do not understand how to create sound file .pcm from the buffers. I.e should i append buf(1) + buf(2) + buf(3) + ... (the buf i sent to waveInAddBuffer) for creating the file?
    And I do not understand how to connect everything - i.e., I do NOT want to record X minutes, then to stop and then save to file. I need to transmit this recording online in real time so i need immediate access to the data.

    The final goal is to transmit the recording after it is encoded - to another device in real time - currently i am not asking about the encoder since i will deal with it latter.

    So I need something like:

    byte arr[1024*1024];
    while (1)
    {
    GetCurrentSounds(arr);
    Encode(arr);
    Transmit(arr)
    }

    So GetCurrentSounds fill arr with the recording that took place (in another thread i guess) from the time GetCurrentSounds last called .

    Yes, I do not really need to save to file - but the reason i asked how to save it to file is for debugging to see that I do everything ok. Hope you can provide explanation to the 3 question and even some code how to do what I need.

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,621

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    Hi!

    You should be able to use the recording API pretty straight off, but the device must also support so called "Stereo Mix", which you can read about here:
    http://www.howtogeek.com/howto/39532...-record-audio/

    Please note the Stereo Mix is disabled by default. Maybe you can programmatically enable it, but I have no idea how.
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Apr 2014
    Posts
    8

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    Quote Originally Posted by zerver View Post
    Hi!

    You should be able to use the recording API pretty straight off, but the device must also support so called "Stereo Mix", which you can read about here:
    http://www.howtogeek.com/howto/39532...-record-audio/

    Please note the Stereo Mix is disabled by default. Maybe you can programmatically enable it, but I have no idea how.
    Thanks but this is not the solution:
    From the article:
    In other instances, however, itís because the newest Windows 7 drivers donít support this feature. This was the case on my Asus Eee PC (a 1000HE), but I got around the issue by downloading and installing the older Windows XP/Vista drivers for my audio chipset
    --------------------------------

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,100

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    the waveInOpen() needs a INPUT sound device
    and there's the problem area.
    you'll need to install (or create) a sounddriver that has save to disk or output-as-input.

  5. #5
    Join Date
    Apr 2014
    Posts
    8

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    Quote Originally Posted by OReubens View Post
    the waveInOpen() needs a INPUT sound device
    and there's the problem area.
    you'll need to install (or create) a sounddriver that has save to disk or output-as-input.
    Hi.
    Do you meant that I will write a Driver? .drv file?

  6. #6
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,621

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    Writing a sound driver... I don't think you should reinvent the wheel...

    Maybe have a look here: http://www.portaudio.com/
    Nobody cares how it works as long as it works

  7. #7
    Join Date
    Apr 2014
    Posts
    8

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    Quote Originally Posted by zerver View Post
    Writing a sound driver... I don't think you should reinvent the wheel...

    Maybe have a look here: http://www.portaudio.com/
    Thanks for trying to help but portaudio has thousands of thousands of code lines so i do not even know how to approach that.

  8. #8
    Join Date
    May 2013
    Posts
    26

    Re: Capture sounds from soundcard=speakers - NOT from microphone

    You might be able to use a virtual sound card or Virtual Audio Cable: http://www.tomsguide.com/us/download...305-31100.html

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