Note that there are some explanatory texts on larger screens.

plurals
  1. POwaveInProc / Windows audio question
    primarykey
    data
    text
    <p>I'm using the Windows API to get audio input. I've followed all the steps on MSDN and managed to record audio to a WAV file. No problem. I'm using multiple buffers and all that. I'd like to do more with the buffers than simply write to a file, so now I've got a callback set up. It works great and I'm getting the data, but I'm not sure what to do with it once I have it.</p> <p>Here's my callback... everything here works:</p> <pre><code>// Media API callback void CALLBACK AudioRecorder::waveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { // Data received if (uMsg == WIM_DATA) { // Get wav header LPWAVEHDR mBuffer = (WAVEHDR *)dwParam1; // Now what? for (unsigned i = 0; i != mBuffer-&gt;dwBytesRecorded; ++i) { // I can see the char, how do get them into my file and audio buffers? cout &lt;&lt; mBuffer-&gt;lpData[i] &lt;&lt; "\n"; } // Re-use buffer mResultHnd = waveInAddBuffer(hWaveIn, mBuffer, sizeof(mInputBuffer[0])); // mInputBuffer is a const WAVEHDR * } } // waveInOpen cannot use an instance method as its callback, // so we create a static method which calls the instance version void CALLBACK AudioRecorder::staticWaveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { // Call instance version of method reinterpret_cast&lt;AudioRecorder *&gt;(dwParam1)-&gt;waveInProc(hWaveIn, uMsg, dwInstance, dwParam1, dwParam2); } </code></pre> <p>Like I said, it works great, but I'm trying to do the following:</p> <ul> <li>Convert the data to short and copy into an array</li> <li>Convert the data to float and copy into an array</li> <li>Copy the data to a larger char array which I'll write into a WAV</li> <li>Relay the data to an arbitrary output device</li> </ul> <p>I've worked with FMOD a lot and I'm familiar with interleaving and all that. But FMOD dishes everything out as floats. In this case, I'm going the other way. I guess I'm basically just looking for resources on how to go from LPSTR to short, float, and unsigned char.</p> <p>Thanks much in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload