Added int32 adn float32 support to SDL_LoadWAV_RW().
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402041
This commit is contained in:
parent
bead079669
commit
fd613a1f43
2 changed files with 35 additions and 17 deletions
|
@ -413,7 +413,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
||||||
int was_error;
|
int was_error;
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int lenread;
|
int lenread;
|
||||||
int MS_ADPCM_encoded, IMA_ADPCM_encoded;
|
int IEEE_float_encoded, MS_ADPCM_encoded, IMA_ADPCM_encoded;
|
||||||
int samplesize;
|
int samplesize;
|
||||||
|
|
||||||
/* WAV magic header */
|
/* WAV magic header */
|
||||||
|
@ -472,11 +472,15 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
||||||
was_error = 1;
|
was_error = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
|
IEEE_float_encoded = MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
|
||||||
switch (SDL_SwapLE16(format->encoding)) {
|
switch (SDL_SwapLE16(format->encoding)) {
|
||||||
case PCM_CODE:
|
case PCM_CODE:
|
||||||
/* We can understand this */
|
/* We can understand this */
|
||||||
break;
|
break;
|
||||||
|
case IEEE_FLOAT_CODE:
|
||||||
|
IEEE_float_encoded = 1;
|
||||||
|
/* We can understand this */
|
||||||
|
break;
|
||||||
case MS_ADPCM_CODE:
|
case MS_ADPCM_CODE:
|
||||||
/* Try to understand this */
|
/* Try to understand this */
|
||||||
if (InitMS_ADPCM(format) < 0) {
|
if (InitMS_ADPCM(format) < 0) {
|
||||||
|
@ -506,24 +510,37 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
||||||
}
|
}
|
||||||
SDL_memset(spec, 0, (sizeof *spec));
|
SDL_memset(spec, 0, (sizeof *spec));
|
||||||
spec->freq = SDL_SwapLE32(format->frequency);
|
spec->freq = SDL_SwapLE32(format->frequency);
|
||||||
switch (SDL_SwapLE16(format->bitspersample)) {
|
|
||||||
case 4:
|
if (IEEE_float_encoded) {
|
||||||
if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
|
if ((SDL_SwapLE16(format->bitspersample)) != 32) {
|
||||||
spec->format = AUDIO_S16;
|
|
||||||
} else {
|
|
||||||
was_error = 1;
|
was_error = 1;
|
||||||
|
} else {
|
||||||
|
spec->format = AUDIO_F32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (SDL_SwapLE16(format->bitspersample)) {
|
||||||
|
case 4:
|
||||||
|
if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
|
||||||
|
spec->format = AUDIO_S16;
|
||||||
|
} else {
|
||||||
|
was_error = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
spec->format = AUDIO_U8;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
spec->format = AUDIO_S16;
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
spec->format = AUDIO_S32;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
was_error = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
spec->format = AUDIO_U8;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
spec->format = AUDIO_S16;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
was_error = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (was_error) {
|
if (was_error) {
|
||||||
SDL_SetError("Unknown %d-bit PCM data format",
|
SDL_SetError("Unknown %d-bit PCM data format",
|
||||||
SDL_SwapLE16(format->bitspersample));
|
SDL_SwapLE16(format->bitspersample));
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#define DATA 0x61746164 /* "data" */
|
#define DATA 0x61746164 /* "data" */
|
||||||
#define PCM_CODE 0x0001
|
#define PCM_CODE 0x0001
|
||||||
#define MS_ADPCM_CODE 0x0002
|
#define MS_ADPCM_CODE 0x0002
|
||||||
|
#define IEEE_FLOAT_CODE 0x0003
|
||||||
#define IMA_ADPCM_CODE 0x0011
|
#define IMA_ADPCM_CODE 0x0011
|
||||||
#define MP3_CODE 0x0055
|
#define MP3_CODE 0x0055
|
||||||
#define WAVE_MONO 1
|
#define WAVE_MONO 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue