Board index » delphi » Why BADFORMAT in return with WaveOutOpen?

Why BADFORMAT in return with WaveOutOpen?

Why do I get BADFORMAT error (=32) in return when I use WaveOutOpen?
When calling WaveOutGetCaps, it reports that all formats
up to 44100/16/2 is OK.

--------------------------------------------
Excerpt:

    var
        F:      TWaveFormat;
        pF:     PWaveFormat;
        r:      Word;
        hW:     PHWaveOut;

    begin
        F.wFormatTag     := WAVE_FORMAT_PCM;
        F.nChannels      := 2;
        F.nSamplesPerSec := 44100;
        F.nAvgBytesPerSec:= 176400;
        F.nBlockAlign    := 4;

        pF := @F;
        r  := WaveOutOpen(hW, 0, pF, 0, 0, WAVE_FORMAT_QUERY);

---------------------------------------------------------

Even when trying lower formats, it still returns 32.

Ebbe,
ei94...@ios.chalmers.se

 

Re:Why BADFORMAT in return with WaveOutOpen?


Hi Ebbe,

Quote
ei94...@ios.chalmers.se (Ebbe Nilsson) wrote:
>Why do I get BADFORMAT error (=32) in return when I use WaveOutOpen?
>When calling WaveOutGetCaps, it reports that all formats
>up to 44100/16/2 is OK.
>--------------------------------------------
>Excerpt:
>    var
>        F:      TWaveFormat;
>        pF:     PWaveFormat;
>        r:      Word;
>        hW:     PHWaveOut;
>    begin
>        F.wFormatTag     := WAVE_FORMAT_PCM;
>        F.nChannels      := 2;
>        F.nSamplesPerSec := 44100;
>        F.nAvgBytesPerSec:= 176400;
>        F.nBlockAlign    := 4;
>        pF := @F;
>        r  := WaveOutOpen(hW, 0, pF, 0, 0, WAVE_FORMAT_QUERY);

As you stated above you want to use a WAVE_FORMAT_PCM. So
you have to initialize a complete TPCMWaveFormat record instead
of a TWaveFormat:

  TPCMWaveFormat = record
      wf: TWaveFormat;
      wBitsPerSample: Word;
   end;

Here the initialization of wBitsPerSample is also needed!

hope it helps.

Armin

--
signature currently not available.

Other Threads