First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
my @audiotypes = qw(
|
|
|
|
U8
|
|
|
|
S8
|
|
|
|
U16LSB
|
|
|
|
S16LSB
|
|
|
|
U16MSB
|
|
|
|
S16MSB
|
|
|
|
S32LSB
|
|
|
|
S32MSB
|
|
|
|
F32LSB
|
|
|
|
F32MSB
|
|
|
|
);
|
|
|
|
|
|
|
|
my %funcs;
|
|
|
|
|
|
|
|
my $custom_converters = 0;
|
|
|
|
|
|
|
|
|
|
|
|
sub outputHeader {
|
|
|
|
print <<EOF;
|
2006-08-28 03:17:39 +00:00
|
|
|
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
/*
|
|
|
|
SDL - Simple DirectMedia Layer
|
|
|
|
Copyright (C) 1997-2006 Sam Lantinga
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
Sam Lantinga
|
|
|
|
slouken\@libsdl.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SDL_config.h"
|
|
|
|
#include "SDL_audio.h"
|
|
|
|
#include "SDL_audio_c.h"
|
|
|
|
|
2006-08-28 03:17:39 +00:00
|
|
|
/* *INDENT-OFF* */
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2006-09-01 18:07:41 +00:00
|
|
|
my @vals = ( 127, 32767, 2147483647 );
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
foreach (@vals) {
|
|
|
|
my $val = $_;
|
|
|
|
my $fval = 1.0 / $val;
|
|
|
|
print("#define DIVBY${val} ${fval}f\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
|
2006-08-28 03:17:39 +00:00
|
|
|
sub outputFooter {
|
|
|
|
print <<EOF;
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|
|
|
|
EOF
|
|
|
|
}
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
|
|
|
|
sub splittype {
|
|
|
|
my $t = shift;
|
|
|
|
my ($signed, $size, $endian) = $t =~ /([USF])(\d+)([LM]SB|)/;
|
|
|
|
my $float = ($signed eq 'F') ? 1 : 0;
|
|
|
|
$signed = (($float) or ($signed eq 'S')) ? 1 : 0;
|
|
|
|
$endian = 'NONE' if ($endian eq '');
|
|
|
|
|
|
|
|
my $ctype = '';
|
|
|
|
if ($float) {
|
|
|
|
$ctype = (($size == 32) ? 'float' : 'double');
|
|
|
|
} else {
|
|
|
|
$ctype = (($signed) ? 'S' : 'U') . "int${size}";
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($signed, $float, $size, $endian, $ctype);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub getSwapFunc {
|
|
|
|
my ($size, $signed, $float, $endian, $val) = @_;
|
|
|
|
my $BEorLE = (($endian eq 'MSB') ? 'BE' : 'LE');
|
|
|
|
my $code = '';
|
|
|
|
|
|
|
|
if ($float) {
|
|
|
|
$code = "SDL_SwapFloat${BEorLE}($val)";
|
|
|
|
} else {
|
|
|
|
if ($size > 8) {
|
|
|
|
$code = "SDL_Swap${BEorLE}${size}($val)";
|
|
|
|
} else {
|
|
|
|
$code = $val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($signed) and (!$float)) {
|
|
|
|
$code = "((Sint${size}) $code)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return "${code}";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub maxIntVal {
|
2006-09-01 18:07:41 +00:00
|
|
|
my $size = shift;
|
|
|
|
if ($size == 8) {
|
|
|
|
return 0x7F;
|
|
|
|
} elsif ($size == 16) {
|
|
|
|
return 0x7FFF;
|
|
|
|
} elsif ($size == 32) {
|
|
|
|
return 0x7FFFFFFF;
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
die("bug in script.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub getFloatToIntMult {
|
2006-09-01 18:07:41 +00:00
|
|
|
my $size = shift;
|
|
|
|
my $val = maxIntVal($size) . '.0';
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
$val .= 'f' if ($size < 32);
|
|
|
|
return $val;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub getIntToFloatDivBy {
|
2006-09-01 18:07:41 +00:00
|
|
|
my $size = shift;
|
|
|
|
return 'DIVBY' . maxIntVal($size);
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub getSignFlipVal {
|
|
|
|
my $size = shift;
|
|
|
|
if ($size == 8) {
|
|
|
|
return '0x80';
|
|
|
|
} elsif ($size == 16) {
|
|
|
|
return '0x8000';
|
|
|
|
} elsif ($size == 32) {
|
|
|
|
return '0x80000000';
|
|
|
|
}
|
|
|
|
|
|
|
|
die("bug in script.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub buildCvtFunc {
|
|
|
|
my ($from, $to) = @_;
|
|
|
|
my ($fsigned, $ffloat, $fsize, $fendian, $fctype) = splittype($from);
|
|
|
|
my ($tsigned, $tfloat, $tsize, $tendian, $tctype) = splittype($to);
|
|
|
|
my $diffs = 0;
|
|
|
|
$diffs++ if ($fsize != $tsize);
|
|
|
|
$diffs++ if ($fsigned != $tsigned);
|
|
|
|
$diffs++ if ($ffloat != $tfloat);
|
|
|
|
$diffs++ if ($fendian ne $tendian);
|
|
|
|
|
|
|
|
return if ($diffs == 0);
|
|
|
|
|
|
|
|
my $hashid = "$from/$to";
|
|
|
|
if (1) { # !!! FIXME: if ($diffs > 1) {
|
|
|
|
my $sym = "SDL_Convert_${from}_to_${to}";
|
|
|
|
$funcs{$hashid} = $sym;
|
|
|
|
$custom_converters++;
|
|
|
|
|
|
|
|
# Always unsigned for ints, for possible byteswaps.
|
|
|
|
my $srctype = (($ffloat) ? 'float' : "Uint${fsize}");
|
|
|
|
|
|
|
|
print <<EOF;
|
|
|
|
static void SDLCALL
|
|
|
|
${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const $srctype *src;
|
|
|
|
$tctype *dst;
|
|
|
|
|
|
|
|
#ifdef DEBUG_CONVERT
|
|
|
|
fprintf(stderr, "Converting AUDIO_${from} to AUDIO_${to}.\\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
if ($fsize < $tsize) {
|
|
|
|
my $mult = $tsize / $fsize;
|
|
|
|
print <<EOF;
|
|
|
|
src = (const $srctype *) (cvt->buf + cvt->len_cvt);
|
|
|
|
dst = ($tctype *) (cvt->buf + cvt->len_cvt * $mult);
|
|
|
|
for (i = cvt->len_cvt / sizeof ($srctype); i; --i, --src, --dst) {
|
|
|
|
EOF
|
|
|
|
} else {
|
|
|
|
print <<EOF;
|
|
|
|
src = (const $srctype *) cvt->buf;
|
|
|
|
dst = ($tctype *) cvt->buf;
|
|
|
|
for (i = cvt->len_cvt / sizeof ($srctype); i; --i, ++src, ++dst) {
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
# Have to convert to/from float/int.
|
|
|
|
# !!! FIXME: cast through double for int32<->float?
|
|
|
|
my $code = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, '*src');
|
|
|
|
if ($ffloat != $tfloat) {
|
|
|
|
if ($ffloat) {
|
2006-09-01 18:07:41 +00:00
|
|
|
my $mult = getFloatToIntMult($tsize);
|
|
|
|
if (!$tsigned) { # bump from -1.0f/1.0f to 0.0f/2.0f
|
|
|
|
$code = "($code + 1.0f)";
|
|
|
|
}
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
$code = "(($tctype) ($code * $mult))";
|
|
|
|
} else {
|
|
|
|
# $divby will be the reciprocal, to avoid pipeline stalls
|
|
|
|
# from floating point division...so multiply it.
|
2006-09-01 18:07:41 +00:00
|
|
|
my $divby = getIntToFloatDivBy($fsize);
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
$code = "(((float) $code) * $divby)";
|
2006-09-01 18:07:41 +00:00
|
|
|
if (!$fsigned) { # bump from 0.0f/2.0f to -1.0f/1.0f.
|
|
|
|
$code = "($code - 1.0f)";
|
|
|
|
}
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# All integer conversions here.
|
|
|
|
if ($fsigned != $tsigned) {
|
|
|
|
my $signflipval = getSignFlipVal($fsize);
|
|
|
|
$code = "(($code) ^ $signflipval)";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $shiftval = abs($fsize - $tsize);
|
|
|
|
if ($fsize < $tsize) {
|
|
|
|
$code = "((($tctype) $code) << $shiftval)";
|
|
|
|
} elsif ($fsize > $tsize) {
|
|
|
|
$code = "(($tctype) ($code >> $shiftval))";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $swap = getSwapFunc($tsize, $tsigned, $tfloat, $tendian, 'val');
|
|
|
|
|
|
|
|
print <<EOF;
|
|
|
|
const $tctype val = $code;
|
|
|
|
*dst = ${swap};
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
if ($fsize > $tsize) {
|
|
|
|
my $divby = $fsize / $tsize;
|
|
|
|
print(" cvt->len_cvt /= $divby;\n");
|
|
|
|
} elsif ($fsize < $tsize) {
|
|
|
|
my $mult = $tsize / $fsize;
|
|
|
|
print(" cvt->len_cvt *= $mult;\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<EOF;
|
|
|
|
format = AUDIO_$to;
|
|
|
|
if (cvt->filters[++cvt->filter_index]) {
|
|
|
|
cvt->filters[cvt->filter_index] (cvt, format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if ($fsigned != $tsigned) {
|
|
|
|
$funcs{$hashid} = 'SDL_ConvertSigned';
|
|
|
|
} elsif ($ffloat != $tfloat) {
|
|
|
|
$funcs{$hashid} = 'SDL_ConvertFloat';
|
|
|
|
} elsif ($fsize != $tsize) {
|
|
|
|
$funcs{$hashid} = 'SDL_ConvertSize';
|
|
|
|
} elsif ($fendian ne $tendian) {
|
|
|
|
$funcs{$hashid} = 'SDL_ConvertEndian';
|
|
|
|
} else {
|
|
|
|
die("error in script.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
outputHeader();
|
|
|
|
|
|
|
|
foreach (@audiotypes) {
|
|
|
|
my $from = $_;
|
|
|
|
foreach (@audiotypes) {
|
|
|
|
my $to = $_;
|
|
|
|
buildCvtFunc($from, $to);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<EOF;
|
|
|
|
const SDL_AudioTypeFilters sdl_audio_type_filters[] =
|
|
|
|
{
|
|
|
|
EOF
|
|
|
|
|
|
|
|
foreach (@audiotypes) {
|
|
|
|
my $from = $_;
|
|
|
|
foreach (@audiotypes) {
|
|
|
|
my $to = $_;
|
|
|
|
if ($from ne $to) {
|
|
|
|
my $hashid = "$from/$to";
|
|
|
|
my $sym = $funcs{$hashid};
|
|
|
|
print(" { AUDIO_$from, AUDIO_$to, $sym },\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<EOF;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2006-08-28 03:17:39 +00:00
|
|
|
outputFooter();
|
|
|
|
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
exit 0;
|
|
|
|
|
2006-08-28 03:17:39 +00:00
|
|
|
# end of sdlgenaudiocvt.pl ...
|
First shot at new audio data types (int32 and float32).
Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.
Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402029
2006-08-24 12:10:46 +00:00
|
|
|
|