Sourcecode 
Author Message
 Sourcecode

Now I have found this sourcecode. I Put it all in a funktion of a Button
(OnButton1), but if I try it it an press the Button , my IPaq crash and I
must reset it. Whats wrong? And how can I save the recorded Data? Here is
the sourcecode:

const int NUMPTS = 44100 * 10;   // 10 seconds
 int sampleRate = 44100;
 short int waveIn[NUMPTS];   // 'short int' is a 16-bit type; I request
16-bit samples below
                             // for 8-bit capture, you'd use 'unsigned char'
or 'BYTE' 8-bit types

 HWAVEIN      hWaveIn;
 WAVEHDR      WaveInHdr;
 MMRESULT result;

 // Specify recording parameters
 WAVEFORMATEX pFormat;
 pFormat.wFormatTag=WAVE_FORMAT_PCM;     // simple, uncompressed format
 pFormat.nChannels=1;                    //  1=mono, 2=stereo
 pFormat.nSamplesPerSec=sampleRate;      // 44100
 pFormat.nAvgBytesPerSec=sampleRate*2;   // = nSamplesPerSec * n.Channels *
wBitsPerSample/8
 pFormat.nBlockAlign=2;                  // = n.Channels * wBitsPerSample/8
 pFormat.wBitsPerSample=16;              //  16 for high quality, 8 for
telephone-grade
 pFormat.cbSize=0;

waveInOpen(&hWaveIn, WAVE_MAPPER,&pFormat,
            0L, 0L, WAVE_FORMAT_DIRECT);

 // Set up and prepare header for input
 WaveInHdr.lpData = (LPSTR)waveIn;
 WaveInHdr.dwBufferLength = NUMPTS*2;
 WaveInHdr.dwBytesRecorded=0;
 WaveInHdr.dwUser = 0L;
 WaveInHdr.dwFlags = 0L;
 WaveInHdr.dwLoops = 0L;
 waveInPrepareHeader(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));

 // Insert a wave input buffer
 result = waveInAddBuffer(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));
 if (result)
 {
  MessageBox(_T("Failed to read block from device"),
                   NULL, MB_OK | MB_ICONEXCLAMATION);
  return;
 }

 // Commence sampling input
 result = waveInStart(hWaveIn);
 if (result)
 {
  MessageBox(_T("Failed to start recording"),
                   NULL, MB_OK | MB_ICONEXCLAMATION);
  return;
 }

 // Wait until finished recording
 do {} while (waveInUnprepareHeader(hWaveIn, &WaveInHdr,
sizeof(WAVEHDR))==WAVERR_STILLPLAYING);

 waveInClose(hWaveIn);



Sun, 25 Sep 2005 20:21:00 GMT  
 Sourcecode
Hello,

problem is here:

Quote:
>short int waveIn[NUMPTS];

44100 * 10* 2 = 882000 bytes - too much :)

Also,
Try to use callback  mechanism to receive callback information
and control recording process.

for example:

waveInOpen(&hWaveIn,WAVE_MAPPER,&pFormat,(DWORD)WaveInCallback,(DWORD)this,
CALLBACK_FUNCTION);

Check your e-mail. I sent source code for you.

________________________
Ruslan Demyanenko



Mon, 26 Sep 2005 16:02:22 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. H3sm sourcecode

2. compiler and sourcecode wanted

3. Read sourcecode from a database

4. Please, help me the SourceCode for TripleDES...

5. searching sourcecode to generate 8-bit-crc (x^8 + x^2 + x + 1)

6. where to find the sourcecode for the c standard library

7. Eliza: Sourcecode!

8. sscanf() sourcecode

9. Req: Sourcecode

10. C sourcecode

11. ftp client sourcecode wanted!!

12. need some pointers to C-sourcecode

 

 
Powered by phpBB® Forum Software