Thread View: borland.public.cppbuilder.multimedia
5 messages
5 total messages
Started by ghislain.ruy
Sun, 08 Jul 2001 21:16
SOUND CARD
Author: ghislain.ruy
Date: Sun, 08 Jul 2001 21:16
Date: Sun, 08 Jul 2001 21:16
16 lines
1318 bytes
1318 bytes
Hello, does somebody know how to retrieve raw samples from a sound card in order to process them ? I had a look to winapi but it's quite cumbersome and I would prefer something like a linux driver (just read a file for example). Is there a dll to do the job ? Is it possible via the media player trough undocumented class members or so ? Thank you in advance for help. -- -------------- Ghislain RUY --------------
Re: SOUND CARD
Author: Corey Murtagh
Date: Mon, 09 Jul 2001 22:05
Date: Mon, 09 Jul 2001 22:05
50 lines
3200 bytes
3200 bytes
<ghislain.ruy@ieee.org> wrote in message news:3B48CDA3.CE2AAD36@ieee.org... > Hello, Hi Ghislane, > does somebody know how to retrieve raw samples from a sound card in > order to process them ? > I had a look to winapi but it's quite cumbersome and I would prefer > something like a linux driver (just read a file for example). Is there a > dll to do the job ? Unfortunately the driver model in Windows is significantly different to the Linux one. However, although the mmSystem API is a little complex it doesn't take too long to work out. Create a WAVEFORMATEX structure to describe the recording format you need and pass it to waveInOpen() to open a wave input device. Prepare two (or more - two is a good starting number) buffers using waveInPrepareHeader(), then add them to the record queue with waveInAddBuffer(). Start recording with waveInStart(). Don't forget to allocate the memory for the buffers, as the mmsystem won't do this for you. Once that's all done you should get callbacks (or messages, or...) when each buffer is filled. Take the data out of the buffer and re-add the buffer to the recording queue. You might want to do this in a seperate thread to abstract it all from your processing routines - use a memory stream or something to store it in, then your processing routines just need to read from the stream. Once you are done recording, call waveInStop() to stop recording, wait for the mmsystem to tell you it is done, then clean up: call waveInUnprepareHeader() on all buffers prepared earlier, then waveInReset() and finally waveInClose(). > Is it possible via the media player trough undocumented class members or > so ? I prefer to go straight to the mmsystem as it's about as low-level as you can get without some knowledge of the actual sound drivers. Of course you could try using DirectSound... assuming it has a recording facility? I haven't touched DirectX yet, but then I haven't needed it. > Thank you in advance for help. Hope it helps. Let me know if you get lost. -- Corey Murtagh The Electric Monk "Quidquid latine dictum sit, altum viditur."
Re: SOUND CARD
Author: Corey Murtagh
Date: Tue, 24 Jul 2001 10:06
Date: Tue, 24 Jul 2001 10:06
49 lines
2463 bytes
2463 bytes
<ghislain.ruy@ieee.org> wrote in message news:3B48CDA3.CE2AAD36@ieee.org... > Hello, > > does somebody know how to retrieve raw samples from a sound card in > order to process them ? > I had a look to winapi but it's quite cumbersome and I would prefer > something like a linux driver (just read a file for example). Is there a > dll to do the job ? > Is it possible via the media player trough undocumented class members or > so ? Sorry about the delay replying... been messing around with news readers and servers. Anyway, there are two main ways to access the sound card: MMSystem and DirectSound. I prefer the first, because I've already got lots of code to refer to. Here's the basic sequence I use to record sound: 1: Prepare a WAVEFORMATEX struct to define the sample format (rate, bits, channels, etc) 2: Call waveInOpen() to open the input device 3: prepare a couple of WAVEHDR structs by allocating buffers, then calling waveInPrepareHeader() on both of them 4: Call waveInAddBuffer() to add both buffers to the record queue, then waveInStart() to start it running 5: message loop. Wait on MM_WIM_DATA messages, process them (copy the data out of the buffer, then add it back into the queue with waveInAddBuffer) 6: when done, call waveInStop() and wait until all buffers have been returned 7: call waveInReset(), waveInUnprepareHeader() on both buffers, the waveInClose() to release the port. Hope this helps. I have some code I can send you if you get bogged down. -- Corey Murtagh The Electric Monk "Quidquid latine dictum sit, altum viditur."
Re: SOUND CARD
Author: Spider
Date: Wed, 25 Jul 2001 12:44
Date: Wed, 25 Jul 2001 12:44
11 lines
1248 bytes
1248 bytes
Would you happen to have any code to show a level meter even though the audio driver doesn't include a meter I can read ?? ok, a little background: I have a media player that will search for a meter (mixerGetLineControls) and check for MIXERCONTROL_CONTROLTYPE_PEAKMETER on most controls, works great on many different computers - except - for computers with audio drivers that don't include any type of peak meters. Do you know of anyway to get levels, without having to write a device driver ?? this realy bugs me! Wally
Re: SOUND CARD
Author: ruygh
Date: Sat, 18 Aug 2001 23:05
Date: Sat, 18 Aug 2001 23:05
67 lines
3175 bytes
3175 bytes
Thank you very much. I indeed took the time to dig into the windows API and finally got to the sequence you suggests with success. My primary job is RF & DSp electronic design, programming is a side activity, but for one application, I needed to use the sound card samples to process them. I used a callback function instead of windows messages and got a flawless class. Thank you very much. Corey Murtagh wrote: > > <ghislain.ruy@ieee.org> wrote in message news:3B48CDA3.CE2AAD36@ieee.org... > > Hello, > > > > does somebody know how to retrieve raw samples from a sound card in > > order to process them ? > > I had a look to winapi but it's quite cumbersome and I would prefer > > something like a linux driver (just read a file for example). Is there a > > dll to do the job ? > > Is it possible via the media player trough undocumented class members or > > so ? > > Sorry about the delay replying... been messing around with news readers and > servers. > > Anyway, there are two main ways to access the sound card: MMSystem and > DirectSound. I prefer the first, because I've already got lots of code to > refer to. > > Here's the basic sequence I use to record sound: > > 1: Prepare a WAVEFORMATEX struct to define the sample format > (rate, bits, channels, etc) > > 2: Call waveInOpen() to open the input device > > 3: prepare a couple of WAVEHDR structs by allocating buffers, > then calling waveInPrepareHeader() on both of them > > 4: Call waveInAddBuffer() to add both buffers to the record > queue, then waveInStart() to start it running > > 5: message loop. Wait on MM_WIM_DATA messages, process them > (copy the data out of the buffer, then add it back into > the queue with waveInAddBuffer) > > 6: when done, call waveInStop() and wait until all buffers > have been returned > > 7: call waveInReset(), waveInUnprepareHeader() on both buffers, > the waveInClose() to release the port. > > Hope this helps. I have some code I can send you if you get bogged down. > > -- > Corey Murtagh > The Electric Monk > "Quidquid latine dictum sit, altum viditur." -- -------------- Ghislain RUY F1HDD AMSAT FRANCE Chef de projet SATEDU --------------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads