SDL_audio.h
Enumerado SDL_AudioFormat
Un enumerado de formatos de audio.
typedef Uint16 SDL_AudioFormat;
Valores
Esto es lo que significan actualmente los 16 bits de SDL_AudioFormat:
+----------------------sample is signed if set | | +----------sample is bigendian if set | | | | +--sample is float if set | | | | | | +--sample bit size---+ | | | | | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Los bits no especificados son siempre cero, pero pueden utilizarse en versiones posteriores de SDL. Existen macros para consultar los bits especificados.
Macros de formato de audio
- SDL_AUDIO_MASK_BITSIZE
- (0xFF)
- SDL_AUDIO_MASK_DATATYPE
- (1<<8)
- SDL_AUDIO_MASK_ENDIAN
- (1<<12)
- SDL_AUDIO_MASK_SIGNED
- (1<<15)
- SDL_AUDIO_BITSIZE(x)
- (x & SDL_AUDIO_MASK_BITSIZE)
- SDL_AUDIO_ISFLOAT(x)
- (x & SDL_AUDIO_MASK_DATATYPE)
- SDL_AUDIO_ISBIGENDIAN(x)
- (x & SDL_AUDIO_MASK_ENDIAN)
- SDL_AUDIO_ISSIGNED(x)
- (x & SDL_AUDIO_MASK_SIGNED)
- SDL_AUDIO_ISINT(x)
- (!SDL_AUDIO_ISFLOAT(x))
- SDL_AUDIO_ISLITTLEENDIAN(x)
- (!SDL_AUDIO_ISBIGENDIAN(x))
- SDL_AUDIO_ISUNSIGNED(x)
- (!SDL_AUDIO_ISSIGNED(x))
Valores de formato de audio
Soporte 8-bit | |
---|---|
AUDIO_S8 | signed 8-bit samples |
AUDIO_U8 | unsigned 8-bit samples |
Soporte 16-bit | |
AUDIO_S16LSB | signed 16-bit samples en orden little-endian |
AUDIO_S16MSB | signed 16-bit samples en orden big-endian |
AUDIO_S16SYS | signed 16-bit samples orden nativo |
AUDIO_S16 | AUDIO_S16LSB |
AUDIO_U16LSB | unsigned 16-bit samples en orden little-endian |
AUDIO_U16MSB | unsigned 16-bit samples en orden big-endian |
AUDIO_U16SYS | unsigned 16-bit samples en orden nativo |
AUDIO_U16 | AUDIO_U16LSB |
Soporte de 32-bit (nuevo en SDL 2.0) | |
AUDIO_S32LSB | 32-bit integer samples en orden little-endian |
AUDIO_S32MSB | 32-bit integer samples en orden big-endian |
AUDIO_S32SYS | 32-bit integer samples en orden nativo |
AUDIO_S32 | AUDIO_S32LSB |
Soporte float (nuevo en SDL 2.0) | |
AUDIO_F32LSB | 32-bit samples float en orden little-endian |
AUDIO_F32MSB | 32-bit samples float en orden big-endian |
AUDIO_F32SYS | 32-bit samples float en orden nativo |
AUDIO_F32 | AUDIO_F32LSB |
Ejemplo
extern SDL_AudioFormat fmt; if (SDL_AUDIO_ISFLOAT(fmt)) { printf("floating point data\n"); } else { printf("integer data\n"); } printf("%d bits per sample\n", (int) SDL_AUDIO_BITSIZE(fmt));
Observaciones
Hay que tener cuidado al asumir detalles de un formato de datos. Si solo se comprueba SDL_AUDIO_ISFLOAT(), podría sorprender encontrar que una versión posterior de SDL añade soporte Float64 cuando se esperaba que solo hubiera datos de 32 bits, por ejemplo.