Board index » delphi » MMSystem and waveOutOpen function

MMSystem and waveOutOpen function


I have a SoundBlaster16 card which waveOutGetDevCaps tells me supports
up to 16-bit, 44100 Hz stereo but I cannot for the life of me get it
to kick into stereo and/or 16-bit mode!  I'm running Windows 95 and have

never had any problems listening to audio CD's, WAV files, etc, at
16-bit/44kHz/stereo.  It is either a problem with Dephi's MMSystem
interface or something silly I'm doing.

I don't have any docs on the waveOut routines except the Win32 API help
file (from elsewhere, not Delphi) and the MMSystem source from Delphi.

Ok, say I have a variable of type TPCMWaveFormat called pFormat.  Then,
after using GetMem to allocate it, I assign the following for 8-bit,
mono, any rate:

   with pFormat do
      wf.wFormatTag := wave_Format_PCM;
      wf.nChannels := 1;  {mono}
      wf.nBlockAlign := 1;  {8-bit, mono = 1 byte}
      wBitsPerSample := 8;
      wf.nSamplesPerSec := Rate;  {11/22/44kHz}
      wf.nAvgBytesPerSec := Rate;

This works fine with waveOutOpen like:

   err := waveOutOpen(@WaveID,Word(wave_Mapper),pWaveFormat(pFormat),...

The other parameters above don't matter here.  I have used 0 for
above but it doesn't do anything different (where 0 is the first and/or
waveOut device).  I have also used @pFormat^.wf instead of
above but it doesn't change anything either.  It shouldn't matter with
Format structure address I'm passing since the PCM-only field,
is on the tail end of this memory block and can be accessed using an
from the passed address.

From what I can gather from the minimal docs in my API help, the
would be correct for other format modes:

                      ---Format fields--------------------
   sample bits mode   nChannels nBlockAlign wBitsPerSample
   ----------- ------ --------- ----------- --------------
            8  mono          1           1              8
            8  stereo        2           2             16
           16  mono          1           2             16
           16  stereo        2           4             32

Only the first entry above works for me.

Any parameters other than the first entry in the table above results in
a WaveOut Format error that tells me to consult my WaveOut capabilities.

Am I way off on the table above?  I know the first and last entries
are correct, as the first one works and the last one is in the API help
as an example (but it doesn't work for me!).  Oh, by the way, I'm not
interested in 16-bit modes right now, it's the stereo I really want.

Sampling rates work fine -- I have no problem hitting 44kHz in 8-bit mono.


--Jeff ( )

PS: Hope the table above doesn't look like {*word*99} like it does in my


Re:MMSystem and waveOutOpen function

Quote (Jeff Bain) wrote:
>                      ---Format fields--------------------
>   sample bits mode   nChannels nBlockAlign wBitsPerSample
>   ----------- ------ --------- ----------- --------------
>            8  mono          1           1              8
>            8  stereo        2           2             16
>           16  mono          1           2             16
>           16  stereo        2           4             32

>Only the first entry above works for me.

Don't forget the nAvgBytesPerSec field. For 16-bit stereo and 44KHz it
nAvgBytesPerSec := nSamplesPerSec * 4;

Hope this helps.

Ulf Soderberg                  email:
Senior Software Engineer       www:
System Innovation AB           phone: +46 86300630
SWEDEN                         fax:   +46 86300639

Other Threads