Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I have problem with waveinopen function which cause an errormessage 11

435 views
Skip to first unread message

CHW

unread,
May 5, 2001, 7:33:35 AM5/5/01
to
I have a problem with the waveinopen function. The function returns the
MMRESULT_ERROR 11( "invalid Parameter passed "). The function runs under
Win NT but under WIN ME came the above errormessage. Thanks for help

Sent via AllAPI.net
http://www.allapi.net/

Alexander Kienzle

unread,
May 5, 2001, 10:36:26 AM5/5/01
to
Can you show some code?

Alex

CHW <hou...@hotmail.com> schrieb in im Newsbeitrag:
#ong5cV1AHA.1908@tkmsftngp02...

CHW

unread,
May 6, 2001, 10:19:00 AM5/6/01
to
Alexander Kienzle wrote:


> Can you show some code?

> Alex

> CHW <hou...@hotmail.com> schrieb in im Newsbeitrag:
> #ong5cV1AHA.1908@tkmsftngp02...
> > I have a problem with the waveinopen function. The function returns the
> > MMRESULT_ERROR 11( "invalid Parameter passed "). The function runs under
> > Win NT but under WIN ME came the above errormessage. Thanks for help

Here is the codesequence which cause the problem

the cpp file

//---------------------------------------------------------------------------

#include <vcl.h>
#include <mmsystem>
#pragma hdrstop

#include "audioprob.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
hwnd = CreateWindow("banane", TEXT("hallo"), WS_OVERLAPPEDWINDOW,
// Fensterstil
CW_USEDEFAULT, // X-Position des
Fensters
CW_USEDEFAULT, // Y-Position des
Fensters
CW_USEDEFAULT, // Fensterbreite
CW_USEDEFAULT, // Fensterhöhe
NULL, // übergeordnetes
Fenster
NULL, // Menü
NULL, // Programm-Kopiezähler
(Programm-ID)
NULL) ;
// Audio-Gerät für die Aufnahme öffnen
waveform.wFormatTag = WAVE_FORMAT_PCM;
waveform.nChannels = 1 ;
waveform.nSamplesPerSec = 11025 ;
waveform.nAvgBytesPerSec = 11025 ;
waveform.nBlockAlign = 1 ;
waveform.wBitsPerSample = 8 ;
waveform.cbSize = 0 ;
FehlernummerAufnahme=waveInOpen (&hWaveIn, WAVE_MAPPER, &waveform,
(DWORD) hwnd, 0, CALLBACK_WINDOW);
labFehlermeldungAufnahme->Caption = FehlernummerAufnahme;

}

the headerfile

//---------------------------------------------------------------------------

#ifndef audioprobH
#define audioprobH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *labFehlermeldungAufnahme;
private: // User declarations

HWND hwnd;
UINT message;
LPARAM lParam;

BOOL bRecording, bPlaying, bReverse, bPaused,
bEnding, bTerminating ;
DWORD dwDataLength, dwRepetitions ;
HWAVEIN hWaveIn ;
HWAVEOUT hWaveOut ;
PBYTE pBuffer1, pBuffer2, pSaveBuffer, pNewBuffer ;
PWAVEHDR pWaveHdr1, pWaveHdr2 ;
WAVEFORMATEX waveform ;

unsigned int FehlernummerAufnahme, FehlernummerPlay ;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

Alexander Kienzle

unread,
May 7, 2001, 9:04:07 AM5/7/01
to
Sorry for the delay, seems I did not hit the Send button when
I wrote a reply yesterday.

Code looks ok, but I think the format defined in the waveformatex
structure might be rejected, as it is not a common format
(44.1kHz, 16-bit stereo).
Try calling waveInOpen with the WAVE_FORMAT_QUERY and
WAVE_FORMAT_DIRECT flags to test whether the format is
really supported by the hardware.
I think sometimes ACM (Audio Compression Manager) is used to
perform realtime conversion of audio formats, so waveInOpen
might fail in case no such converter is installed.

I also never used the WAVE_MAPPER flag.

Hope this helps

Alex

CHW <hou...@hotmail.com> wrote in message
news:uAeu$dj1AHA.1396@tkmsftngp05...


> Alexander Kienzle wrote:
>
>
> > Can you show some code?
>
> > Alex
>
> > CHW <hou...@hotmail.com> schrieb in im Newsbeitrag:
> > #ong5cV1AHA.1908@tkmsftngp02...
> > > I have a problem with the waveinopen function. The function returns
the
> > > MMRESULT_ERROR 11( "invalid Parameter passed "). The function runs
under
> > > Win NT but under WIN ME came the above errormessage. Thanks for help
>
> Here is the codesequence which cause the problem
>
> the cpp file
>
>

file://---------------------------------------------------------------------


------
>
> #include <vcl.h>
> #include <mmsystem>
> #pragma hdrstop
>
> #include "audioprob.h"
>

file://---------------------------------------------------------------------


------
> #pragma package(smart_init)
> #pragma resource "*.dfm"
> TForm1 *Form1;
>

file://---------------------------------------------------------------------

file://---------------------------------------------------------------------
------
>
> #ifndef audioprobH
> #define audioprobH
>
file://---------------------------------------------------------------------


------
> #include <Classes.hpp>
> #include <Controls.hpp>
> #include <StdCtrls.hpp>
> #include <Forms.hpp>
>

file://---------------------------------------------------------------------


------
> class TForm1 : public TForm
> {
> __published: // IDE-managed Components
> TLabel *labFehlermeldungAufnahme;
> private: // User declarations
>
> HWND hwnd;
> UINT message;
> LPARAM lParam;
>
> BOOL bRecording, bPlaying, bReverse, bPaused,
> bEnding, bTerminating ;
> DWORD dwDataLength, dwRepetitions ;
> HWAVEIN hWaveIn ;
> HWAVEOUT hWaveOut ;
> PBYTE pBuffer1, pBuffer2, pSaveBuffer, pNewBuffer ;
> PWAVEHDR pWaveHdr1, pWaveHdr2 ;
> WAVEFORMATEX waveform ;
>
> unsigned int FehlernummerAufnahme, FehlernummerPlay ;
> public: // User declarations
> __fastcall TForm1(TComponent* Owner);
> };
>

file://---------------------------------------------------------------------
------
> extern PACKAGE TForm1 *Form1;
>
file://---------------------------------------------------------------------

CHW

unread,
May 7, 2001, 1:38:25 PM5/7/01
to
Thank you Alex for the advise.
I tried but it doesn't work. I think the problem is the window handle.
When I replace the CALLBACK_WINDOW with the CALLBACK_NULL then the
function works. But I need the CALLBACK_WINDOW for the
callback-mechanism.Maybe you have another advise.
Thank you for helping

Christoph

0 new messages