Mix_Quickload_RAW doesn't seem to properly process real raw WAV data

Mix_Quickload_RAW doesn’t really seem to properly work on true WAV raw data
(i.e. just the sound samples w/o any header information). When I feed such data
to it, I get distorted sound.

When I on the other hand feed complete WAV data including proper block headers
to it, everything works fine.

I don’t know what “true WAV raw data” means, but Mix_QuickLoad_RAW()
looks like it should interpret any headers as garbage sound data. The
fact that it seems to play correctly only when you include the
headers suggests to me that you’re making some other mistake, but you
have failed to include your code (or software versions) so we can only
guess at what you might have done wrong. Here are some ideas:

  1. Your PCM data is not in the format you got with SDL_OpenAudio() or
    Mix_OpenAudio()

  2. Your PCM data is not properly aligned (try adding +1 to your
    pointer and -1 to your len when you call Mix_QuickLoad_RAW() and see
    if that fixes anything)

For reference, here is the implementation of Mix_QuickLoad_RAW() as of
SDL_mixer Subversion revision 644:

Mix_Chunk *chunk;
chunk = (Mix_Chunk *)malloc(sizeof(Mix_Chunk));
chunk->allocated = 0;
chunk->alen = len;
chunk->abuf = mem;
chunk->volume = MIX_MAX_VOLUME;
return(chunk);On Sat, Feb 7, 2009 at 5:04 PM, Dietfrid Mali wrote:

Mix_Quickload_RAW doesn’t really seem to properly work on true WAV raw data
(i.e. just the sound samples w/o any header information). When I feed such data
to it, I get distorted sound.

When I on the other hand feed complete WAV data including proper block headers
to it, everything works fine.


http://codebad.com/

Well, it must be another error. I have detected that everything works well with
the previous program version.

RIFF/WAVE header data probably doesn’t hurt in data passed to Mix_QuickLoad_RAW
because it’s so short you simply don’t hear it, and it’s word aligned so doesn’t
affect interpretation of the sound data.

I am now passing complete WAV data to Mix_QuickLoad_WAV.

I just cannot figure what I might have changed between these two program
versions. All calls look identical. But that’s my problem.

SDL_mixer is very sensitive towards sound buffer sizes (funny enough, bigger
buffers cause static) and doesn’t like being shutdown and reopened with
different settings during program execution, which usually causes distorted
sound.

SDL_mixer is very sensitive towards sound buffer sizes (funny enough, bigger
buffers cause static)

More likely it is high PCM data fill callback latency that causes the
problem. Although I static/noise is a particularly awful mode of
failure IMHO.

and doesn’t like being shutdown and reopened with
different settings during program execution, which usually causes distorted
sound.

Perhaps some SDL audio back-end is intolerant of this behavior…On Sat, Feb 7, 2009 at 8:50 PM, Dietfrid Mali wrote:


http://codebad.com/

Donny Viszneki <donny.viszneki gmail.com> writes:

More likely it is high PCM data fill callback latency that causes the
problem. Although I static/noise is a particularly awful mode of
failure IMHO.

C2D E8500, 4 GB DDR2 1066 MHz, Soundblaster X-Fi, Radeon HD 4870. Data fill
callback latency? Not with that machine, I would say.

I still have the problem of a lot of static in the sound, and all I do is
resample it from mono to stereo (just duplicating the bytes, mode is AUDIO_U8)
before passing the sound data to SDL_mixer.

Btw, “real raw WAV sound data” is the data following a RIFF/WAVE Data chunk
header; the actual sound samples.

Perhaps some SDL audio back-end is intolerant of this behavior…

Sigh.

Donny Viszneki <donny.viszneki gmail.com> writes:

More likely it is high PCM data fill callback latency that causes the
problem. Although I static/noise is a particularly awful mode of
failure IMHO.

C2D E8500, 4 GB DDR2 1066 MHz, Soundblaster X-Fi, Radeon HD 4870. Data fill
callback latency? Not with that machine, I would say.

I still have the problem of a lot of static in the sound, and all I do is
resample it from mono to stereo (just duplicating the bytes, mode is AUDIO_U8)
before passing the sound data to SDL_mixer.

Are you using Vista by any chance?

Btw, “real raw WAV sound data” is the data following a RIFF/WAVE Data chunk
header; the actual sound samples.

The right term for this is “PCM data” :slight_smile:

Perhaps some SDL audio back-end is intolerant of this behavior…

Sigh.

What system are you using? Have you tried other SDL audio backends
available for your platform?On Sun, Feb 8, 2009 at 4:04 PM, Dietfrid Mali wrote:


http://codebad.com/

Donny Viszneki <donny.viszneki gmail.com> writes:

Are you using Vista by any chance?

WinXP home SP 3.

The right term for this is “PCM data” :slight_smile:

Well, the SDL_mixer docs available don’t call it that way either.

What system are you using? Have you tried other SDL audio backends
available for your platform?

I don’t know what you are talking about or what choice I would have here.

Well, it must be another error. I have detected that everything works well with
the previous program version.

RIFF/WAVE header data probably doesn’t hurt in data passed to Mix_QuickLoad_RAW
because it’s so short you simply don’t hear it, and it’s word aligned so doesn’t
affect interpretation of the sound data.

I am now passing complete WAV data to Mix_QuickLoad_WAV.

I just cannot figure what I might have changed between these two program
versions. All calls look identical. But that’s my problem.

Can you put together a minimal example that shows the problem?

See ya!
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

I looked through the SDL source and I didn’t see any alternative audio
back-ends on Windows, strangely. I thought there’d be a DirectX
back-end. SorryOn Sun, Feb 8, 2009 at 8:46 PM, Dietfrid Mali wrote:

Donny Viszneki <donny.viszneki gmail.com> writes:

What system are you using? Have you tried other SDL audio backends
available for your platform?

I don’t know what you are talking about or what choice I would have here.


http://codebad.com/

Hello !

I looked through the SDL source and I didn’t see any alternative audio
back-ends on Windows, strangely. I thought there’d be a DirectX
back-end. Sorry

SDL 1.2 had two choices for Windows Users,
using WaveOut and using DirectSound through DirectX 5.

The DSound driver is still in the sources with SDL 1.3 :

http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL/src/audio/windx5/

Enable it by setting SDL_AUDIODRIVER to waveout or dsound.

CU

Ah, thanks! I grepped the relevant source code for “win” assuming that
would pick out any windows-related plugin. Guess that was a silly
approachOn Mon, Feb 9, 2009 at 2:39 PM, Torsten Giebl wrote:

SDL 1.2 had two choices for Windows Users,
using WaveOut and using DirectSound through DirectX 5.

The DSound driver is still in the sources with SDL 1.3 :

Enable it by setting SDL_AUDIODRIVER to waveout or dsound.


http://codebad.com/

Torsten Giebl <wizard syntheticsw.com> writes:

SDL 1.2 had two choices for Windows Users,
using WaveOut and using DirectSound through DirectX 5.

Enable it by setting SDL_AUDIODRIVER to waveout or dsound.

CU

Thanks. Afaik DX is the default output device.