├── borland.zip ├── CWProject.sit ├── PBProjects.tar.gz ├── decoders ├── libmpg123 │ ├── icy2utf8.h │ ├── README-sdlsound.txt │ ├── decode_sse.S │ ├── decode_3dnowext.S │ ├── true.h │ ├── equalizer.c │ ├── id3.h │ ├── icy.h │ ├── icy.c │ ├── dnoise.sh │ ├── parse.h │ ├── compat.c │ ├── testcpu.c │ ├── getcpuflags.h │ ├── Makefile.am │ ├── mangle.h │ ├── libmpg123.sym.in │ ├── equalizer_3dnow.S │ ├── getbits.h │ ├── index.h │ ├── getcpuflags.S │ ├── Makefile.am-original │ ├── decode.h │ ├── optimize.c │ ├── compat.h │ ├── stringbuf.c │ ├── index.c │ ├── decode_mmx.S │ ├── reader.h │ ├── layer1.c │ ├── dct64.c │ ├── mpg123lib_intern.h │ ├── tabinit.c │ ├── tabinit_mmx.S │ └── decode_sse3d.h ├── Makefile.am ├── timidity │ ├── Makefile.am │ ├── readmidi.h │ ├── instrum_dls.h │ ├── resample.h │ ├── mix.h │ ├── common.h │ ├── tables.h │ ├── Makefile.testmidi │ ├── TODO │ ├── instrum.h │ ├── playmidi.h │ ├── output.h │ ├── README │ ├── testmidi.c │ ├── output.c │ ├── CHANGES │ ├── common.c │ ├── options.h │ ├── FAQ │ ├── dls2.h │ └── timidity.h ├── midi.c └── skeleton.c ├── .gitignore ├── SDL_sound.pc.in ├── CHANGELOG.txt ├── bootstrap ├── playsound ├── Makefile.am ├── physfsrwops.h └── physfsrwops.c ├── TODO.txt ├── CREDITS.txt ├── Makefile.am ├── VisualC ├── sdl_sound.dsw ├── README.txt ├── playsound.dsp └── playsound_static.dsp ├── mixer ├── DESIGN ├── mixercore.c └── converters.c ├── README.txt ├── extra_rwops.h ├── INSTALL.txt ├── extra_rwops.c ├── filter_templates.h └── acinclude.m4 /borland.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ancurio/SDL_sound/HEAD/borland.zip -------------------------------------------------------------------------------- /CWProject.sit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ancurio/SDL_sound/HEAD/CWProject.sit -------------------------------------------------------------------------------- /PBProjects.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ancurio/SDL_sound/HEAD/PBProjects.tar.gz -------------------------------------------------------------------------------- /decoders/libmpg123/icy2utf8.h: -------------------------------------------------------------------------------- 1 | /* You expect a license plate for _this_ file? */ 2 | #ifndef MPG123_ICY2UTF_H 3 | #define MPG123_ICY2UTF_H 4 | 5 | char *icy2utf8(const char *); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /decoders/libmpg123/README-sdlsound.txt: -------------------------------------------------------------------------------- 1 | This package, according to the README, is under the LGPL, which means it uses 2 | the same license as SDL_sound. 3 | 4 | libmpg123 is part of mpg123, which can be found at http://www.mpg123.org/ ... 5 | 6 | --ryan. 7 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | *.la 4 | *.pc 5 | *.log 6 | *.status 7 | *.sub 8 | *.cache 9 | 10 | .deps 11 | .libs 12 | 13 | aclocal.m4 14 | Makefile 15 | Makefile.in 16 | configure 17 | compile 18 | config.* 19 | depcomp 20 | install-sh 21 | libtool 22 | ltmain.sh 23 | missing 24 | stamp-h1 25 | 26 | -------------------------------------------------------------------------------- /decoders/libmpg123/decode_sse.S: -------------------------------------------------------------------------------- 1 | #include "mangle.h" 2 | #define MPL_DCT64 ASM_NAME(dct64_sse) 3 | #define SYNTH_NAME ASM_NAME(synth_1to1_sse_asm) 4 | #include "decode_sse3d.h" 5 | 6 | /* Mark non-executable stack. */ 7 | #if defined(__linux__) && defined(__ELF__) 8 | .section .note.GNU-stack,"",%progbits 9 | #endif 10 | -------------------------------------------------------------------------------- /SDL_sound.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: SDL_sound 7 | Description: audio decoding library for Simple DirectMedia Layer 8 | Version: @VERSION@ 9 | Requires: sdl2 >= @SDL_VERSION@ 10 | Libs: -L${libdir} -lSDL_sound 11 | Cflags: -I${includedir}/SDL2 12 | -------------------------------------------------------------------------------- /decoders/libmpg123/decode_3dnowext.S: -------------------------------------------------------------------------------- 1 | #include "mangle.h" 2 | #define MPL_DCT64 ASM_NAME(dct64_3dnowext) 3 | #define SYNTH_NAME ASM_NAME(synth_1to1_3dnowext_asm) 4 | #include "decode_sse3d.h" 5 | 6 | /* Mark non-executable stack. */ 7 | #if defined(__linux__) && defined(__ELF__) 8 | .section .note.GNU-stack,"",%progbits 9 | #endif 10 | -------------------------------------------------------------------------------- /decoders/libmpg123/true.h: -------------------------------------------------------------------------------- 1 | /* 2 | true: a trivial truth 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org 6 | */ 7 | 8 | #ifndef MPG123_H_TRUE 9 | #define MPG123_H_TRUE 10 | 11 | #define FALSE 0 12 | #define TRUE 1 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * CHANGELOG. 3 | */ 4 | 5 | Not maintaining CHANGELOG.txt by hand any more. This is why we have revision 6 | control tools to do it for us. :) 7 | 8 | Take a look at http://hg.icculus.org/icculus/SDL_sound/ for a complete list 9 | of changes. 10 | 11 | --ryan. (icculus@icculus.org) 12 | 13 | /* end of CHANGELOG.txt ... */ 14 | 15 | -------------------------------------------------------------------------------- /decoders/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libdecoders.la 2 | 3 | SUBDIRS = timidity libmpg123 4 | 5 | INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/decoders/timidity 6 | 7 | libdecoders_la_SOURCES = \ 8 | aiff.c \ 9 | au.c \ 10 | mikmod.c \ 11 | modplug.c \ 12 | mpg123.c \ 13 | ogg.c \ 14 | raw.c \ 15 | shn.c \ 16 | voc.c \ 17 | midi.c \ 18 | flac.c \ 19 | speex.c \ 20 | coreaudio.c \ 21 | wav.c 22 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | echo "Initial preparation...this can take awhile, so sit tight..." 5 | aclocal 6 | 7 | # MacOS X renames GNU libtool to "glibtool", since they have something 8 | # else called "libtool" already... 9 | if $(which glibtoolize); then 10 | glibtoolize --automake --copy --force 11 | else 12 | libtoolize --automake --copy --force 13 | fi 14 | 15 | autoheader 16 | automake --foreign --add-missing --copy 17 | autoconf 18 | 19 | echo "You are now ready to run ./configure ..." 20 | 21 | -------------------------------------------------------------------------------- /decoders/libmpg123/equalizer.c: -------------------------------------------------------------------------------- 1 | /* 2 | equalizer.c: equalizer settings 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | */ 8 | 9 | 10 | #include "mpg123lib_intern.h" 11 | 12 | void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]) 13 | { 14 | int i; 15 | for(i=0;i<32;i++) 16 | bandPtr[i] = REAL_MUL(bandPtr[i], equalizer[channel][i]); 17 | } 18 | -------------------------------------------------------------------------------- /playsound/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = playsound playsound_simple 2 | 3 | INCLUDES = -I$(top_srcdir) 4 | 5 | if USE_PHYSICSFS 6 | PHYSFS_CFLG = -DSUPPORT_PHYSFS=1 7 | PHYSFS_LIBS = -lphysfs 8 | else 9 | PHYSFS_CFLG = 10 | PHYSFS_SRCS = 11 | PHYSFS_LIBS = 12 | endif 13 | 14 | playsound_CFLAGS = $(PHYSFS_CFLG) 15 | playsound_LDADD = ../libSDL_sound.la $(PHYSFS_LIBS) 16 | playsound_SOURCES = playsound.c physfsrwops.c physfsrwops.h 17 | 18 | playsound_simple_LDADD = ../libSDL_sound.la 19 | playsound_simple_SOURCES = playsound_simple.c 20 | 21 | -------------------------------------------------------------------------------- /decoders/libmpg123/id3.h: -------------------------------------------------------------------------------- 1 | /* 2 | id3: ID3v2.3 and ID3v2.4 parsing (a relevant subset) 3 | 4 | copyright 2006-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #ifndef MPG123_ID3_H 10 | #define MPG123_ID3_H 11 | 12 | /* really need it _here_! */ 13 | #include "frame.h" 14 | 15 | void init_id3(mpg123_handle *fr); 16 | void exit_id3(mpg123_handle *fr); 17 | void reset_id3(mpg123_handle *fr); 18 | int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes); 19 | void id3_link(mpg123_handle *fr); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /decoders/timidity/Makefile.am: -------------------------------------------------------------------------------- 1 | if USE_TIMIDITY 2 | noinst_LTLIBRARIES = libtimidity.la 3 | endif 4 | 5 | INCLUDES = -I$(top_srcdir) 6 | 7 | libtimidity_la_SOURCES = \ 8 | common.c \ 9 | common.h \ 10 | dls1.h \ 11 | dls2.h \ 12 | instrum.c \ 13 | instrum.h \ 14 | instrum_dls.c \ 15 | instrum_dls.h \ 16 | mix.c \ 17 | mix.h \ 18 | options.h \ 19 | output.c \ 20 | output.h \ 21 | playmidi.c \ 22 | playmidi.h \ 23 | readmidi.c \ 24 | readmidi.h \ 25 | resample.c \ 26 | resample.h \ 27 | tables.c \ 28 | tables.h \ 29 | timidity.c \ 30 | timidity.h 31 | 32 | EXTRA_DIST = CHANGES COPYING FAQ README TODO Makefile.testmidi testmidi.c 33 | 34 | -------------------------------------------------------------------------------- /decoders/libmpg123/icy.h: -------------------------------------------------------------------------------- 1 | /* 2 | icy: support for SHOUTcast ICY meta info, an attempt to keep it organized 3 | 4 | copyright 2006-7 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis and modelled after patch by Honza 7 | */ 8 | #ifndef MPG123_ICY_H 9 | #define MPG123_ICY_H 10 | 11 | #include "compat.h" 12 | #include "mpg123.h" 13 | 14 | struct icy_meta 15 | { 16 | char* data; 17 | off_t interval; 18 | off_t next; 19 | }; 20 | 21 | void init_icy(struct icy_meta *); 22 | void clear_icy(struct icy_meta *); 23 | void reset_icy(struct icy_meta *); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /decoders/libmpg123/icy.c: -------------------------------------------------------------------------------- 1 | /* 2 | icy: Puny code to pretend for a serious ICY data structure. 3 | 4 | copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include "icy.h" 10 | 11 | void init_icy(struct icy_meta *icy) 12 | { 13 | icy->data = NULL; 14 | } 15 | 16 | void clear_icy(struct icy_meta *icy) 17 | { 18 | if(icy->data != NULL) free(icy->data); 19 | init_icy(icy); 20 | } 21 | 22 | void reset_icy(struct icy_meta *icy) 23 | { 24 | clear_icy(icy); 25 | init_icy(icy); 26 | } 27 | /*void set_icy(struct icy_meta *icy, char* new_data) 28 | { 29 | if(icy->data) free(icy->data); 30 | icy->data = new_data; 31 | icy->changed = 1; 32 | }*/ 33 | -------------------------------------------------------------------------------- /decoders/libmpg123/dnoise.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A script to generate dnoise.c from a plain text file with the noise numbers. 4 | # In future, the plain text file (or a binary version) may be used by mpg123 at runtime instead of compiling it in. 5 | 6 | # copyright 2006-8 by the mpg123 project - free software under the terms of the LGPL 2.1 7 | # initially written by Thomas Orgis 8 | 9 | echo '/* 10 | dnoise: Noise for dithered output. 11 | 12 | copyright 2006-8 by the mpg123 project - free software under the terms of the LGPL 2.1 13 | see COPYING and AUTHORS files in distribution or http://mpg123.org 14 | initially written by (in assembler) Adrian Bacon 15 | */ 16 | 17 | float dithernoise[65536] = 18 | {' 19 | 20 | # If sed is there, use it. 21 | if echo -n | sed ''; then 22 | sed -e 's/$/f,/' < "$1" 23 | else 24 | # Plain sh... very slow, but works. 25 | while read i 26 | do 27 | echo "${i}f," 28 | done < "$1" 29 | fi 30 | 31 | echo '};'; 32 | -------------------------------------------------------------------------------- /decoders/timidity/readmidi.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | readmidi.h 21 | 22 | */ 23 | 24 | extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp); 25 | -------------------------------------------------------------------------------- /decoders/timidity/instrum_dls.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | instrum.h 21 | 22 | */ 23 | 24 | extern Instrument *load_instrument_dls(MidiSong *song, int drum, int bank, int instrument); 25 | -------------------------------------------------------------------------------- /decoders/timidity/resample.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | resample.h 21 | */ 22 | 23 | extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr); 24 | extern void pre_resample(MidiSong *song, Sample *sp); 25 | -------------------------------------------------------------------------------- /decoders/libmpg123/parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | parse: spawned from common; clustering around stream/frame parsing 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp & Thomas Orgis 7 | */ 8 | 9 | #ifndef MPG123_PARSE_H 10 | #define MPG123_PARSE_H 11 | 12 | #include "frame.h" 13 | 14 | int read_frame_init(mpg123_handle* fr); 15 | int frame_bitrate(mpg123_handle *fr); 16 | long frame_freq(mpg123_handle *fr); 17 | int read_frame_recover(mpg123_handle* fr); /* dead? */ 18 | int read_frame(mpg123_handle *fr); 19 | void set_pointer(mpg123_handle *fr, long backstep); 20 | int position_info(mpg123_handle* fr, unsigned long no, long buffsize, unsigned long* frames_left, double* current_seconds, double* seconds_left); 21 | double compute_bpf(mpg123_handle *fr); 22 | long time_to_frame(mpg123_handle *fr, double seconds); 23 | int get_songlen(mpg123_handle *fr,int no); 24 | off_t samples_to_bytes(mpg123_handle *fr , off_t s); 25 | off_t bytes_to_samples(mpg123_handle *fr , off_t b); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | More immediate: 2 | - Fix the crappy rewind implementation in shn.c's SHN_rewind(). 3 | - Finish implementing seek() method in decoders, see below. 4 | - Add a sdlsound-config script? 5 | - Make sure we can build shared libs on Cygwin, BeOS, Mac OS X... 6 | - Move to CMake 7 | - Up default optimizations to -O3? 8 | 9 | Decoders still needing seek() method: 10 | (If decoder can't seek, clean up the stub and report an error.) 11 | - mikmod.c 12 | - shn.c 13 | - quicktime.c 14 | 15 | General stuff TODO: 16 | - Hack on the experimental audio conversion routines. 17 | - Add the altivec-optimized libvorbis to the project? 18 | - Handle compression and other chunks in WAV files. 19 | - Handle compression and other chunks in AIFF-C files. 20 | - Reduce malloc() pressure. 21 | - Maybe allow an external allocator? 22 | 23 | Quicktime stuff that'd be cool, but isn't crucial: 24 | - Integrate decoders/quicktime.c with build system (for OS X)? 25 | - Make decoders/quicktime.c more robust. 26 | - Make decoders/quicktime.c work on win32? 27 | - There's no seek() method. 28 | 29 | Ongoing: 30 | - look for "FIXME"s in the code. 31 | 32 | /* end of TODO ... */ 33 | 34 | -------------------------------------------------------------------------------- /decoders/libmpg123/compat.c: -------------------------------------------------------------------------------- 1 | /* 2 | compat: Some compatibility functions. Basic standard C stuff, that may barely be above/around C89. 3 | 4 | The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX. 5 | 6 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 7 | see COPYING and AUTHORS files in distribution or http://mpg123.org 8 | initially written by Thomas Orgis 9 | */ 10 | 11 | #include "config.h" 12 | #include "compat.h" 13 | 14 | /* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */ 15 | void *safe_realloc(void *ptr, size_t size) 16 | { 17 | if(ptr == NULL) return malloc(size); 18 | else return realloc(ptr, size); 19 | } 20 | 21 | #ifndef HAVE_STRERROR 22 | const char *strerror(int errnum) 23 | { 24 | extern int sys_nerr; 25 | extern char *sys_errlist[]; 26 | 27 | return (errnum < sys_nerr) ? sys_errlist[errnum] : ""; 28 | } 29 | #endif 30 | 31 | #ifndef HAVE_STRDUP 32 | char *strdup(const char *src) 33 | { 34 | char *dest; 35 | 36 | if (!(dest = (char *) malloc(strlen(src)+1))) 37 | return NULL; 38 | else 39 | return strcpy(dest, src); 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /decoders/timidity/mix.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | In case you haven't heard, this program is free software; 7 | you can redistribute it and/or modify it under the terms of the 8 | GNU General Public License as published by the Free Software 9 | Foundation; either version 2 of the License, or (at your option) 10 | any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | 21 | mix.h 22 | 23 | */ 24 | 25 | extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c); 26 | extern int recompute_envelope(MidiSong *song, int v); 27 | extern void apply_envelope_to_amp(MidiSong *song, int v); 28 | -------------------------------------------------------------------------------- /decoders/libmpg123/testcpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | testcpu: standalone CPU flags tester 3 | 4 | copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include 10 | #include "getcpuflags.h" 11 | 12 | int main() 13 | { 14 | int family; 15 | struct cpuflags flags; 16 | if(!getcpuflags(&flags)){ printf("CPU won't do cpuid (some old i386 or i486)\n"); return 0; } 17 | family = (flags.id & 0xf00)>>8; 18 | printf("family: %i\n", family); 19 | printf("stdcpuflags: 0x%08x\n", flags.std); 20 | printf("std2cpuflags: 0x%08x\n", flags.std2); 21 | printf("extcpuflags: 0x%08x\n", flags.ext); 22 | if(cpu_i586(flags)) 23 | { 24 | printf("A i586 or better cpu with:"); 25 | if(cpu_mmx(flags)) printf(" mmx"); 26 | if(cpu_3dnow(flags)) printf(" 3dnow"); 27 | if(cpu_3dnowext(flags)) printf(" 3dnowext"); 28 | if(cpu_sse(flags)) printf(" sse"); 29 | if(cpu_sse2(flags)) printf(" sse2"); 30 | if(cpu_sse3(flags)) printf(" sse3"); 31 | printf("\n"); 32 | } 33 | else printf("I guess you have some i486\n"); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /decoders/timidity/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | common.h 22 | */ 23 | 24 | typedef struct { 25 | char *path; 26 | void *next; 27 | } PathList; 28 | 29 | extern SDL_RWops *open_file(char *name); 30 | extern void add_to_pathlist(char *s); 31 | extern void *safe_malloc(size_t count); 32 | extern void free_pathlist(void); 33 | -------------------------------------------------------------------------------- /decoders/timidity/tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | tables.h 21 | */ 22 | 23 | #include 24 | #define sine(x) (sin((2*PI/1024.0) * (x))) 25 | 26 | #define SINE_CYCLE_LENGTH 1024 27 | extern const Sint32 freq_table[]; 28 | extern const double vol_table[]; 29 | extern const double bend_fine[]; 30 | extern const double bend_coarse[]; 31 | -------------------------------------------------------------------------------- /CREDITS.txt: -------------------------------------------------------------------------------- 1 | ---------------------- 2 | | SDL_sound credits. | 3 | ---------------------- 4 | 5 | Initial API interface and implementation, 6 | RAW driver, 7 | VOC driver, 8 | MPG123 driver, 9 | WAV driver, 10 | OGG driver, 11 | SHN driver, 12 | Unix support, 13 | BeOS support: 14 | Ryan C. Gordon 15 | 16 | Bug fixes, 17 | FreeBSD testing: 18 | Tsuyoshi Iguchi 19 | 20 | Code cleanups and fixes, 21 | AIFF driver, 22 | MikMod driver, 23 | MIDI driver, 24 | ModPlug driver, 25 | FLAC driver: 26 | Torbjörn Andersson 27 | 28 | autoconf, 29 | MacOS X support: 30 | Max Horn 31 | 32 | win32 support, 33 | PocketPC support, 34 | other fixes: 35 | Tyler Montbriand 36 | 37 | AU driver, 38 | Mattias Engdegård 39 | 40 | MacOS Classic support, 41 | quicktime decoder, 42 | OS X fixes: 43 | Darrell Walisser 44 | 45 | Alternate audio conversion code: 46 | Frank Ranostaj 47 | 48 | Initial Borland C++ project files: 49 | Dominique Louis 50 | 51 | Bugfixes and stuff: 52 | Eric Wing 53 | 54 | FLAC 1.1.3 updates: 55 | Josh Coalson 56 | 57 | Fixes: 58 | Chris Nelson 59 | 60 | Fixes: 61 | Ozkan Sezer 62 | 63 | Other stuff: 64 | Your name here! Patches go to icculus@icculus.org ... 65 | 66 | /* end of CREDITS ... */ 67 | 68 | -------------------------------------------------------------------------------- /decoders/timidity/Makefile.testmidi: -------------------------------------------------------------------------------- 1 | # Silly test makefile 2 | 3 | CC = gcc 4 | 5 | # Standard SDL_sound debugging 6 | CFLAGS = -g -I../.. -ansi -pedantic -Wall `sdl-config --cflags` -DDEBUG_CHATTER 7 | LIBS = `sdl-config --libs` 8 | 9 | # Electric Fence debugging 10 | # CFLAGS = -g -I../.. -ansi -pedantic -Wall `sdl-config --cflags` 11 | # LIBS = `sdl-config --libs` -lefence 12 | 13 | OBJECTS = common.o instrum.o mix.o output.o playmidi.o readmidi.o resample.o \ 14 | tables.o timidity.o testmidi.o 15 | 16 | all: testmidi 17 | 18 | testmidi: $(OBJECTS) 19 | $(CC) $(OBJECTS) $(CFLAGS) -o testmidi $(LIBS) 20 | 21 | clean: 22 | $(RM) testmidi *.o *~ 23 | 24 | common.o: common.c options.h common.h 25 | instrum.o: instrum.c timidity.h options.h common.h instrum.h resample.h \ 26 | tables.h 27 | mix.o: mix.c timidity.h options.h instrum.h playmidi.h output.h tables.h \ 28 | resample.h mix.h 29 | output.o: output.c options.h output.h 30 | playmidi.o: playmidi.c timidity.h options.h instrum.h playmidi.h output.h \ 31 | mix.h tables.h 32 | readmidi.o: readmidi.c timidity.h common.h instrum.h playmidi.h 33 | resample.o: resample.c timidity.h options.h common.h instrum.h playmidi.h \ 34 | tables.h resample.h 35 | tables.o: tables.c tables.h 36 | testmidi.o: testmidi.c common.h timidity.h 37 | timidity.o: timidity.c options.h common.h instrum.h playmidi.h readmidi.h \ 38 | output.h timidity.h tables.h 39 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libSDL_sound.la 2 | 3 | SUBDIRS = decoders . 4 | 5 | libSDL_soundincludedir = $(includedir)/SDL2 6 | libSDL_soundinclude_HEADERS = \ 7 | SDL_sound.h 8 | 9 | libSDL_sound_la_SOURCES = \ 10 | SDL_sound.c \ 11 | SDL_sound_internal.h \ 12 | audio_convert.c \ 13 | extra_rwops.c \ 14 | extra_rwops.h 15 | 16 | if USE_TIMIDITY 17 | TIMIDITY_LIB = decoders/timidity/libtimidity.la 18 | else 19 | TIMIDITY_LIB = 20 | endif 21 | 22 | if USE_LIBMPG123 23 | MPG123_LIB = decoders/libmpg123/libmpg123.la 24 | else 25 | MPG123_LIB = 26 | endif 27 | 28 | libSDL_sound_la_LDFLAGS = \ 29 | -release $(LT_RELEASE) \ 30 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ 31 | -no-undefined 32 | libSDL_sound_la_LIBADD = \ 33 | decoders/libdecoders.la \ 34 | $(TIMIDITY_LIB) $(MPG123_LIB) 35 | 36 | EXTRA_DIST = \ 37 | CREDITS \ 38 | COPYING \ 39 | CHANGELOG \ 40 | CWProject.sit \ 41 | PBProjects.tar.gz \ 42 | borland.zip \ 43 | Doxyfile \ 44 | VisualC 45 | 46 | dist-hook: 47 | mkdir $(distdir)/docs 48 | echo "Docs are generated with the program "Doxygen" (http://www.doxygen.org/)," >> $(distdir)/docs/README 49 | echo " or can be read online at http://icculus.org/SDL_sound/docs/" >> $(distdir)/docs/README 50 | echo >> $(distdir)/docs/README 51 | rm -rf `find $(distdir) -type d -name ".svn"` 52 | 53 | pkgconfigdir = $(libdir)/pkgconfig 54 | pkgconfig_DATA = SDL_sound.pc 55 | -------------------------------------------------------------------------------- /VisualC/sdl_sound.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "playsound"=".\playsound.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "playsound_static"=".\playsound_static.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "sdl_sound_dll"=".\sdl_sound_dll.dsp" - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "sdl_sound_static"=".\sdl_sound_static.dsp" - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | Global: 55 | 56 | Package=<5> 57 | {{{ 58 | }}} 59 | 60 | Package=<3> 61 | {{{ 62 | }}} 63 | 64 | ############################################################################### 65 | 66 | -------------------------------------------------------------------------------- /decoders/timidity/TODO: -------------------------------------------------------------------------------- 1 | * I don't like the indentation style at all, but for the most part 2 | I've left it alone. 3 | 4 | * Much of the code looks ugly to me. 5 | 6 | * The return value from SDL_RWread() is checked inconsistenly. 7 | 8 | * Group the members of MidiSong into logical units, i.e. structs? 9 | 10 | * The debug messages are probably a bit too noisy. I've removed one 11 | particularly annoying one, but... 12 | 13 | Some of them should be turned into error messages instead. 14 | 15 | * Can the instrument handling be made more efficient? At the moment 16 | different MidiSongs may separately load the same instrument. 17 | 18 | Note that the MidiSong's audio format affects how the instrument is 19 | loaded, so it's not as easy as just letting all MidiSongs share tone 20 | and drum banks. 21 | 22 | At the moment they do share the data that is simply read from the 23 | config file, but that's just a quick hack to avoid having to read 24 | the config file every time a MIDI song is loaded. 25 | 26 | * Check if any of MidiStruct's members can safely be made into static 27 | globals again. 28 | 29 | * TiMidity++ adds a number of undocumented (?) extensions to the 30 | configuration syntax. These are not implemented here. In particular, 31 | the "map" keyword used by the "eawpats". 32 | 33 | * The other decoders generally only read as much of the file as is 34 | necessary. Could we do that in this decoder as well? (Currently it 35 | seems to convert the entire file into MIDI events first.) 36 | 37 | * Can it be optimized? 38 | -------------------------------------------------------------------------------- /decoders/timidity/instrum.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | instrum.h 21 | 22 | */ 23 | 24 | /* Bits in modes: */ 25 | #define MODES_16BIT (1<<0) 26 | #define MODES_UNSIGNED (1<<1) 27 | #define MODES_LOOPING (1<<2) 28 | #define MODES_PINGPONG (1<<3) 29 | #define MODES_REVERSE (1<<4) 30 | #define MODES_SUSTAIN (1<<5) 31 | #define MODES_ENVELOPE (1<<6) 32 | 33 | /* A hack to delay instrument loading until after reading the 34 | entire MIDI file. */ 35 | #define MAGIC_LOAD_INSTRUMENT ((Instrument *) (-1)) 36 | 37 | #define SPECIAL_PROGRAM -1 38 | 39 | extern int load_missing_instruments(MidiSong *song); 40 | extern void free_instruments(MidiSong *song); 41 | extern int set_default_instrument(MidiSong *song, char *name); 42 | -------------------------------------------------------------------------------- /decoders/libmpg123/getcpuflags.h: -------------------------------------------------------------------------------- 1 | /* 2 | getcpucpuflags: get cpuflags for ia32 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org 6 | initially written by KIMURA Takuhiro (for 3DNow!) 7 | extended for general use by Thomas Orgis 8 | */ 9 | 10 | #ifndef MPG123_H_GETCPUFLAGS 11 | #define MPG123_H_GETCPUFLAGS 12 | 13 | /* standard level flags part 1 (ECX)*/ 14 | #define FLAG_SSE3 0x00000001 15 | 16 | /* standard level flags part 2 (EDX) */ 17 | #define FLAG2_MMX 0x00800000 18 | #define FLAG2_SSE 0x02000000 19 | #define FLAG2_SSE2 0x04000000 20 | #define FLAG2_FPU 0x00000001 21 | /* cpuid extended level 1 (AMD) */ 22 | #define XFLAG_MMX 0x00800000 23 | #define XFLAG_3DNOW 0x80000000 24 | #define XFLAG_3DNOWEXT 0x40000000 25 | 26 | struct cpuflags 27 | { 28 | unsigned int id; 29 | unsigned int std; 30 | unsigned int std2; 31 | unsigned int ext; 32 | }; 33 | 34 | extern struct cpuflags cpu_flags; 35 | 36 | unsigned int getcpuflags(struct cpuflags* cf); 37 | 38 | /* checks the family */ 39 | #define cpu_i586(s) ( ((s.id & 0xf00)>>8) == 0 || ((s.id & 0xf00)>>8) > 4 ) 40 | /* checking some flags... */ 41 | #define cpu_fpu(s) (FLAG2_FPU & s.std2) 42 | #define cpu_mmx(s) (FLAG2_MMX & s.std2 || XFLAG_MMX & s.ext) 43 | #define cpu_3dnow(s) (XFLAG_3DNOW & s.ext) 44 | #define cpu_3dnowext(s) (XFLAG_3DNOWEXT & s.ext) 45 | #define cpu_sse(s) (FLAG2_SSE & s.std2) 46 | #define cpu_sse2(s) (FLAG2_SSE2 & s.std2) 47 | #define cpu_sse3(s) (FLAG_SSE3 & s.std) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /decoders/libmpg123/Makefile.am: -------------------------------------------------------------------------------- 1 | if USE_LIBMPG123 2 | noinst_LTLIBRARIES = libmpg123.la 3 | endif 4 | 5 | # !!! FIXME: get MMX/SSE/Altivec/etc stuff in here. 6 | 7 | INCLUDES = -I$(top_srcdir)/decodes/libmpg123 8 | libmpg123_la_CFLAGS = -DOPT_GENERIC -DREAL_IS_FLOAT -DMPG123_NO_CONFIGURE 9 | 10 | libmpg123_la_SOURCES = \ 11 | compat.c \ 12 | compat.h \ 13 | parse.c \ 14 | parse.h \ 15 | frame.c \ 16 | format.c \ 17 | frame.h \ 18 | reader.h \ 19 | debug.h \ 20 | decode.h \ 21 | decode_2to1.c \ 22 | decode_4to1.c \ 23 | decode_ntom.c \ 24 | equalizer.c \ 25 | huffman.h \ 26 | icy.c \ 27 | icy.h \ 28 | icy2utf8.c \ 29 | icy2utf8.h \ 30 | id3.c \ 31 | id3.h \ 32 | true.h \ 33 | l2tables.h \ 34 | layer1.c \ 35 | layer2.c \ 36 | layer3.c \ 37 | getbits.h \ 38 | optimize.h \ 39 | optimize.c \ 40 | readers.c \ 41 | tabinit.c \ 42 | stringbuf.c \ 43 | libmpg123.c \ 44 | mpg123lib_intern.h \ 45 | mangle.h \ 46 | getcpuflags.h \ 47 | index.h \ 48 | index.c \ 49 | mpg123.h \ 50 | config.h \ 51 | dct64.c \ 52 | decode.c \ 53 | libmpg123.sym 54 | 55 | EXTRA_libmpg123_la_SOURCES = \ 56 | dct36_3dnowext.S \ 57 | dct36_3dnow.S \ 58 | dct64_3dnowext.S \ 59 | dct64_3dnow.S \ 60 | dct64_altivec.c \ 61 | dct64_i386.c \ 62 | dct64_i486.c \ 63 | dct64_mmx.S \ 64 | dct64_sse.S \ 65 | decode_3dnowext.S \ 66 | decode_3dnow.S \ 67 | decode_altivec.c \ 68 | decode_i386.c \ 69 | decode_i486.c \ 70 | decode_i586_dither.S \ 71 | decode_i586.S \ 72 | decode_mmx.S \ 73 | decode_sse3d.h \ 74 | decode_sse.S \ 75 | equalizer_3dnow.S \ 76 | tabinit_mmx.S \ 77 | getcpuflags.S 78 | 79 | EXTRA_DIST = mpg123.h.in dnoise.sh dnoise.dat testcpu.c README-sdlsound.txt 80 | 81 | -------------------------------------------------------------------------------- /decoders/libmpg123/mangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | mangle: support defines for preprocessed assembler 3 | 4 | copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | 7 | This once started out as mangle.h from MPlayer, but you can't really call it derived work... the small part that in principle stems from MPlayer also being not very special (once you decided to use such a header at all, it's quite obvious material). 8 | */ 9 | 10 | #ifndef __MANGLE_H 11 | #define __MANGLE_H 12 | 13 | #include "config.h" 14 | 15 | #ifdef CCALIGN 16 | #define MOVUAPS movaps 17 | #else 18 | #define MOVUAPS movups 19 | #endif 20 | 21 | #ifdef ASMALIGN_EXP 22 | #define ALIGN4 .align 2 23 | #define ALIGN8 .align 3 24 | #define ALIGN16 .align 4 25 | #define ALIGN32 .align 5 26 | #else 27 | #define ALIGN4 .align 4 28 | #define ALIGN8 .align 8 29 | #define ALIGN16 .align 16 30 | #define ALIGN32 .align 32 31 | #endif 32 | 33 | /* Feel free to add more to the list, eg. a.out IMO */ 34 | #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__OS2__) || \ 35 | (defined(__OpenBSD__) && !defined(__ELF__)) || defined(__APPLE__) 36 | #define MANGLE(a) "_" #a 37 | #define ASM_NAME(a) _##a 38 | #define ASM_VALUE(a) $_##a 39 | #else 40 | #define MANGLE(a) #a 41 | #define ASM_NAME(a) a 42 | #define ASM_VALUE(a) "$" #a 43 | #endif 44 | 45 | #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__) 46 | #define COMM(a,b,c) .comm a,b 47 | #else 48 | #define COMM(a,b,c) .comm a,b,c 49 | #endif 50 | /* more hacks for macosx; no .bss ... */ 51 | #ifdef __APPLE__ 52 | #define BSS .data 53 | #else 54 | #define BSS .bss 55 | #endif 56 | #endif /* !__MANGLE_H */ 57 | 58 | -------------------------------------------------------------------------------- /decoders/libmpg123/libmpg123.sym.in: -------------------------------------------------------------------------------- 1 | mpg123_init 2 | mpg123_exit 3 | mpg123_new 4 | mpg123_delete 5 | mpg123_param 6 | mpg123_getparam 7 | mpg123_plain_strerror 8 | mpg123_strerror 9 | mpg123_errcode 10 | mpg123_decoders 11 | mpg123_supported_decoders 12 | mpg123_decoder 13 | mpg123_rates 14 | mpg123_encodings 15 | mpg123_format_none 16 | mpg123_format_all 17 | mpg123_format 18 | mpg123_format_support 19 | mpg123_getformat 20 | mpg123_open_feed 21 | mpg123_close 22 | mpg123_read 23 | mpg123_feed 24 | mpg123_decode 25 | mpg123_eq 26 | mpg123_geteq 27 | mpg123_reset_eq 28 | mpg123_volume 29 | mpg123_volume_change 30 | mpg123_getvolume 31 | mpg123_info 32 | mpg123_safe_buffer 33 | mpg123_scan 34 | mpg123_tpf 35 | mpg123_clip 36 | mpg123_getstate 37 | mpg123_init_string 38 | mpg123_free_string 39 | mpg123_resize_string 40 | mpg123_grow_string 41 | mpg123_copy_string 42 | mpg123_add_string 43 | mpg123_add_substring 44 | mpg123_set_string 45 | mpg123_set_substring 46 | mpg123_meta_check 47 | mpg123_id3 48 | mpg123_icy 49 | mpg123_icy2utf8 50 | mpg123_parnew 51 | mpg123_new_pars 52 | mpg123_delete_pars 53 | mpg123_fmt_none 54 | mpg123_fmt_all 55 | mpg123_fmt 56 | mpg123_fmt_support 57 | mpg123_par 58 | mpg123_getpar 59 | mpg123_replace_buffer 60 | mpg123_outblock 61 | mpg123_replace_reader 62 | mpg123_open@LARGEFILE_SUFFIX@ 63 | mpg123_open_fd@LARGEFILE_SUFFIX@ 64 | mpg123_decode_frame@LARGEFILE_SUFFIX@ 65 | mpg123_tell@LARGEFILE_SUFFIX@ 66 | mpg123_tellframe@LARGEFILE_SUFFIX@ 67 | mpg123_tell_stream@LARGEFILE_SUFFIX@ 68 | mpg123_seek@LARGEFILE_SUFFIX@ 69 | mpg123_feedseek@LARGEFILE_SUFFIX@ 70 | mpg123_seek_frame@LARGEFILE_SUFFIX@ 71 | mpg123_timeframe@LARGEFILE_SUFFIX@ 72 | mpg123_index@LARGEFILE_SUFFIX@ 73 | mpg123_position@LARGEFILE_SUFFIX@ 74 | mpg123_length@LARGEFILE_SUFFIX@ 75 | mpg123_set_filesize@LARGEFILE_SUFFIX@ 76 | -------------------------------------------------------------------------------- /mixer/DESIGN: -------------------------------------------------------------------------------- 1 | - Mixes internally in Float32. This simplifies the code immensely by only 2 | having one format to screw with. It also makes life easy for end-user 3 | callbacks. A native Float32 format should be added to SDL, too, so there 4 | isn't unnecessary conversion if we can avoid it (i.e. - a CoreAudio backend). 5 | 6 | - "Chunks" are just Sound_Samples...you can lock the mixer to screw with them 7 | (i.e. - seeking in a playing Sample, etc). The mixer adds some opaque state 8 | to Sound_Sample (current play position, how much is decoded, etc), some of 9 | which can be queried and set. 10 | 11 | - There is no "stopped" state. You are either in the playing list or you are 12 | not, but state doesn't reset, so removing a sample from the list is more like 13 | pausing it. If you put it back in the playing list without rewinding it, it 14 | starts where it was. 15 | 16 | - Fire and forget mixing is easy; flag a sample as "auto free" and it'll 17 | delete itself when it's done playing. No need to set up a callback just to 18 | clean up. 19 | 20 | - No channels. You can mix as many samples as you have resources to 21 | accomodate. 22 | 23 | - No groups. This can be layered on top of the library if needed. If you 24 | need atomic operations, lock the mixer. 25 | 26 | - No music channel. Samples are samples. You can mix a MIDI as a sound effect 27 | if you want, or a WAV file for background music. If you have the horsepower 28 | to decode multiple compressed files at once, go for it. 29 | 30 | - You can prebuffer/predecode as much of a sample as you like. 31 | 32 | - Every sample mixes with a per-channel gain, plus a master gain that is 33 | global to the mixer. 34 | 35 | - Can handle non-power of two resampling. 36 | 37 | - post mix hook, sample finished hook. Effects callback? 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /VisualC/README.txt: -------------------------------------------------------------------------------- 1 | README 2 | 2002/12/23 3 | 4 | This directory contains a Project Workspace for Visual Studio 6. 5 | It is based off the code in the CVS after the 1.0.0 release (1.0.1?). 6 | 7 | 8 | This project has options to build a DLL or static library and 9 | build playsound (dynamic or static). This project mimics the 10 | original pre-1.0.0 version which no longer works with the current 11 | code. 12 | 13 | Unlike the former package, this one contains no binaries. This 14 | will allow this project to be included in the main SDL_sound 15 | source code. You will be responsible for finding the binaries 16 | you need for each decoder. We have attempted to provide a 17 | Support pack which contains the binaries built and tested with. 18 | However, many of the binaries become quickly outdated so 19 | you may not want to depend too heavily on the Support pack. 20 | 21 | If you need the binaries, you should either copy the files to your 22 | default VisualC++ directories (both headers and libraries), or add 23 | them to your search paths, either through the Project Settings for 24 | Include and Link paths or through the global settings 25 | (Tools->Options->Directories in VC6). You need to do it both for the 26 | header files (includes) and library files. To run your final 27 | executables, you will need the DLL files in the local path 28 | or one of your Windows main DLL search paths. 29 | 30 | 31 | Issues: 32 | 33 | The static playsound really isn't static. You still need the 34 | dlls for each of the codecs. You will have to tweak the project to 35 | build a true static binary and will probably require you to have 36 | static versions of all the decoder libraries. 37 | 38 | 39 | 40 | 41 | Eric Wing 42 | Joshua Quick 43 | -------------------------------------------------------------------------------- /decoders/libmpg123/equalizer_3dnow.S: -------------------------------------------------------------------------------- 1 | /* 2 | equalizer_3dnow: 3DNow! optimized do_equalizer() 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by KIMURA Takuhiro 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | .text 12 | ALIGN4 13 | .globl ASM_NAME(do_equalizer_3dnow) 14 | /* .type ASM_NAME(do_equalizer_3dnow),@function */ 15 | /* void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]); */ 16 | ASM_NAME(do_equalizer_3dnow): 17 | pushl %esi 18 | pushl %ebx 19 | /* bandPtr */ 20 | movl 12(%esp),%ebx 21 | /* channel */ 22 | movl 16(%esp),%ecx 23 | xorl %edx,%edx 24 | /* equalizer */ 25 | movl 20(%esp),%esi 26 | sall $7,%ecx 27 | ALIGN4 28 | .L9: 29 | movq (%ebx,%edx),%mm0 30 | pfmul (%esi,%ecx),%mm0 31 | 32 | movq 8(%ebx,%edx),%mm1 33 | pfmul 8(%esi,%ecx),%mm1 34 | movq %mm0,(%ebx,%edx) 35 | 36 | movq 16(%ebx,%edx),%mm0 37 | pfmul 16(%esi,%ecx),%mm0 38 | movq %mm1,8(%ebx,%edx) 39 | 40 | movq 24(%ebx,%edx),%mm1 41 | pfmul 24(%esi,%ecx),%mm1 42 | movq %mm0,16(%ebx,%edx) 43 | 44 | movq 32(%ebx,%edx),%mm0 45 | pfmul 32(%esi,%ecx),%mm0 46 | movq %mm1,24(%ebx,%edx) 47 | 48 | movq 40(%ebx,%edx),%mm1 49 | pfmul 40(%esi,%ecx),%mm1 50 | movq %mm0,32(%ebx,%edx) 51 | 52 | movq 48(%ebx,%edx),%mm0 53 | pfmul 48(%esi,%ecx),%mm0 54 | movq %mm1,40(%ebx,%edx) 55 | 56 | movq 56(%ebx,%edx),%mm1 57 | pfmul 56(%esi,%ecx),%mm1 58 | movq %mm0,48(%ebx,%edx) 59 | movq %mm1,56(%ebx,%edx) 60 | 61 | addl $64,%edx 62 | addl $32,%ecx 63 | cmpl $124,%edx 64 | jle .L9 65 | ALIGN4 66 | popl %ebx 67 | popl %esi 68 | ret 69 | 70 | /* Mark non-executable stack. */ 71 | #if defined(__linux__) && defined(__ELF__) 72 | .section .note.GNU-stack,"",%progbits 73 | #endif 74 | -------------------------------------------------------------------------------- /decoders/libmpg123/getbits.h: -------------------------------------------------------------------------------- 1 | /* 2 | getbits 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | */ 8 | 9 | #ifndef _MPG123_GETBITS_H_ 10 | #define _MPG123_GETBITS_H_ 11 | 12 | /* that's the same file as getits.c but with defines to 13 | force inlining */ 14 | 15 | #define backbits(fr,nob) ((void)( \ 16 | fr->bitindex -= nob, \ 17 | fr->wordpointer += (fr->bitindex>>3), \ 18 | fr->bitindex &= 0x7 )) 19 | 20 | #define getbitoffset(fr) ((-fr->bitindex)&0x7) 21 | #define getbyte(fr) (*fr->wordpointer++) 22 | 23 | #define getbits(fr, nob) ( \ 24 | fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \ 25 | fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \ 26 | fr->ultmp &= 0xffffff, fr->bitindex += nob, \ 27 | fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \ 28 | fr->bitindex &= 7,fr->ultmp) 29 | 30 | #define skipbits(fr, nob) fr->ultmp = ( \ 31 | fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \ 32 | fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \ 33 | fr->ultmp &= 0xffffff, fr->bitindex += nob, \ 34 | fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \ 35 | fr->bitindex &= 7 ) 36 | 37 | #define getbits_fast(fr, nob) ( \ 38 | fr->ultmp = (unsigned char) (fr->wordpointer[0] << fr->bitindex), \ 39 | fr->ultmp |= ((unsigned long) fr->wordpointer[1]<bitindex)>>8, \ 40 | fr->ultmp <<= nob, fr->ultmp >>= 8, \ 41 | fr->bitindex += nob, fr->wordpointer += (fr->bitindex>>3), \ 42 | fr->bitindex &= 7, fr->ultmp ) 43 | 44 | #define get1bit(fr) ( \ 45 | fr->uctmp = *fr->wordpointer << fr->bitindex, fr->bitindex++, \ 46 | fr->wordpointer += (fr->bitindex>>3), fr->bitindex &= 7, fr->uctmp>>7 ) 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /decoders/timidity/playmidi.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | playmidi.h 21 | 22 | */ 23 | 24 | /* Midi events */ 25 | #define ME_NONE 0 26 | #define ME_NOTEON 1 27 | #define ME_NOTEOFF 2 28 | #define ME_KEYPRESSURE 3 29 | #define ME_MAINVOLUME 4 30 | #define ME_PAN 5 31 | #define ME_SUSTAIN 6 32 | #define ME_EXPRESSION 7 33 | #define ME_PITCHWHEEL 8 34 | #define ME_PROGRAM 9 35 | #define ME_TEMPO 10 36 | #define ME_PITCH_SENS 11 37 | 38 | #define ME_ALL_SOUNDS_OFF 12 39 | #define ME_RESET_CONTROLLERS 13 40 | #define ME_ALL_NOTES_OFF 14 41 | #define ME_TONE_BANK 15 42 | 43 | #define ME_LYRIC 16 44 | 45 | #define ME_EOT 99 46 | 47 | /* Causes the instrument's default panning to be used. */ 48 | #define NO_PANNING -1 49 | 50 | /* Voice status options: */ 51 | #define VOICE_FREE 0 52 | #define VOICE_ON 1 53 | #define VOICE_SUSTAINED 2 54 | #define VOICE_OFF 3 55 | #define VOICE_DIE 4 56 | 57 | /* Voice panned options: */ 58 | #define PANNED_MYSTERY 0 59 | #define PANNED_LEFT 1 60 | #define PANNED_RIGHT 2 61 | #define PANNED_CENTER 3 62 | /* Anything but PANNED_MYSTERY only uses the left volume */ 63 | 64 | #define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c)))) 65 | -------------------------------------------------------------------------------- /decoders/timidity/output.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | output.h 21 | 22 | */ 23 | 24 | /* Data format encoding bits */ 25 | 26 | #define PE_MONO 0x01 /* versus stereo */ 27 | #define PE_SIGNED 0x02 /* versus unsigned */ 28 | #define PE_16BIT 0x04 /* versus 8-bit */ 29 | 30 | /* Conversion functions -- These overwrite the Sint32 data in *lp with 31 | data in another format */ 32 | 33 | /* 8-bit signed and unsigned*/ 34 | extern void s32tos8(void *dp, Sint32 *lp, Sint32 c); 35 | extern void s32tou8(void *dp, Sint32 *lp, Sint32 c); 36 | 37 | /* 16-bit */ 38 | extern void s32tos16(void *dp, Sint32 *lp, Sint32 c); 39 | extern void s32tou16(void *dp, Sint32 *lp, Sint32 c); 40 | 41 | /* byte-exchanged 16-bit */ 42 | extern void s32tos16x(void *dp, Sint32 *lp, Sint32 c); 43 | extern void s32tou16x(void *dp, Sint32 *lp, Sint32 c); 44 | 45 | /* little-endian and big-endian specific */ 46 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN 47 | #define s32tou16l s32tou16 48 | #define s32tou16b s32tou16x 49 | #define s32tos16l s32tos16 50 | #define s32tos16b s32tos16x 51 | #else 52 | #define s32tou16l s32tou16x 53 | #define s32tou16b s32tou16 54 | #define s32tos16l s32tos16x 55 | #define s32tos16b s32tos16 56 | #endif 57 | -------------------------------------------------------------------------------- /decoders/libmpg123/index.h: -------------------------------------------------------------------------------- 1 | #ifndef MPG123_H_INDEX 2 | #define MPG123_H_INDEX 3 | 4 | /* 5 | index: frame index data structure and functions 6 | 7 | This is for keeping track of frame positions for accurate seeking. 8 | Now in it's own file, with initial code from frame.c and parse.c . 9 | 10 | The idea of the index with a certain amount of entries is to cover 11 | all yet-encountered frame positions with minimal coarseness. 12 | Meaning: At first every frame position is recorded, then, when 13 | the index is full, every second position is trown away to make 14 | space. Next time it is full, the same happens. And so on. 15 | In this manner we maintain a good resolution with the given 16 | maximum index size while covering the whole stream. 17 | 18 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 19 | see COPYING and AUTHORS files in distribution or http://mpg123.org 20 | initially written by Thomas Orgis 21 | */ 22 | 23 | #include "config.h" 24 | #include "compat.h" 25 | 26 | struct frame_index 27 | { 28 | off_t *data; /* actual data, the frame positions */ 29 | off_t step; /* advancement in frame number per index point */ 30 | off_t next; /* frame offset supposed to come next into the index */ 31 | size_t size; /* total number of possible entries */ 32 | size_t fill; /* number of used entries */ 33 | size_t grow_size; /* if > 0: index allowed to grow on need with these steps, instead of lowering resolution */ 34 | }; 35 | 36 | /* The condition for a framenum to be appended to the index. 37 | if(FI_NEXT(fr->index, fr->num)) fi_add(offset); */ 38 | #define FI_NEXT(fi, framenum) ((fi).size && framenum == (fi).next) 39 | 40 | /* Initialize stuff, set things to zero and NULL... */ 41 | void fi_init(struct frame_index *fi); 42 | /* Deallocate/zero things. */ 43 | void fi_exit(struct frame_index *fi); 44 | 45 | /* Prepare a given size, preserving current fill, if possible. 46 | If the new size is smaller than fill, the entry density is reduced. 47 | Return 0 on success. */ 48 | int fi_resize(struct frame_index *fi, size_t newsize); 49 | 50 | /* Append a frame position, reducing index density if needed. */ 51 | void fi_add(struct frame_index *fi, off_t pos); 52 | 53 | /* Empty the index (setting fill=0 and step=1), but keep current size. */ 54 | void fi_reset(struct frame_index *fi); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /decoders/timidity/README: -------------------------------------------------------------------------------- 1 | [This version of timidity has been stripped for simplicity in porting to SDL, 2 | and then even further for SDL_sound] 3 | ---------------------------------*-text-*--------------------------------- 4 | 5 | From http://www.cgs.fi/~tt/discontinued.html : 6 | 7 | If you'd like to continue hacking on TiMidity, feel free. I'm 8 | hereby extending the TiMidity license agreement: you can now 9 | select the most convenient license for your needs from (1) the 10 | GNU GPL, (2) the GNU LGPL, or (3) the Perl Artistic License. 11 | 12 | -------------------------------------------------------------------------- 13 | 14 | This is the README file for TiMidity v0.2i 15 | 16 | TiMidity is a MIDI to WAVE converter that uses Gravis 17 | Ultrasound(*)-compatible patch files to generate digital audio data 18 | from General MIDI files. The audio data can be played through any 19 | sound device or stored on disk. On a fast machine, music can be 20 | played in real time. TiMidity runs under Linux, FreeBSD, HP-UX, SunOS, and 21 | Win32, and porting to other systems with gcc should be easy. 22 | 23 | TiMidity Features: 24 | 25 | * 32 or more dynamically allocated fully independent voices 26 | * Compatibility with GUS patch files 27 | * Output to 16- or 8-bit PCM or uLaw audio device, file, or 28 | stdout at any sampling rate 29 | * Optional interactive mode with real-time status display 30 | under ncurses and SLang terminal control libraries. Also 31 | a user friendly motif interface since version 0.2h 32 | * Support for transparent loading of compressed MIDI files and 33 | patch files 34 | 35 | * Support for the following MIDI events: 36 | - Program change 37 | - Key pressure 38 | - Channel main volume 39 | - Tempo 40 | - Panning 41 | - Damper pedal (Sustain) 42 | - Pitch wheel 43 | - Pitch wheel sensitivity 44 | - Change drum set 45 | 46 | * The GNU General Public License can, as always, be found in the file 47 | "../COPYING". 48 | 49 | * TiMidity requires sampled instruments (patches) to play MIDI files. You 50 | should get the file "timidity-lib-0.1.tar.gz" and unpack it in the same 51 | directory where you unpacked the source code archive. You'll want more 52 | patches later -- read the file "FAQ" for pointers. 53 | 54 | * Timidity is no longer supported, but can be found by searching the web. 55 | 56 | 57 | Tuukka Toivonen 58 | 59 | [(*) Any Registered Trademarks used anywhere in the documentation or 60 | source code for TiMidity are acknowledged as belonging to their 61 | respective owners.] 62 | -------------------------------------------------------------------------------- /decoders/libmpg123/getcpuflags.S: -------------------------------------------------------------------------------- 1 | /* 2 | getcpucpuflags: get cpuflags for ia32 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org 6 | initially written by KIMURA Takuhiro (for 3DNow!) 7 | extended for general use by Thomas Orgis 8 | 9 | extern int getcpuid(struct cpuflags*) 10 | or just 11 | extern int getcpuid(unsigned int*) 12 | where there is memory for 4 ints 13 | -> the first set of idflags (basic cpu family info) 14 | and the idflags, stdflags, std2flags, extflags written to the parameter 15 | -> 0x00000000 (CPUID instruction not supported) 16 | */ 17 | 18 | #include "mangle.h" 19 | 20 | .text 21 | ALIGN4 22 | 23 | .globl ASM_NAME(getcpuflags) 24 | /* .type ASM_NAME(getcpuflags),@function */ 25 | ASM_NAME(getcpuflags): 26 | pushl %ebp 27 | movl %esp,%ebp 28 | pushl %edx 29 | pushl %ecx 30 | pushl %ebx 31 | pushl %esi 32 | /* get the int pointer for storing the flags */ 33 | movl 8(%ebp), %esi 34 | /* does that one make sense? */ 35 | movl $0x80000000,%eax 36 | /* now save the flags and do a check for cpuid availability */ 37 | pushfl 38 | pushfl 39 | popl %eax 40 | movl %eax,%ebx 41 | /* set that bit... */ 42 | xorl $0x00200000,%eax 43 | pushl %eax 44 | popfl 45 | /* ...and read back the flags to see if it is understood */ 46 | pushfl 47 | popl %eax 48 | popfl 49 | cmpl %ebx,%eax 50 | je .Lnocpuid 51 | /* In principle, I would have to check the CPU's identify first to be sure how to interpret the extended flags. */ 52 | /* now get the info, first extended */ 53 | movl $0x0, 12(%esi) /* clear value */ 54 | /* only if supported... */ 55 | movl $0x80000000, %eax 56 | cpuid 57 | /* IDT CPUs should not change EAX, generally I hope that non-3DNow cpus do not set a bogus support level here. */ 58 | cmpl $0x80000001, %eax 59 | jb .Lnoextended /* Skip ext check without minimal support level. */ 60 | /* is supported, get flags value */ 61 | movl $0x80000001,%eax 62 | cpuid 63 | movl %edx,12(%esi) 64 | .Lnoextended: 65 | /* then the other ones, called last to get the id flags in %eax for ret */ 66 | movl $0x00000001,%eax 67 | cpuid 68 | movl %eax, (%esi) 69 | movl %ecx, 4(%esi) 70 | movl %edx, 8(%esi) 71 | jmp .Lend 72 | ALIGN4 73 | .Lnocpuid: 74 | /* error: set everything to zero */ 75 | movl $0, %eax 76 | movl $0, (%esi) 77 | movl $0, 4(%esi) 78 | movl $0, 8(%esi) 79 | movl $0, 12(%esi) 80 | ALIGN4 81 | .Lend: 82 | /* return value are the id flags, still stored in %eax */ 83 | popl %esi 84 | popl %ebx 85 | popl %ecx 86 | popl %edx 87 | movl %ebp,%esp 88 | popl %ebp 89 | ret 90 | 91 | /* Mark non-executable stack. */ 92 | #if defined(__linux__) && defined(__ELF__) 93 | .section .note.GNU-stack,"",%progbits 94 | #endif 95 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | SDL_sound. An abstract soundfile decoder. 2 | 3 | SDL_sound is a library that handles the decoding of several popular sound file 4 | formats, such as .WAV and .MP3. It is meant to make the programmer's sound 5 | playback tasks simpler. The programmer gives SDL_sound a filename, or feeds 6 | it data directly from one of many sources, and then reads the decoded 7 | waveform data back at her leisure. If resource constraints are a concern, 8 | SDL_sound can process sound data in programmer-specified blocks. Alternately, 9 | SDL_sound can decode a whole sound file and hand back a single pointer to the 10 | whole waveform. SDL_sound can also handle sample rate, audio format, and 11 | channel conversion on-the-fly and behind-the-scenes, if the programmer 12 | desires. 13 | 14 | Please check the website for the most up-to-date information about SDL_sound: 15 | http://icculus.org/SDL_sound/ 16 | 17 | SDL_sound _REQUIRES_ Simple Directmedia Layer (SDL) to function, and cannot 18 | be built without it. You can get SDL from http://www.libsdl.org/. SDL_sound 19 | has only been tried with the SDL 1.2 series, but may work on older versions. 20 | Reports of success or failure are welcome. 21 | 22 | Some optional external libraries that SDL_sound can use and where to find them: 23 | SMPEG (used to decode MP3s): http://icculus.org/smpeg/ 24 | libvorbisfile (used to decode OGGs): http://www.xiph.org/ogg/vorbis/ 25 | libSpeex (used to decode SPXs): http://speex.org/ 26 | libFLAC (used to decode FLACs): http://flac.sourceforge.net/ 27 | libModPlug (used to decode MODs, etc): http://modplug-xmms.sourceforge.net/ 28 | libMikMod (used to decode MODs, etc, too): http://www.mikmod.org/ 29 | 30 | Experimental QuickTime support for the Mac is included, but has not been 31 | integrated with the build system, and probably doesn't work with 32 | QuickTime for Windows. 33 | 34 | These external libraries are OPTIONAL. SDL_sound will build and function 35 | without them, but various sound file formats are not supported unless these 36 | libraries are available. Unless explicitly disabled during initial build 37 | configuration, SDL_sound always supports these file formats internally: 38 | 39 | - Microsoft .WAV files (uncompressed and MS-ADPCM encoded). 40 | - Creative Labs .VOC files 41 | - Shorten (.SHN) files 42 | - Audio Interchange format (AIFF) files 43 | - Sun Audio (.AU) files 44 | - MIDI files 45 | - MP3 files (internal decoder, different than the one SMPEG uses) 46 | - Raw waveform data 47 | 48 | Building/Installing: 49 | Please read the INSTALL document. 50 | 51 | Reporting bugs/commenting: 52 | There is a mailing list available. To subscribe, send a blank email to 53 | sdlsound-subscribe@icculus.org. This is the best way to get in touch with 54 | SDL_sound developers. 55 | 56 | --ryan. (icculus@icculus.org) 57 | 58 | 59 | -------------------------------------------------------------------------------- /decoders/libmpg123/Makefile.am-original: -------------------------------------------------------------------------------- 1 | ## Makefile.am: produce Makefile.in from this 2 | 3 | ## copyright by the mpg123 project - free software under the terms of the LGPL 2.1 4 | ## see COPYING and AUTHORS files in distribution or http://mpg123.org 5 | ## initially written by Nicholas J. Humfrey 6 | 7 | #AM_CFLAGS = @AUDIO_CFLAGS@ 8 | #AM_LDFLAGS = 9 | INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/libmpg123 10 | 11 | EXTRA_DIST = mpg123.h.in dnoise.sh dnoise.dat 12 | 13 | EXTRA_PROGRAMS = testcpu 14 | testcpu_dependencies = getcpuflags.$(OBJEXT) 15 | testcpu_sources = testcpu.c 16 | testcpu_LDADD = getcpuflags.$(OBJEXT) 17 | 18 | 19 | CLEANFILES = *.a 20 | 21 | 22 | #lib_LIBRARIES = libmpg123.a 23 | lib_LTLIBRARIES = libmpg123.la 24 | nodist_include_HEADERS = mpg123.h 25 | 26 | #libmpg123_a_LIBADD = @DECODER_OBJ@ 27 | #libmpg123_a_DEPENDENCIES = @DECODER_OBJ@ 28 | 29 | libmpg123_la_LDFLAGS = -no-undefined -version-info @LIBMPG123_VERSION@ -export-symbols $(top_srcdir)/src/libmpg123/libmpg123.sym 30 | libmpg123_la_LIBADD = @DECODER_LOBJ@ 31 | libmpg123_la_DEPENDENCIES = @DECODER_LOBJ@ $(top_srcdir)/src/libmpg123/libmpg123.sym 32 | 33 | libmpg123_la_SOURCES = \ 34 | compat.c \ 35 | compat.h \ 36 | parse.c \ 37 | parse.h \ 38 | frame.c \ 39 | format.c \ 40 | frame.h \ 41 | reader.h \ 42 | debug.h \ 43 | decode.h \ 44 | decode_2to1.c \ 45 | decode_4to1.c \ 46 | decode_ntom.c \ 47 | equalizer.c \ 48 | huffman.h \ 49 | icy.c \ 50 | icy.h \ 51 | icy2utf8.c \ 52 | icy2utf8.h \ 53 | id3.c \ 54 | id3.h \ 55 | true.h \ 56 | l2tables.h \ 57 | layer1.c \ 58 | layer2.c \ 59 | layer3.c \ 60 | getbits.h \ 61 | optimize.h \ 62 | optimize.c \ 63 | readers.c \ 64 | tabinit.c \ 65 | stringbuf.c \ 66 | libmpg123.c \ 67 | mpg123lib_intern.h \ 68 | mangle.h \ 69 | getcpuflags.h \ 70 | index.h \ 71 | index.c \ 72 | libmpg123.sym 73 | 74 | EXTRA_libmpg123_la_SOURCES = \ 75 | dct36_3dnowext.S \ 76 | dct36_3dnow.S \ 77 | dct64_3dnowext.S \ 78 | dct64_3dnow.S \ 79 | dct64_altivec.c \ 80 | dct64.c \ 81 | dct64_i386.c \ 82 | dct64_i486.c \ 83 | dct64_mmx.S \ 84 | dct64_sse.S \ 85 | decode_3dnowext.S \ 86 | decode_3dnow.S \ 87 | decode_altivec.c \ 88 | decode.c \ 89 | decode_i386.c \ 90 | decode_i486.c \ 91 | decode_i586_dither.S \ 92 | decode_i586.S \ 93 | decode_mmx.S \ 94 | decode_sse3d.h \ 95 | decode_sse.S \ 96 | equalizer_3dnow.S \ 97 | tabinit_mmx.S \ 98 | getcpuflags.S 99 | 100 | # explicit preprocessing since mingw32 does not honor the big .S 101 | .S.o: 102 | $(CPP) $(AM_CPPFLAGS) $(DEFAULT_INCLUDES) $(CPPFLAGS) $< > $<.s 103 | $(CCAS) $(CCASFLAGS) -c -o $@ $<.s && rm $<.s 104 | 105 | .S.lo: 106 | $(LTCCASCOMPILE) $(DEFAULT_INCLUDES) -c -o $@ $< 107 | 108 | dnoise.c: dnoise.dat dnoise.sh 109 | sh dnoise.sh "$<" > "$@" 110 | -------------------------------------------------------------------------------- /decoders/libmpg123/decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | decode.h: common definitions for decode functions 3 | 4 | copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis, taking WRITE_SAMPLE from decode.c 7 | */ 8 | #ifndef MPG123_DECODE_H 9 | #define MPG123_DECODE_H 10 | 11 | #ifdef FLOATOUT 12 | #define WRITE_SAMPLE(samples,sum,clip) *(samples) = sum 13 | #define sample_t float 14 | #else 15 | #define WRITE_SAMPLE(samples,sum,clip) \ 16 | if( (sum) > REAL_PLUS_32767) { *(samples) = 0x7fff; (clip)++; } \ 17 | else if( (sum) < REAL_MINUS_32768) { *(samples) = -0x8000; (clip)++; } \ 18 | else { *(samples) = REAL_TO_SHORT(sum); } 19 | #define sample_t short 20 | #endif 21 | 22 | #define NTOM_MAX 8 /* maximum allowed factor for upsampling */ 23 | #define NTOM_MAX_FREQ 96000 /* maximum frequency to upsample to / downsample from */ 24 | #define NTOM_MUL (32768) 25 | 26 | /* synth_1to1 in optimize.h, one should also use opts for these here... */ 27 | 28 | int synth_2to1 (real *,int, mpg123_handle*, int); 29 | int synth_2to1_8bit (real *,int, mpg123_handle *,int); 30 | int synth_2to1_mono (real *, mpg123_handle *); 31 | int synth_2to1_mono2stereo (real *, mpg123_handle *); 32 | int synth_2to1_8bit_mono (real *, mpg123_handle *); 33 | int synth_2to1_8bit_mono2stereo (real *, mpg123_handle *); 34 | 35 | int synth_4to1 (real *,int, mpg123_handle*, int); 36 | int synth_4to1_8bit (real *,int, mpg123_handle *,int); 37 | int synth_4to1_mono (real *, mpg123_handle *); 38 | int synth_4to1_mono2stereo (real *, mpg123_handle *); 39 | int synth_4to1_8bit_mono (real *, mpg123_handle *); 40 | int synth_4to1_8bit_mono2stereo (real *, mpg123_handle *); 41 | 42 | int synth_ntom (real *,int, mpg123_handle*, int); 43 | int synth_ntom_8bit (real *,int, mpg123_handle *,int); 44 | int synth_ntom_mono (real *, mpg123_handle *); 45 | int synth_ntom_mono2stereo (real *, mpg123_handle *); 46 | int synth_ntom_8bit_mono (real *, mpg123_handle *); 47 | int synth_ntom_8bit_mono2stereo (real *, mpg123_handle *); 48 | 49 | int synth_ntom_set_step(mpg123_handle *fr); /* prepare ntom decoding */ 50 | unsigned long ntom_val(mpg123_handle *fr, off_t frame); /* compute ntom_val for frame offset */ 51 | 52 | off_t ntom_frmouts(mpg123_handle *fr, off_t frame); 53 | off_t ntom_ins2outs(mpg123_handle *fr, off_t ins); 54 | off_t ntom_frameoff(mpg123_handle *fr, off_t soff); 55 | 56 | void init_layer3(void); 57 | void init_layer3_stuff(mpg123_handle *fr); 58 | void init_layer2(void); 59 | void init_layer2_stuff(mpg123_handle *fr); 60 | int make_conv16to8_table(mpg123_handle *fr); 61 | 62 | int do_layer3(mpg123_handle *fr); 63 | int do_layer2(mpg123_handle *fr); 64 | int do_layer1(mpg123_handle *fr); 65 | void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /decoders/timidity/testmidi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An abstract sound format decoding API. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /** 21 | * Program to test the TiMidity core, without having to worry about decoder 22 | * and/or playsound bugs. It's not meant to be robust or user-friendly. 23 | */ 24 | 25 | #include 26 | #include 27 | #include "SDL.h" 28 | #include "timidity.h" 29 | 30 | int done_flag = 0; 31 | MidiSong *song; 32 | 33 | static void audio_callback(void *userdata, Uint8 *stream, int len) 34 | { 35 | if (Timidity_PlaySome(song, stream, len) == 0) 36 | done_flag = 1; 37 | } 38 | 39 | int main(int argc, char *argv[]) 40 | { 41 | SDL_AudioSpec audio; 42 | SDL_RWops *rw; 43 | 44 | if (SDL_Init(SDL_INIT_AUDIO) < 0) 45 | { 46 | fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); 47 | return 1; 48 | } 49 | 50 | atexit(SDL_Quit); 51 | 52 | if (argc != 2) 53 | { 54 | fprintf(stderr, "Usage: %s midifile\n", argv[0]); 55 | return 1; 56 | } 57 | 58 | audio.freq = 44100; 59 | audio.format = AUDIO_S16SYS; 60 | audio.channels = 2; 61 | audio.samples = 4096; 62 | audio.callback = audio_callback; 63 | 64 | if (SDL_OpenAudio(&audio, NULL) < 0) 65 | { 66 | fprintf(stderr, "Couldn't open audio device. %s\n", SDL_GetError()); 67 | return 1; 68 | } 69 | 70 | if (Timidity_Init() < 0) 71 | { 72 | fprintf(stderr, "Could not initialise TiMidity.\n"); 73 | return 1; 74 | } 75 | 76 | rw = SDL_RWFromFile(argv[1], "rb"); 77 | if (rw == NULL) 78 | { 79 | fprintf(stderr, "Could not create RWops from MIDI file.\n"); 80 | return 1; 81 | } 82 | 83 | song = Timidity_LoadSong(rw, &audio); 84 | SDL_RWclose(rw); 85 | 86 | if (song == NULL) 87 | { 88 | fprintf(stderr, "Could not open MIDI file.\n"); 89 | return 1; 90 | } 91 | 92 | Timidity_SetVolume(song, 100); 93 | Timidity_Start(song); 94 | 95 | SDL_PauseAudio(0); 96 | while (!done_flag) 97 | { 98 | SDL_Delay(10); 99 | } 100 | SDL_PauseAudio(1); 101 | Timidity_FreeSong(song); 102 | Timidity_Exit(); 103 | 104 | return 0; 105 | } 106 | -------------------------------------------------------------------------------- /decoders/timidity/output.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | output.c 21 | 22 | Audio output (to file / device) functions. 23 | */ 24 | 25 | #if HAVE_CONFIG_H 26 | # include 27 | #endif 28 | 29 | #include "SDL_sound.h" 30 | 31 | #define __SDL_SOUND_INTERNAL__ 32 | #include "SDL_sound_internal.h" 33 | 34 | #include "options.h" 35 | #include "output.h" 36 | 37 | /*****************************************************************/ 38 | /* Some functions to convert signed 32-bit data to other formats */ 39 | 40 | void s32tos8(void *dp, Sint32 *lp, Sint32 c) 41 | { 42 | Sint8 *cp=(Sint8 *)(dp); 43 | Sint32 l; 44 | while (c--) 45 | { 46 | l=(*lp++)>>(32-8-GUARD_BITS); 47 | if (l>127) l=127; 48 | else if (l<-128) l=-128; 49 | *cp++ = (Sint8) (l); 50 | } 51 | } 52 | 53 | void s32tou8(void *dp, Sint32 *lp, Sint32 c) 54 | { 55 | Uint8 *cp=(Uint8 *)(dp); 56 | Sint32 l; 57 | while (c--) 58 | { 59 | l=(*lp++)>>(32-8-GUARD_BITS); 60 | if (l>127) l=127; 61 | else if (l<-128) l=-128; 62 | *cp++ = 0x80 ^ ((Uint8) l); 63 | } 64 | } 65 | 66 | void s32tos16(void *dp, Sint32 *lp, Sint32 c) 67 | { 68 | Sint16 *sp=(Sint16 *)(dp); 69 | Sint32 l; 70 | while (c--) 71 | { 72 | l=(*lp++)>>(32-16-GUARD_BITS); 73 | if (l > 32767) l=32767; 74 | else if (l<-32768) l=-32768; 75 | *sp++ = (Sint16)(l); 76 | } 77 | } 78 | 79 | void s32tou16(void *dp, Sint32 *lp, Sint32 c) 80 | { 81 | Uint16 *sp=(Uint16 *)(dp); 82 | Sint32 l; 83 | while (c--) 84 | { 85 | l=(*lp++)>>(32-16-GUARD_BITS); 86 | if (l > 32767) l=32767; 87 | else if (l<-32768) l=-32768; 88 | *sp++ = 0x8000 ^ (Uint16)(l); 89 | } 90 | } 91 | 92 | void s32tos16x(void *dp, Sint32 *lp, Sint32 c) 93 | { 94 | Sint16 *sp=(Sint16 *)(dp); 95 | Sint32 l; 96 | while (c--) 97 | { 98 | l=(*lp++)>>(32-16-GUARD_BITS); 99 | if (l > 32767) l=32767; 100 | else if (l<-32768) l=-32768; 101 | *sp++ = SDL_Swap16((Sint16)(l)); 102 | } 103 | } 104 | 105 | void s32tou16x(void *dp, Sint32 *lp, Sint32 c) 106 | { 107 | Uint16 *sp=(Uint16 *)(dp); 108 | Sint32 l; 109 | while (c--) 110 | { 111 | l=(*lp++)>>(32-16-GUARD_BITS); 112 | if (l > 32767) l=32767; 113 | else if (l<-32768) l=-32768; 114 | *sp++ = SDL_Swap16(0x8000 ^ (Uint16)(l)); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /extra_rwops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An abstract sound format decoding API. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* 21 | * Some extra RWops that are needed or are just handy to have. 22 | * 23 | * Please see the file LICENSE.txt in the source's root directory. 24 | * 25 | * This file written by Ryan C. Gordon. (icculus@icculus.org) 26 | */ 27 | 28 | #ifndef _INCLUDE_EXTRA_RWOPS_H_ 29 | #define _INCLUDE_EXTRA_RWOPS_H_ 30 | 31 | #include "SDL.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* 38 | * The Reference Counter RWops... 39 | * 40 | * This wraps another RWops with a reference counter. When you create a 41 | * reference counter RWops, it sets a counter to one. Everytime you call 42 | * RWops_RWRefCounter_new(), that's RWops's counter increments by one. 43 | * Everytime you call that RWops's close() method, the counter decrements 44 | * by one. If the counter hits zero, the original RWops's close() method 45 | * is called, and the reference counting wrapper deletes itself. The read, 46 | * write, and seek methods just pass through to the original. 47 | * 48 | * This is handy if you have two libraries (in the original case, SDL_sound 49 | * and SMPEG), who both want an SDL_RWops, and both want to close it when 50 | * they are finished. This resolves that contention. The user creates a 51 | * RWops, passes it to SDL_sound, which wraps it in a reference counter and 52 | * increments the number of references, and passes the wrapped RWops to 53 | * SMPEG. SMPEG "closes" this wrapped RWops when the MP3 has finished 54 | * playing, and SDL_sound then closes it, too. This second closing removes 55 | * the last reference, and the RWops is smoothly destructed. 56 | */ 57 | 58 | /* Return a SDL_RWops that is a reference counting wrapper of (rw). */ 59 | SDL_RWops *RWops_RWRefCounter_new(SDL_RWops *rw); 60 | 61 | /* Increment a reference counting RWops's refcount by one. */ 62 | void RWops_RWRefCounter_addRef(SDL_RWops *rw); 63 | 64 | 65 | /* 66 | * RWops pooling. This is to reduce malloc() pressure for audio that is 67 | * placed into Sound_Samples over and over again. 68 | */ 69 | 70 | /* Call this first. */ 71 | int RWops_pooled_init(void); 72 | 73 | /* Call this last. */ 74 | int RWops_pooled_deinit(void); 75 | 76 | /* Get a new RWops, allocating if needed. */ 77 | SDL_RWops *RWops_pooled_alloc(void); 78 | 79 | /* Return a RWops to the pool for reuse. */ 80 | void RWops_pooled_free(SDL_RWops *rw); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* !defined _INCLUDE_EXTRA_RWOPS_H_ */ 87 | 88 | /* end of extra_rwops.h ... */ 89 | 90 | -------------------------------------------------------------------------------- /decoders/libmpg123/optimize.c: -------------------------------------------------------------------------------- 1 | /* 2 | optimize: get a grip on the different optimizations 3 | 4 | copyright 2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis, inspired by 3DNow stuff in mpg123.[hc] 7 | 8 | Currently, this file contains the struct and function to choose an optimization variant and works only when OPT_MULTI is in effect. 9 | */ 10 | 11 | #include "mpg123lib_intern.h" /* includes optimize.h */ 12 | #ifdef OPT_MULTI 13 | 14 | #include "getcpuflags.h" 15 | struct cpuflags cpu_flags; 16 | 17 | /* same number of entries as full list, but empty at beginning */ 18 | static char *mpg123_supported_decoder_list[] = 19 | { 20 | #ifdef OPT_3DNOWEXT 21 | NULL, 22 | #endif 23 | #ifdef OPT_SSE 24 | NULL, 25 | #endif 26 | #ifdef OPT_3DNOW 27 | NULL, 28 | #endif 29 | #ifdef OPT_MMX 30 | NULL, 31 | #endif 32 | #ifdef OPT_I586 33 | NULL, 34 | #endif 35 | #ifdef OPT_I586_DITHER 36 | NULL, 37 | #endif 38 | #ifdef OPT_I486 39 | NULL, 40 | #endif 41 | #ifdef OPT_I386 42 | NULL, 43 | #endif 44 | #ifdef OPT_ALTIVEC 45 | NULL, 46 | #endif 47 | NULL, /* generic */ 48 | NULL 49 | }; 50 | #endif 51 | 52 | static char *mpg123_decoder_list[] = 53 | { 54 | #ifdef OPT_3DNOWEXT 55 | "3DNowExt", 56 | #endif 57 | #ifdef OPT_SSE 58 | "SSE", 59 | #endif 60 | #ifdef OPT_3DNOW 61 | "3DNow", 62 | #endif 63 | #ifdef OPT_MMX 64 | "MMX", 65 | #endif 66 | #ifdef OPT_I586 67 | "i586", 68 | #endif 69 | #ifdef OPT_I586_DITHER 70 | "i586_dither", 71 | #endif 72 | #ifdef OPT_I486 73 | "i486", 74 | #endif 75 | #ifdef OPT_I386 76 | "i386", 77 | #endif 78 | #ifdef OPT_ALTIVEC 79 | "AltiVec", 80 | #endif 81 | #ifdef OPT_GENERIC 82 | "generic", 83 | #endif 84 | NULL 85 | }; 86 | 87 | void check_decoders(void ) 88 | { 89 | #ifndef OPT_MULTI 90 | return; 91 | #else 92 | char **d = mpg123_supported_decoder_list; 93 | #ifdef OPT_X86 94 | getcpuflags(&cpu_flags); 95 | if(cpu_i586(cpu_flags)) 96 | { 97 | /* not yet: if(cpu_sse2(cpu_flags)) printf(" SSE2"); 98 | if(cpu_sse3(cpu_flags)) printf(" SSE3"); */ 99 | #ifdef OPT_3DNOWEXT 100 | if(cpu_3dnowext(cpu_flags)) *(d++) = "3DNowExt"; 101 | #endif 102 | #ifdef OPT_SSE 103 | if(cpu_sse(cpu_flags)) *(d++) = "SSE"; 104 | #endif 105 | #ifdef OPT_3DNOW 106 | if(cpu_3dnow(cpu_flags)) *(d++) = "3DNow"; 107 | #endif 108 | #ifdef OPT_MMX 109 | if(cpu_mmx(cpu_flags)) *(d++) = "MMX"; 110 | #endif 111 | #ifdef OPT_I586 112 | *(d++) = "i586"; 113 | #endif 114 | #ifdef OPT_I586_DITHER 115 | *(d++) = "i586_dither"; 116 | #endif 117 | } 118 | #endif 119 | /* just assume that the i486 built is run on a i486 cpu... */ 120 | #ifdef OPT_I486 121 | *(d++) = "i486"; 122 | #endif 123 | #ifdef OPT_ALTIVEC 124 | *(d++) = "AltiVec"; 125 | #endif 126 | /* every supported x86 can do i386, any cpu can do generic */ 127 | #ifdef OPT_I386 128 | *(d++) = "i386"; 129 | #endif 130 | #ifdef OPT_GENERIC 131 | *(d++) = "generic"; 132 | #endif 133 | #endif /* ndef OPT_MULTI */ 134 | } 135 | 136 | char attribute_align_arg **mpg123_decoders(){ return mpg123_decoder_list; } 137 | char attribute_align_arg **mpg123_supported_decoders() 138 | { 139 | #ifdef OPT_MULTI 140 | return mpg123_supported_decoder_list; 141 | #else 142 | return mpg123_decoder_list; 143 | #endif 144 | } 145 | -------------------------------------------------------------------------------- /decoders/timidity/CHANGES: -------------------------------------------------------------------------------- 1 | This version of TiMidity should contain all the fixes from the 2 | September 25 2003 SDL_mixer CVS snapshot. In addition, I've made some 3 | changes of my own, e.g.: 4 | 5 | * All file access is done through SDL_RWops. This means the MIDI 6 | stream no longer has to be a file. (The config file and instruments 7 | still have to be though.) 8 | 9 | * Replacing of TiMidity's endian-handling with SDL's. 10 | 11 | * Removal of much unused or unnecessary code, such as 12 | 13 | + The "hooks" for putting a user interface onto TiMidity. 14 | + The antialias filter. It wasn't active, and even at 4 kHz I 15 | couldn't hear any difference when activating it. 16 | + Removed all traces of LOOKUP_HACK and LOOKUP_INTERPOLATION. 17 | According to the code comments they weren't very good anyway. 18 | ("degrades sound quality noticeably"). I also removed the 19 | disclaimer about the "8-bit uLaw to 16-bit PCM and the 13-bit-PCM 20 | to 8-bit uLaw tables" disclaimer, since I believe those were the 21 | tables I removed. 22 | + Removed LOOKUP_SINE since it was already commented out. I think we 23 | can count on our target audience having math co-processors 24 | nowadays. 25 | + Removed USE_LDEXP since it wasn't being used and "it doesn't make 26 | much of a difference either way". 27 | + Removed decompress hack from open_file() since it didn't look very 28 | portable. 29 | + Removed heaps of unnecessary constants. 30 | + Removed unused functions. 31 | + Assume that LINEAR_INTERPOLATION is always used, so remove all 32 | code dealing with it not being so. It's not that I think the 33 | difference in audio quality is that great, but since it wouldn't 34 | compile without code changes I assume no one's used it for quite 35 | some time... 36 | + Assume PRECALC_LOOPS is always defined. Judging by the comments it 37 | may not make much of a difference either way, so why maintain two 38 | versions of the same code? 39 | 40 | * Moving several static globals into the MidiSong struct. This 41 | includes sample rate, formate, etc. which are now all per-song. 42 | 43 | * Moved some typedefs (e.g. MidiSong) to timidity.h for easy inclusion 44 | into the MIDI decoder. 45 | 46 | * Added free_pathlist(). 47 | 48 | * Replaced TiMidity's own 8, 16 and 32-bit types with SDL's. 49 | 50 | * Made TiMidity look for its configuration file in both /etc and 51 | /usr/local/lib/timidity. (Windows version remains unchanged.) 52 | 53 | * Timidity_PlaySome() now takes three arguments. A MidiSong, a decode 54 | buffer and decode buffer size in bytes. (MidiSong is a new argument, 55 | and buffer size used to be in samples.) 56 | 57 | In addition, it will return the number of bytes decoded. 58 | 59 | * Added Timidity_Exit(). 60 | 61 | * Removed Timidity_Stop() and Timidity_Active(). Stopping playback 62 | should be handled by SDL_sound, and Timidity_PlaySome() will return 63 | 0 when the MIDI stream is finished. 64 | 65 | * Modified the ToneBank stuff to allow some data to be shared between 66 | MidiSongs. 67 | 68 | * The following files have been removed: controls.c, controls.h, 69 | filter.c, filter.h, sdl_a.c, sdl_c.c 70 | 71 | * config.h has been renamed as options.h to avoid confusion with the 72 | automatically generated config.h for SDL_sound. 73 | 74 | * Added support for loading DLS format instruments: 75 | Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong() 76 | 77 | * Added Timidity_Init_NoConfig() 78 | -------------------------------------------------------------------------------- /decoders/libmpg123/compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | compat: Some compatibility functions and header inclusions. 3 | Basic standard C stuff, that may barely be above/around C89. 4 | 5 | The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX. 6 | It is envisioned to include this compat header instead of any of the "standard" headers, to catch compatibility issues. 7 | So, don't include stdlib.h or string.h ... include compat.h. 8 | 9 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 10 | see COPYING and AUTHORS files in distribution or http://mpg123.org 11 | initially written by Thomas Orgis 12 | */ 13 | 14 | #ifndef MPG123_COMPAT_H 15 | #define MPG123_COMPAT_H 16 | 17 | #include "config.h" 18 | 19 | #ifdef HAVE_STDLIB_H 20 | /* realloc, size_t */ 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #ifdef HAVE_SIGNAL_H 28 | #include 29 | #else 30 | #ifdef HAVE_SYS_SIGNAL_H 31 | #include 32 | #endif 33 | #endif 34 | 35 | #ifdef HAVE_UNISTD_H 36 | #include 37 | #endif 38 | 39 | /* Types, types, types. */ 40 | /* Do we actually need these two in addition to sys/types.h? As replacement? */ 41 | #ifdef HAVE_SYS_TYPES_H 42 | #include 43 | #endif 44 | #ifdef HAVE_INTTYPES_H 45 | #include 46 | #endif 47 | #ifdef HAVE_STDINT_H 48 | #include 49 | #endif 50 | /* We want SIZE_MAX, etc. */ 51 | #ifdef HAVE_LIMITS_H 52 | #include 53 | #endif 54 | 55 | #ifndef SIZE_MAX 56 | #define SIZE_MAX ((size_t)-1) 57 | #endif 58 | #ifndef ULONG_MAX 59 | #define ULONG_MAX ((unsigned long)-1) 60 | #endif 61 | 62 | #ifdef HAVE_STRING_H 63 | #include 64 | #endif 65 | 66 | #ifdef OS2 67 | #include 68 | #endif 69 | 70 | #ifdef HAVE_SYS_TIME_H 71 | #include 72 | #endif 73 | /* For select(), I need select.h according to POSIX 2001, else: sys/time.h sys/types.h unistd.h */ 74 | #ifdef HAVE_SYS_SELECT_H 75 | #include 76 | #endif 77 | 78 | /* To parse big numbers... */ 79 | #ifdef HAVE_ATOLL 80 | #define atobigint atoll 81 | #else 82 | #define atobigint atol 83 | #endif 84 | 85 | typedef unsigned char byte; 86 | 87 | /* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */ 88 | void *safe_realloc(void *ptr, size_t size); 89 | #ifndef HAVE_STRERROR 90 | const char *strerror(int errnum); 91 | #endif 92 | 93 | #ifndef HAVE_STRDUP 94 | char *strdup(const char *s); 95 | #endif 96 | 97 | /* If we have the size checks enabled, try to derive some sane printfs. 98 | Simple start: Use max integer type and format if long is not big enough. 99 | I am hesitating to use %ll without making sure that it's there... */ 100 | #if (defined SIZEOF_OFF_T) && (SIZEOF_OFF_T > SIZEOF_LONG) && (defined PRIiMAX) 101 | # define OFF_P PRIiMAX 102 | typedef intmax_t off_p; 103 | #else 104 | # define OFF_P "li" 105 | typedef long off_p; 106 | #endif 107 | 108 | #if (defined SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > SIZEOF_LONG) && (defined PRIuMAX) 109 | # define SIZE_P PRIuMAX 110 | typedef uintmax_t size_p; 111 | #else 112 | # define SIZE_P "lu" 113 | typedef unsigned long size_p; 114 | #endif 115 | 116 | #if (defined SIZEOF_SSIZE_T) && (SIZEOF_SSIZE_T > SIZEOF_LONG) && (defined PRIiMAX) 117 | # define SSIZE_P PRIuMAX 118 | typedef intmax_t ssize_p; 119 | #else 120 | # define SSIZE_P "li" 121 | typedef long ssize_p; 122 | #endif 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /decoders/libmpg123/stringbuf.c: -------------------------------------------------------------------------------- 1 | /* 2 | stringbuf: mimicking a bit of C++ to more safely handle strings 3 | 4 | copyright 2006-8 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include "mpg123lib_intern.h" 10 | #include "config.h" 11 | #include "mpg123.h" 12 | #include "compat.h" 13 | #include 14 | #include "debug.h" 15 | 16 | void attribute_align_arg mpg123_init_string(mpg123_string* sb) 17 | { 18 | sb->p = NULL; 19 | sb->size = 0; 20 | sb->fill = 0; 21 | } 22 | 23 | void attribute_align_arg mpg123_free_string(mpg123_string* sb) 24 | { 25 | if(sb->p != NULL) free(sb->p); 26 | mpg123_init_string(sb); 27 | } 28 | 29 | int attribute_align_arg mpg123_grow_string(mpg123_string* sb, size_t new) 30 | { 31 | if(sb->size < new) return mpg123_resize_string(sb, new); 32 | else return 1; 33 | } 34 | 35 | int attribute_align_arg mpg123_resize_string(mpg123_string* sb, size_t new) 36 | { 37 | debug3("resizing string pointer %p from %lu to %lu", (void*) sb->p, (unsigned long)sb->size, (unsigned long)new); 38 | if(new == 0) 39 | { 40 | if(sb->size && sb->p != NULL) free(sb->p); 41 | mpg123_init_string(sb); 42 | return 1; 43 | } 44 | if(sb->size != new) 45 | { 46 | char* t; 47 | debug("really!"); 48 | t = (char*) safe_realloc(sb->p, new*sizeof(char)); 49 | debug1("safe_realloc returned %p", (void*) t); 50 | if(t != NULL) 51 | { 52 | sb->p = t; 53 | sb->size = new; 54 | return 1; 55 | } 56 | else return 0; 57 | } 58 | else return 1; /* success */ 59 | } 60 | 61 | int attribute_align_arg mpg123_copy_string(mpg123_string* from, mpg123_string* to) 62 | { 63 | size_t fill; 64 | char *text; 65 | if(to == NULL) return -1; 66 | 67 | debug2("called copy_string with %p -> %p", (void*)from, (void*)to); 68 | if(from == NULL) 69 | { 70 | fill = 0; 71 | text = NULL; 72 | } 73 | else 74 | { 75 | fill = from->fill; 76 | text = from->p; 77 | } 78 | 79 | if(mpg123_resize_string(to, fill)) 80 | { 81 | memcpy(to->p, text, fill); 82 | to->fill = fill; 83 | return 1; 84 | } 85 | else return 0; 86 | } 87 | 88 | int attribute_align_arg mpg123_add_string(mpg123_string* sb, const char* stuff) 89 | { 90 | debug1("adding %s", stuff); 91 | return mpg123_add_substring(sb, stuff, 0, strlen(stuff)); 92 | } 93 | 94 | int attribute_align_arg mpg123_add_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count) 95 | { 96 | debug("adding a substring"); 97 | if(sb->fill) /* includes zero byte... */ 98 | { 99 | if( (SIZE_MAX - sb->fill >= count) /* Avoid overflow. */ 100 | && (sb->size >= sb->fill+count || mpg123_grow_string(sb, sb->fill+count)) ) 101 | { 102 | memcpy(sb->p+sb->fill-1, stuff+from, count); 103 | sb->fill += count; 104 | sb->p[sb->fill-1] = 0; /* Terminate! */ 105 | } 106 | else return 0; 107 | } 108 | else 109 | { 110 | if( count < SIZE_MAX && mpg123_grow_string(sb, count+1) ) 111 | { 112 | memcpy(sb->p, stuff+from, count); 113 | sb->fill = count+1; 114 | sb->p[sb->fill-1] = 0; /* Terminate! */ 115 | } 116 | else return 0; 117 | } 118 | return 1; 119 | } 120 | 121 | int attribute_align_arg mpg123_set_substring(mpg123_string* sb, const char* stuff, size_t from, size_t count) 122 | { 123 | sb->fill = 0; 124 | return mpg123_add_substring(sb, stuff, from, count); 125 | } 126 | 127 | int attribute_align_arg mpg123_set_string(mpg123_string* sb, const char* stuff) 128 | { 129 | sb->fill = 0; 130 | return mpg123_add_string(sb, stuff); 131 | } 132 | -------------------------------------------------------------------------------- /playsound/physfsrwops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code provides a glue layer between PhysicsFS and Simple Directmedia 3 | * Layer's (SDL) RWops i/o abstraction. 4 | * 5 | * License: this code is public domain. I make no warranty that it is useful, 6 | * correct, harmless, or environmentally safe. 7 | * 8 | * This particular file may be used however you like, including copying it 9 | * verbatim into a closed-source project, exploiting it commercially, and 10 | * removing any trace of my name from the source (although I hope you won't 11 | * do that). I welcome enhancements and corrections to this file, but I do 12 | * not require you to send me patches if you make changes. 13 | * 14 | * Unless otherwise stated, the rest of PhysicsFS falls under the GNU Lesser 15 | * General Public License: http://www.gnu.org/licenses/lgpl.txt 16 | * 17 | * SDL falls under the LGPL, too. You can get SDL at http://www.libsdl.org/ 18 | * 19 | * This file was written by Ryan C. Gordon. (icculus@icculus.org). 20 | */ 21 | 22 | #ifndef _INCLUDE_PHYSFSRWOPS_H_ 23 | #define _INCLUDE_PHYSFSRWOPS_H_ 24 | 25 | #include "physfs.h" 26 | #include "SDL.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | * Open a platform-independent filename for reading, and make it accessible 34 | * via an SDL_RWops structure. The file will be closed in PhysicsFS when the 35 | * RWops is closed. PhysicsFS should be configured to your liking before 36 | * opening files through this method. 37 | * 38 | * @param filename File to open in platform-independent notation. 39 | * @return A valid SDL_RWops structure on success, NULL on error. Specifics 40 | * of the error can be gleaned from PHYSFS_getLastError(). 41 | */ 42 | __EXPORT__ SDL_RWops *PHYSFSRWOPS_openRead(const char *fname); 43 | 44 | /** 45 | * Open a platform-independent filename for writing, and make it accessible 46 | * via an SDL_RWops structure. The file will be closed in PhysicsFS when the 47 | * RWops is closed. PhysicsFS should be configured to your liking before 48 | * opening files through this method. 49 | * 50 | * @param filename File to open in platform-independent notation. 51 | * @return A valid SDL_RWops structure on success, NULL on error. Specifics 52 | * of the error can be gleaned from PHYSFS_getLastError(). 53 | */ 54 | __EXPORT__ SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname); 55 | 56 | /** 57 | * Open a platform-independent filename for appending, and make it accessible 58 | * via an SDL_RWops structure. The file will be closed in PhysicsFS when the 59 | * RWops is closed. PhysicsFS should be configured to your liking before 60 | * opening files through this method. 61 | * 62 | * @param filename File to open in platform-independent notation. 63 | * @return A valid SDL_RWops structure on success, NULL on error. Specifics 64 | * of the error can be gleaned from PHYSFS_getLastError(). 65 | */ 66 | __EXPORT__ SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname); 67 | 68 | /** 69 | * Make a SDL_RWops from an existing PhysicsFS file handle. You should 70 | * dispose of any references to the handle after successful creation of 71 | * the RWops. The actual PhysicsFS handle will be destroyed when the 72 | * RWops is closed. 73 | * 74 | * @param handle a valid PhysicsFS file handle. 75 | * @return A valid SDL_RWops structure on success, NULL on error. Specifics 76 | * of the error can be gleaned from PHYSFS_getLastError(). 77 | */ 78 | __EXPORT__ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *handle); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* include-once blocker */ 85 | 86 | /* end of physfsrwops.h ... */ 87 | 88 | -------------------------------------------------------------------------------- /decoders/timidity/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | common.c 21 | 22 | */ 23 | 24 | #if HAVE_CONFIG_H 25 | # include 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "SDL_sound.h" 33 | 34 | #define __SDL_SOUND_INTERNAL__ 35 | #include "SDL_sound_internal.h" 36 | 37 | #include "options.h" 38 | #include "common.h" 39 | 40 | /* The paths in this list will be tried whenever we're reading a file */ 41 | static PathList *pathlist = NULL; /* This is a linked list */ 42 | 43 | /* This is meant to find and open files for reading */ 44 | SDL_RWops *open_file(char *name) 45 | { 46 | SDL_RWops *rw; 47 | 48 | if (!name || !(*name)) 49 | { 50 | SNDDBG(("Attempted to open nameless file.\n")); 51 | return 0; 52 | } 53 | 54 | /* First try the given name */ 55 | 56 | SNDDBG(("Trying to open %s\n", name)); 57 | if ((rw = SDL_RWFromFile(name, "rb"))) 58 | return rw; 59 | 60 | if (name[0] != PATH_SEP) 61 | { 62 | char current_filename[1024]; 63 | PathList *plp = pathlist; 64 | int l; 65 | 66 | while (plp) /* Try along the path then */ 67 | { 68 | *current_filename = 0; 69 | l = strlen(plp->path); 70 | if(l) 71 | { 72 | strcpy(current_filename, plp->path); 73 | if(current_filename[l - 1] != PATH_SEP) 74 | { 75 | current_filename[l] = PATH_SEP; 76 | current_filename[l + 1] = '\0'; 77 | } 78 | } 79 | strcat(current_filename, name); 80 | SNDDBG(("Trying to open %s\n", current_filename)); 81 | if ((rw = SDL_RWFromFile(current_filename, "rb"))) 82 | return rw; 83 | plp = plp->next; 84 | } 85 | } 86 | 87 | /* Nothing could be opened. */ 88 | SNDDBG(("Could not open %s\n", name)); 89 | return 0; 90 | } 91 | 92 | /* This'll allocate memory or die. */ 93 | void *safe_malloc(size_t count) 94 | { 95 | void *p; 96 | 97 | p = malloc(count); 98 | if (p == NULL) 99 | SNDDBG(("Sorry. Couldn't malloc %d bytes.\n", count)); 100 | 101 | return p; 102 | } 103 | 104 | /* This adds a directory to the path list */ 105 | void add_to_pathlist(char *s) 106 | { 107 | PathList *plp = safe_malloc(sizeof(PathList)); 108 | 109 | if (plp == NULL) 110 | return; 111 | 112 | plp->path = safe_malloc(strlen(s) + 1); 113 | if (plp->path == NULL) 114 | { 115 | free(plp); 116 | return; 117 | } 118 | 119 | strcpy(plp->path, s); 120 | plp->next = pathlist; 121 | pathlist = plp; 122 | } 123 | 124 | void free_pathlist(void) 125 | { 126 | PathList *plp = pathlist; 127 | PathList *next; 128 | 129 | while (plp) 130 | { 131 | next = plp->next; 132 | free(plp->path); 133 | free(plp); 134 | plp = next; 135 | } 136 | pathlist = NULL; 137 | } 138 | -------------------------------------------------------------------------------- /decoders/libmpg123/index.c: -------------------------------------------------------------------------------- 1 | /* 2 | index: frame index data structure and functions 3 | 4 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include "index.h" 10 | #include "debug.h" 11 | 12 | /* The next expected frame offset, one step ahead. */ 13 | static off_t fi_next(struct frame_index *fi) 14 | { 15 | return (off_t)fi->fill*fi->step; 16 | } 17 | 18 | /* Shrink down the used index to the half. 19 | Be careful with size = 1 ... there's no shrinking possible there. */ 20 | static void fi_shrink(struct frame_index *fi) 21 | { 22 | if(fi->fill < 2) return; /* Won't shrink below 1. */ 23 | else 24 | { /* Double the step, half the fill. Should work as well for fill%2 = 1 */ 25 | size_t c; 26 | debug2("shrink index with fill %lu and step %lu", (unsigned long)fi->fill, (unsigned long)fi->step); 27 | fi->step *= 2; 28 | fi->fill /= 2; 29 | /* Move the data down. */ 30 | for(c = 0; c < fi->fill; ++c) 31 | fi->data[c] = fi->data[2*c]; 32 | } 33 | 34 | fi->next = fi_next(fi); 35 | } 36 | 37 | void fi_init(struct frame_index *fi) 38 | { 39 | fi->data = NULL; 40 | fi->step = 1; 41 | fi->fill = 0; 42 | fi->size = 0; 43 | fi->grow_size = 0; 44 | fi->next = fi_next(fi); 45 | } 46 | 47 | void fi_exit(struct frame_index *fi) 48 | { 49 | debug2("fi_exit: %p and %lu", (void*)fi->data, (unsigned long)fi->size); 50 | if(fi->size && fi->data != NULL) free(fi->data); 51 | 52 | fi_init(fi); /* Be prepared for further fun, still. */ 53 | } 54 | 55 | int fi_resize(struct frame_index *fi, size_t newsize) 56 | { 57 | off_t *newdata = NULL; 58 | if(newsize == fi->size) return 0; 59 | 60 | if(newsize > 0 && newsize < fi->size) 61 | { /* When we reduce buffer size a bit, shrink stuff. */ 62 | while(fi->fill > newsize){ fi_shrink(fi); } 63 | } 64 | 65 | newdata = safe_realloc(fi->data, newsize*sizeof(off_t)); 66 | if(newsize == 0 || newdata != NULL) 67 | { 68 | fi->data = newdata; 69 | fi->size = newsize; 70 | if(fi->fill > fi->size) fi->fill = fi->size; 71 | 72 | fi->next = fi_next(fi); 73 | debug2("new index of size %lu at %p", (unsigned long)fi->size, (void*)fi->data); 74 | return 0; 75 | } 76 | else 77 | { 78 | error("failed to resize index!"); 79 | return -1; 80 | } 81 | } 82 | 83 | void fi_add(struct frame_index *fi, off_t pos) 84 | { 85 | debug3("wanting to add to fill %lu, step %lu, size %lu", (unsigned long)fi->fill, (unsigned long)fi->step, (unsigned long)fi->size); 86 | if(fi->fill == fi->size) 87 | { /* Index is full, we need to shrink... or grow. */ 88 | /* Store the current frame number to check later if we still want it. */ 89 | off_t framenum = fi->fill*fi->step; 90 | /* If we want not / cannot grow, we shrink. */ 91 | if( !(fi->grow_size && fi_resize(fi, fi->size+fi->grow_size)==0) ) 92 | fi_shrink(fi); 93 | 94 | /* Now check if we still want to add this frame (could be that not, because of changed step). */ 95 | if(fi->next != framenum) return; 96 | } 97 | /* When we are here, we want that frame. */ 98 | if(fi->fill < fi->size) /* safeguard for size=1, or just generally */ 99 | { 100 | debug1("adding to index at %p", (void*)(fi->data+fi->fill)); 101 | fi->data[fi->fill] = pos; 102 | ++fi->fill; 103 | fi->next = fi_next(fi); 104 | debug3("added pos %li to index with fill %lu and step %lu", (long) pos, (unsigned long)fi->fill, (unsigned long)fi->step); 105 | } 106 | } 107 | 108 | void fi_reset(struct frame_index *fi) 109 | { 110 | debug1("reset with size %zu", fi->size); 111 | fi->fill = 0; 112 | fi->step = 1; 113 | fi->next = fi_next(fi); 114 | } 115 | -------------------------------------------------------------------------------- /decoders/libmpg123/decode_mmx.S: -------------------------------------------------------------------------------- 1 | /* 2 | decode_MMX.s: MMX optimized synth 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by the mysterious higway (apparently) 7 | 8 | Thomas' words about a note: 9 | Initially, I found the note "this code comes under GPL" in this file. 10 | After asking Michael about legal status of the MMX files, he said that he got them without any comment and thus I believe that the GPL comment was made by Michael, since he made mpg123 GPL at some time - and marked some files that way, but not all. 11 | Based on that thought, I now consider this file along with the other parts of higway's MMX optimization to be licensed under LGPL 2.1 by Michael's decision. 12 | */ 13 | 14 | #include "mangle.h" 15 | 16 | .text 17 | 18 | .globl ASM_NAME(synth_1to1_MMX) 19 | /* int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo, float *decwins); */ 20 | ASM_NAME(synth_1to1_MMX): 21 | pushl %ebp 22 | pushl %edi 23 | pushl %esi 24 | pushl %ebx 25 | /* stack: 0=ebx, 4=esi, 8=edi, 12=ebp, 16=back, 20=bandPtr, 24=channel, 28=out, 32=buffs, 36=bo, 40=decwins */ 26 | movl 24(%esp),%ecx 27 | movl 28(%esp),%edi 28 | movl $15,%ebx 29 | movl 36(%esp),%edx 30 | leal (%edi,%ecx,2),%edi 31 | decl %ecx 32 | movl 32(%esp),%esi 33 | movl (%edx),%eax 34 | jecxz .L1 35 | decl %eax 36 | andl %ebx,%eax 37 | leal 1088(%esi),%esi 38 | movl %eax,(%edx) 39 | .L1: 40 | leal (%esi,%eax,2),%edx 41 | movl %eax,%ebp 42 | incl %eax 43 | pushl 20(%esp) 44 | andl %ebx,%eax 45 | leal 544(%esi,%eax,2),%ecx 46 | incl %ebx 47 | testl $1, %eax 48 | jnz .L2 49 | xchgl %edx,%ecx 50 | incl %ebp 51 | leal 544(%esi),%esi 52 | .L2: 53 | pushl %edx 54 | pushl %ecx 55 | call ASM_NAME(dct64_MMX) 56 | addl $12,%esp 57 | /* stack like before, pushed 3, incremented again */ 58 | leal 1(%ebx), %ecx 59 | subl %ebp,%ebx 60 | pushl %eax 61 | movl 44(%esp),%eax /* decwins */ 62 | leal (%eax,%ebx,2), %edx 63 | popl %eax 64 | .L3: 65 | movq (%edx),%mm0 66 | pmaddwd (%esi),%mm0 67 | movq 8(%edx),%mm1 68 | pmaddwd 8(%esi),%mm1 69 | movq 16(%edx),%mm2 70 | pmaddwd 16(%esi),%mm2 71 | movq 24(%edx),%mm3 72 | pmaddwd 24(%esi),%mm3 73 | paddd %mm1,%mm0 74 | paddd %mm2,%mm0 75 | paddd %mm3,%mm0 76 | movq %mm0,%mm1 77 | psrlq $32,%mm1 78 | paddd %mm1,%mm0 79 | psrad $13,%mm0 80 | packssdw %mm0,%mm0 81 | movd %mm0,%eax 82 | movw %ax, (%edi) 83 | 84 | leal 32(%esi),%esi 85 | leal 64(%edx),%edx 86 | leal 4(%edi),%edi 87 | loop .L3 88 | 89 | 90 | subl $64,%esi 91 | movl $15,%ecx 92 | .L4: 93 | movq (%edx),%mm0 94 | pmaddwd (%esi),%mm0 95 | movq 8(%edx),%mm1 96 | pmaddwd 8(%esi),%mm1 97 | movq 16(%edx),%mm2 98 | pmaddwd 16(%esi),%mm2 99 | movq 24(%edx),%mm3 100 | pmaddwd 24(%esi),%mm3 101 | paddd %mm1,%mm0 102 | paddd %mm2,%mm0 103 | paddd %mm3,%mm0 104 | movq %mm0,%mm1 105 | psrlq $32,%mm1 106 | paddd %mm0,%mm1 107 | psrad $13,%mm1 108 | packssdw %mm1,%mm1 109 | psubd %mm0,%mm0 110 | psubsw %mm1,%mm0 111 | movd %mm0,%eax 112 | movw %ax,(%edi) 113 | 114 | subl $32,%esi 115 | addl $64,%edx 116 | leal 4(%edi),%edi 117 | loop .L4 118 | emms 119 | popl %ebx 120 | popl %esi 121 | popl %edi 122 | popl %ebp 123 | ret 124 | 125 | /* Mark non-executable stack. */ 126 | #if defined(__linux__) && defined(__ELF__) 127 | .section .note.GNU-stack,"",%progbits 128 | #endif 129 | 130 | -------------------------------------------------------------------------------- /INSTALL.txt: -------------------------------------------------------------------------------- 1 | Building is pretty easy. Please read README, too, as it duplicates and 2 | expands upon much of this information. 3 | 4 | 5 | ALL PLATFORMS: 6 | 7 | Please understand your rights and mine: read the text file COPYING in the root 8 | of the source tree. If you can't abide by it, delete this source tree now. 9 | 10 | The best documentation for the SDL_sound API is SDL_sound.h. It is VERY 11 | heavily commented, and makes an excellent, in-depth reference to all the 12 | functions. The official API reference is generated from this file with 13 | a program called "Doxygen" (http://www.doxygen.org/) 14 | 15 | 16 | Borland C++ Builder for Linux (Kylix 3): 17 | Unzip the "borland.zip" file in the root of the source tree and use the 18 | project files in the newly-created Borland/k3 directory. Makefiles for the 19 | command line compiler are in Borland/freebcc ... 20 | 21 | 22 | Unix: 23 | (If you pulled the source from CVS), run ./bootstrap 24 | 25 | run ./configure --help, and see if there's any options you need. Rerun 26 | configure with those options. If this is confusing to you, just run 27 | ./configure with no options: the defaults are generally decent, and 28 | configure is usually smart enough to figure out what's best.. 29 | 30 | If configuration succeeded, run "make". 31 | 32 | Run "make install" as root to install the library for use on your system. 33 | 34 | This should work for most Unix-style systems, including Linux, *BSD, BeOS, and 35 | MacOS X. Reports of success and failure are welcome. 36 | 37 | 38 | MacOS 9 users: 39 | Included with the source is CWProject.sit, which contains project files for 40 | CodeWarrior 5.0 and later. 41 | 42 | 43 | MacOS X command line tools: 44 | You can use the "UNIX" instructions above if you like the command line tools. 45 | 46 | 47 | MacOS X Project Builder: 48 | If you prefer to use Project Builder, use the project files included with 49 | this source: PBProjects.tar.gz...unpack it in the root of the SDL_sound 50 | folder. This archive contains several external libraries you would have 51 | to download/install manually if you used the command line tools (these 52 | libraries are for extra decoders, and are NOT required for SDL_sound to 53 | function...however, without them, the number of sound formats you can 54 | decode is reduced.) 55 | 56 | 57 | BeOS: 58 | You can use the "UNIX" instructions above, too. 59 | 60 | 61 | Win32 Visual C: 62 | For Visual C, use: 63 | http://icculus.org/SDL_sound/downloads/sdl_sound_visualc_srcs.zip 64 | ...and unzip it somewhere. This zipfile has a complete copy of the 65 | SDL_sound sources, Visual C project files, and several external libraries, 66 | too. This zip is everything you should need, and you can scrap this copy of 67 | the source. 68 | 69 | 70 | Win32 Cygwin: 71 | Cygwin users can try their luck with the Unix build instructions in this 72 | tarball instead. 73 | 74 | 75 | Win32 Borland C++ Builder 6: 76 | Unzip the "borland.zip" file in the root of the source tree and use the 77 | project files in the newly-created Borland/bcb6 directory. Makefiles for the 78 | command line compiler are in Borland/freebcc ... these are unmaintained, and 79 | you will need to go find the external libraries you want to use (those that 80 | wish to maintain these project files should contact me). 81 | 82 | 83 | If building is successful, there will be a shared library and a binary 84 | called "playsound". 85 | 86 | 87 | Windows CE (Microsoft PocketPC): 88 | You'll need Microsoft's PocketPC development environment, and this zipfile: 89 | http://icculus.org/SDL_sound/downloads/SDL_soundCE.zip 90 | 91 | Unzip that into the root of this source tree. The new "wce" directory has 92 | project files, and the source to some of the external decoders is included. 93 | Note that not all of the decoders are supported on PocketPC (but please, do 94 | send us patches if you get them working!) 95 | 96 | 97 | OTHER PLATFORMS: 98 | 99 | Send me patches, and instructions, and I'll list them here. Consider 100 | joining the SDL_sound mailing list. Details are at: 101 | http://icculus.org/SDL_sound/ 102 | 103 | --ryan. (icculus@icculus.org) 104 | 105 | 106 | -------------------------------------------------------------------------------- /mixer/mixercore.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An sound processing toolkit. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /** 21 | * This file implements the mixer itself. Largely, this is handled in the 22 | * SDL audio callback. 23 | * 24 | * Documentation is in SDL_sound.h ... It's verbose, honest. :) 25 | * 26 | * Please see the file LICENSE.txt in the source's root directory. 27 | * 28 | * This file written by Ryan C. Gordon. (icculus@icculus.org) 29 | */ 30 | 31 | #if HAVE_CONFIG_H 32 | # include 33 | #endif 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include "SDL.h" 40 | #include "SDL_thread.h" 41 | #include "SDL_sound.h" 42 | 43 | #define __SDL_SOUND_INTERNAL__ 44 | #include "SDL_sound_internal.h" 45 | 46 | 47 | 48 | typedef struct S_PlayingList 49 | { 50 | Sound_Sample *sample; 51 | struct S_PlayingList *next; 52 | } PlayingList; 53 | 54 | static PlayingList *playlist = NULL; 55 | 56 | static inline void mix_predecoded(Sound_Sample *samp, 57 | UInt32 *samp_frames_left, 58 | float *gains) 59 | { 60 | Sound_SampleInternal *internal = (Sound_SampleInternal *) samp->opaque; 61 | Uint32 sfl = *samp_frames_left; /* move to a local. */ 62 | Uint32 max = internal->buffer_size - internal->mix_position; 63 | float *wptr; /* write pointer */ 64 | 65 | /* !!! FIXME: max must be converted to sample frame count... */ 66 | 67 | if (max > sfl) /* we have more data than mix buffer? */ 68 | max = sfl; 69 | 70 | assert(max > 0); 71 | *samp_frames_left -= max; 72 | 73 | wptr = mixbuf + ((mixbufsize / sizeof (float)) - (max * MAX_CHANNELS)); 74 | internal->mix(wptr, internal->buffer, max, gains); 75 | } /* mix_predecoded */ 76 | 77 | 78 | static void mix_playing_samples(Uint8 *stream, int len) 79 | { 80 | PlayingList *samples = playlist; 81 | const int frames = len / framesize; 82 | const Uint32 ticks = SDL_GetTicks(); /* used for calculating fade. */ 83 | 84 | while (samples) /* iterate linked list of playing samples... */ 85 | { 86 | Sound_Sample *samp = samples->sample; 87 | Uint32 sample_frames_left = mixbuf_frames; 88 | float gains[MAX_CHANNELS]; 89 | 90 | calculate_gains(samp, ticks, gains); 91 | while (sample_frames_left) 92 | { 93 | mix_predecoded(samp, &sample_frames_left); 94 | if (!decode_more(samp)) 95 | break; 96 | } /* while */ 97 | 98 | samples = samples->next; /* set up for next iteration. */ 99 | } /* while */ 100 | } /* mix_playing_samples */ 101 | 102 | 103 | static inline void run_pre_mix(void) 104 | { 105 | if (premixer) 106 | premixer(mixbuf, mixbufsize); 107 | else /* !!! FIXME: Do memset in another thread after mix is done. */ 108 | memset(mixbuf, '\0', mixbufsize * sizeof (float) * 2); 109 | } /* run_pre_mix */ 110 | 111 | 112 | static inline void run_post_mix(void) 113 | { 114 | if (postmixer) 115 | postmixer(mixbuf, mixbufsize); 116 | } /* run_post_mix */ 117 | 118 | 119 | /* this is where it happens: the SDL audio callback. */ 120 | static void audio_callback(void *userdata, Uint8 *stream, int len) 121 | { 122 | mixer_callback_running = 1; 123 | run_pre_mix(); 124 | mix_playing_samples(); 125 | run_post_mix(); 126 | mixer_callback_running = 0; 127 | } /* audio_callback */ 128 | 129 | /* end of mixercore.c ... */ 130 | 131 | -------------------------------------------------------------------------------- /decoders/libmpg123/reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | reader: reading input data 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis (after code from Michael Hipp) 7 | */ 8 | 9 | #ifndef MPG123_READER_H 10 | #define MPG123_READER_H 11 | 12 | #include "config.h" 13 | #include "mpg123.h" 14 | 15 | struct buffy 16 | { 17 | unsigned char *data; 18 | ssize_t size; 19 | struct buffy *next; 20 | }; 21 | 22 | struct bufferchain 23 | { 24 | struct buffy* first; /* The beginning of the chain. */ 25 | struct buffy* last; /* The end... of the chain. */ 26 | ssize_t size; /* Aggregated size of all buffies. */ 27 | /* These positions are relative to buffer chain beginning. */ 28 | ssize_t pos; /* Position in whole chain. */ 29 | ssize_t firstpos; /* The point of return on non-forget() */ 30 | /* The "real" filepos is fileoff + pos. */ 31 | off_t fileoff; /* Beginning of chain is at this file offset. */ 32 | }; 33 | 34 | struct reader_data 35 | { 36 | off_t filelen; /* total file length or total buffer size */ 37 | off_t filepos; /* position in file or position in buffer chain */ 38 | int filept; 39 | int flags; 40 | #ifndef WIN32 41 | long timeout_sec; 42 | #endif 43 | ssize_t (*fdread) (mpg123_handle *, void *, size_t); 44 | /* User can replace the read and lseek functions. The r_* are the stored replacement functions or NULL, 45 | The second two pointers are the actual workers (default map to POSIX read/lseek). */ 46 | ssize_t (*r_read) (int fd, void *buf, size_t count); 47 | off_t (*r_lseek)(int fd, off_t offset, int whence); 48 | ssize_t (*read) (int fd, void *buf, size_t count); 49 | off_t (*lseek)(int fd, off_t offset, int whence); 50 | /* Buffered readers want that abstracted, set internally. */ 51 | ssize_t (*fullread)(mpg123_handle *, unsigned char *, ssize_t); 52 | struct bufferchain buffer; /* Not dynamically allocated, these few struct bytes aren't worth the trouble. */ 53 | }; 54 | 55 | /* start to use off_t to properly do LFS in future ... used to be long */ 56 | struct reader 57 | { 58 | int (*init) (mpg123_handle *); 59 | void (*close) (mpg123_handle *); 60 | ssize_t (*fullread) (mpg123_handle *, unsigned char *, ssize_t); 61 | int (*head_read) (mpg123_handle *, unsigned long *newhead); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */ 62 | int (*head_shift) (mpg123_handle *, unsigned long *head); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */ 63 | off_t (*skip_bytes) (mpg123_handle *, off_t len); /* succ: >=0, else error or READER_MORE */ 64 | int (*read_frame_body)(mpg123_handle *, unsigned char *, int size); 65 | int (*back_bytes) (mpg123_handle *, off_t bytes); 66 | int (*seek_frame) (mpg123_handle *, off_t num); 67 | off_t (*tell) (mpg123_handle *); 68 | void (*rewind) (mpg123_handle *); 69 | void (*forget) (mpg123_handle *); 70 | }; 71 | 72 | /* Open a file by path or use an opened file descriptor. */ 73 | int open_stream(mpg123_handle *, const char *path, int fd); 74 | 75 | /* feed based operation has some specials */ 76 | int open_feed(mpg123_handle *); 77 | /* externally called function, returns 0 on success, -1 on error */ 78 | int feed_more(mpg123_handle *fr, const unsigned char *in, long count); 79 | void feed_forget(mpg123_handle *fr); /* forget the data that has been read (free some buffers) */ 80 | off_t feed_set_pos(mpg123_handle *fr, off_t pos); /* Set position (inside available data if possible), return wanted byte offset of next feed. */ 81 | 82 | void open_bad(mpg123_handle *); 83 | 84 | #define READER_FD_OPENED 0x1 85 | #define READER_ID3TAG 0x2 86 | #define READER_SEEKABLE 0x4 87 | #define READER_BUFFERED 0x8 88 | #define READER_NONBLOCK 0x20 89 | 90 | #define READER_STREAM 0 91 | #define READER_ICY_STREAM 1 92 | #define READER_FEED 2 93 | /* These two add a little buffering to enable small seeks for peek ahead. */ 94 | #define READER_BUF_STREAM 3 95 | #define READER_BUF_ICY_STREAM 4 96 | 97 | #ifdef READ_SYSTEM 98 | #define READER_SYSTEM 5 99 | #define READERS 6 100 | #else 101 | #define READERS 5 102 | #endif 103 | 104 | #define READER_ERROR MPG123_ERR 105 | #define READER_MORE MPG123_NEED_MORE 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /decoders/timidity/options.h: -------------------------------------------------------------------------------- 1 | /* 2 | TiMidity -- Experimental MIDI to WAVE converter 3 | Copyright (C) 1995 Tuukka Toivonen 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | /* When a patch file can't be opened, one of these extensions is 21 | appended to the filename and the open is tried again. 22 | */ 23 | #define PATCH_EXT_LIST { ".pat", 0 } 24 | 25 | /* Acoustic Grand Piano seems to be the usual default instrument. */ 26 | #define DEFAULT_PROGRAM 0 27 | 28 | /* 9 here is MIDI channel 10, which is the standard percussion channel. 29 | Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. 30 | On the other hand, some files know that 16 is not a drum channel and 31 | try to play music on it. This is now a runtime option, so this isn't 32 | a critical choice anymore. */ 33 | #define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15)) 34 | 35 | /* In percent. */ 36 | #define DEFAULT_AMPLIFICATION 70 37 | 38 | /* Default polyphony */ 39 | #define DEFAULT_VOICES 32 40 | 41 | /* 1000 here will give a control ratio of 22:1 with 22 kHz output. 42 | Higher CONTROLS_PER_SECOND values allow more accurate rendering 43 | of envelopes and tremolo. The cost is CPU time. */ 44 | #define CONTROLS_PER_SECOND 1000 45 | 46 | /* Make envelopes twice as fast. Saves ~20% CPU time (notes decay 47 | faster) and sounds more like a GUS. There is now a command line 48 | option to toggle this as well. */ 49 | #define FAST_DECAY 50 | 51 | /* How many bits to use for the fractional part of sample positions. 52 | This affects tonal accuracy. The entire position counter must fit 53 | in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of 54 | a sample is 1048576 samples (2 megabytes in memory). The GUS gets 55 | by with just 9 bits and a little help from its friends... 56 | "The GUS does not SUCK!!!" -- a happy user :) */ 57 | #define FRACTION_BITS 12 58 | 59 | /* For some reason the sample volume is always set to maximum in all 60 | patch files. Define this for a crude adjustment that may help 61 | equalize instrument volumes. */ 62 | #define ADJUST_SAMPLE_VOLUMES 63 | 64 | /* The number of samples to use for ramping out a dying note. Affects 65 | click removal. */ 66 | #define MAX_DIE_TIME 20 67 | 68 | /**************************************************************************/ 69 | /* Anything below this shouldn't need to be changed unless you're porting 70 | to a new machine with other than 32-bit, big-endian words. */ 71 | /**************************************************************************/ 72 | 73 | /* change FRACTION_BITS above, not these */ 74 | #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS) 75 | #define FRACTION_MASK (~ INTEGER_MASK) 76 | 77 | /* This is enforced by some computations that must fit in an int */ 78 | #define MAX_CONTROL_RATIO 255 79 | 80 | #define MAX_AMPLIFICATION 800 81 | 82 | /* The TiMidity configuration file */ 83 | #define CONFIG_FILE "timidity.cfg" 84 | 85 | /* These affect general volume */ 86 | #define GUARD_BITS 3 87 | #define AMP_BITS (15-GUARD_BITS) 88 | 89 | #define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1) 90 | 91 | #define FSCALE(a,b) (float)((a) * (double)(1<<(b))) 92 | #define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b)))) 93 | 94 | /* Vibrato and tremolo Choices of the Day */ 95 | #define SWEEP_TUNING 38 96 | #define VIBRATO_AMPLITUDE_TUNING 1.0L 97 | #define VIBRATO_RATE_TUNING 38 98 | #define TREMOLO_AMPLITUDE_TUNING 1.0L 99 | #define TREMOLO_RATE_TUNING 38 100 | 101 | #define SWEEP_SHIFT 16 102 | #define RATE_SHIFT 5 103 | 104 | #ifndef PI 105 | #define PI 3.14159265358979323846 106 | #endif 107 | 108 | /* The path separator (D.M.) */ 109 | #ifdef WIN32 110 | # define PATH_SEP '\\' 111 | #else 112 | # define PATH_SEP '/' 113 | #endif 114 | -------------------------------------------------------------------------------- /VisualC/playsound.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="playsound" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=playsound - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "playsound.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "playsound.mak" CFG="playsound - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "playsound - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "playsound - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "playsound - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "playsound___Win32_Release" 36 | # PROP BASE Intermediate_Dir "playsound___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "playsound___Win32_Release" 41 | # PROP Intermediate_Dir "playsound___Win32_Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 sdl.lib sdlmain.lib win32lib\sdl_sound.lib /nologo /subsystem:console /machine:I386 /out:"win32bin/playsound.exe" 54 | 55 | !ELSEIF "$(CFG)" == "playsound - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "playsound___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "playsound___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "playsound___Win32_Debug" 65 | # PROP Intermediate_Dir "playsound___Win32_Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 sdl.lib sdlmain.lib win32lib\sdl_sound_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"win32bin/playsound_d.exe" /pdbtype:sept 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "playsound - Win32 Release" 84 | # Name "playsound - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\playsound\playsound.c 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /decoders/libmpg123/layer1.c: -------------------------------------------------------------------------------- 1 | /* 2 | layer1.c: the layer 1 decoder 3 | 4 | copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | 8 | may have a few bugs after last optimization ... 9 | */ 10 | 11 | #include "mpg123lib_intern.h" 12 | #include "getbits.h" 13 | 14 | void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],mpg123_handle *fr) 15 | { 16 | unsigned int *ba=balloc; 17 | unsigned int *sca = (unsigned int *) scale_index; 18 | 19 | if(fr->stereo == 2) { 20 | int i; 21 | int jsbound = fr->jsbound; 22 | for (i=0;istereo == 2) { 64 | int jsbound = fr->jsbound; 65 | register real *f0 = fraction[0]; 66 | register real *f1 = fraction[1]; 67 | ba = balloc; 68 | for (sample=smpb,i=0;imuls[n+1][*sca++]; 82 | else 83 | *f0++ = 0.0; 84 | if((n=*ba++)) 85 | *f1++ = (real) ( ((-1)<muls[n+1][*sca++]; 86 | else 87 | *f1++ = 0.0; 88 | } 89 | for (i=jsbound;imuls[n+1][*sca++]; 93 | *f1++ = samp * fr->muls[n+1][*sca++]; 94 | } 95 | else 96 | *f0++ = *f1++ = 0.0; 97 | } 98 | for(i=fr->down_sample_sblimit;i<32;i++) 99 | fraction[0][i] = fraction[1][i] = 0.0; 100 | } 101 | else { 102 | register real *f0 = fraction[0]; 103 | ba = balloc; 104 | for (sample=smpb,i=0;imuls[n+1][*sca++]; 111 | else 112 | *f0++ = 0.0; 113 | } 114 | for(i=fr->down_sample_sblimit;i<32;i++) 115 | fraction[0][i] = 0.0; 116 | } 117 | } 118 | 119 | int do_layer1(mpg123_handle *fr) 120 | { 121 | int clip=0; 122 | int i,stereo = fr->stereo; 123 | unsigned int balloc[2*SBLIMIT]; 124 | unsigned int scale_index[2][SBLIMIT]; 125 | ALIGNED(16) real fraction[2][SBLIMIT]; 126 | int single = fr->single; 127 | 128 | fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32; 129 | 130 | if(stereo == 1 || single == SINGLE_MIX) /* I don't see mixing handled here */ 131 | single = SINGLE_LEFT; 132 | 133 | I_step_one(balloc,scale_index,fr); 134 | 135 | for (i=0;isynth_mono)( (real *) fraction[single], fr); 142 | } 143 | else 144 | { 145 | clip += (fr->synth)( (real *) fraction[0], 0, fr, 0); 146 | clip += (fr->synth)( (real *) fraction[1], 1, fr, 1); 147 | } 148 | } 149 | 150 | return clip; 151 | } 152 | 153 | 154 | -------------------------------------------------------------------------------- /decoders/libmpg123/dct64.c: -------------------------------------------------------------------------------- 1 | /* 2 | dct64.c: DCT64, the plain C version 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | */ 8 | 9 | /* 10 | * Discrete Cosine Tansform (DCT) for subband synthesis 11 | * 12 | * -funroll-loops (for gcc) will remove the loops for better performance 13 | * using loops in the source-code enhances readabillity 14 | * 15 | * 16 | * TODO: write an optimized version for the down-sampling modes 17 | * (in these modes the bands 16-31 (2:1) or 8-31 (4:1) are zero 18 | */ 19 | 20 | #include "mpg123lib_intern.h" 21 | 22 | void dct64(real *out0,real *out1,real *samples) 23 | { 24 | real bufs[64]; 25 | 26 | { 27 | register int i,j; 28 | register real *b1,*b2,*bs,*costab; 29 | 30 | b1 = samples; 31 | bs = bufs; 32 | costab = pnts[0]+16; 33 | b2 = b1 + 32; 34 | 35 | for(i=15;i>=0;i--) 36 | *bs++ = (*b1++ + *--b2); 37 | for(i=15;i>=0;i--) 38 | *bs++ = REAL_MUL((*--b2 - *b1++), *--costab); 39 | 40 | b1 = bufs; 41 | costab = pnts[1]+8; 42 | b2 = b1 + 16; 43 | 44 | { 45 | for(i=7;i>=0;i--) 46 | *bs++ = (*b1++ + *--b2); 47 | for(i=7;i>=0;i--) 48 | *bs++ = REAL_MUL((*--b2 - *b1++), *--costab); 49 | b2 += 32; 50 | costab += 8; 51 | for(i=7;i>=0;i--) 52 | *bs++ = (*b1++ + *--b2); 53 | for(i=7;i>=0;i--) 54 | *bs++ = REAL_MUL((*b1++ - *--b2), *--costab); 55 | b2 += 32; 56 | } 57 | 58 | bs = bufs; 59 | costab = pnts[2]; 60 | b2 = b1 + 8; 61 | 62 | for(j=2;j;j--) 63 | { 64 | for(i=3;i>=0;i--) 65 | *bs++ = (*b1++ + *--b2); 66 | for(i=3;i>=0;i--) 67 | *bs++ = REAL_MUL((*--b2 - *b1++), costab[i]); 68 | b2 += 16; 69 | for(i=3;i>=0;i--) 70 | *bs++ = (*b1++ + *--b2); 71 | for(i=3;i>=0;i--) 72 | *bs++ = REAL_MUL((*b1++ - *--b2), costab[i]); 73 | b2 += 16; 74 | } 75 | 76 | b1 = bufs; 77 | costab = pnts[3]; 78 | b2 = b1 + 4; 79 | 80 | for(j=4;j;j--) 81 | { 82 | *bs++ = (*b1++ + *--b2); 83 | *bs++ = (*b1++ + *--b2); 84 | *bs++ = REAL_MUL((*--b2 - *b1++), costab[1]); 85 | *bs++ = REAL_MUL((*--b2 - *b1++), costab[0]); 86 | b2 += 8; 87 | *bs++ = (*b1++ + *--b2); 88 | *bs++ = (*b1++ + *--b2); 89 | *bs++ = REAL_MUL((*b1++ - *--b2), costab[1]); 90 | *bs++ = REAL_MUL((*b1++ - *--b2), costab[0]); 91 | b2 += 8; 92 | } 93 | bs = bufs; 94 | costab = pnts[4]; 95 | 96 | for(j=8;j;j--) 97 | { 98 | real v0,v1; 99 | v0=*b1++; v1 = *b1++; 100 | *bs++ = (v0 + v1); 101 | *bs++ = REAL_MUL((v0 - v1), (*costab)); 102 | v0=*b1++; v1 = *b1++; 103 | *bs++ = (v0 + v1); 104 | *bs++ = REAL_MUL((v1 - v0), (*costab)); 105 | } 106 | 107 | } 108 | 109 | 110 | { 111 | register real *b1; 112 | register int i; 113 | 114 | for(b1=bufs,i=8;i;i--,b1+=4) 115 | b1[2] += b1[3]; 116 | 117 | for(b1=bufs,i=4;i;i--,b1+=8) 118 | { 119 | b1[4] += b1[6]; 120 | b1[6] += b1[5]; 121 | b1[5] += b1[7]; 122 | } 123 | 124 | for(b1=bufs,i=2;i;i--,b1+=16) 125 | { 126 | b1[8] += b1[12]; 127 | b1[12] += b1[10]; 128 | b1[10] += b1[14]; 129 | b1[14] += b1[9]; 130 | b1[9] += b1[13]; 131 | b1[13] += b1[11]; 132 | b1[11] += b1[15]; 133 | } 134 | } 135 | 136 | 137 | out0[0x10*16] = bufs[0]; 138 | out0[0x10*15] = bufs[16+0] + bufs[16+8]; 139 | out0[0x10*14] = bufs[8]; 140 | out0[0x10*13] = bufs[16+8] + bufs[16+4]; 141 | out0[0x10*12] = bufs[4]; 142 | out0[0x10*11] = bufs[16+4] + bufs[16+12]; 143 | out0[0x10*10] = bufs[12]; 144 | out0[0x10* 9] = bufs[16+12] + bufs[16+2]; 145 | out0[0x10* 8] = bufs[2]; 146 | out0[0x10* 7] = bufs[16+2] + bufs[16+10]; 147 | out0[0x10* 6] = bufs[10]; 148 | out0[0x10* 5] = bufs[16+10] + bufs[16+6]; 149 | out0[0x10* 4] = bufs[6]; 150 | out0[0x10* 3] = bufs[16+6] + bufs[16+14]; 151 | out0[0x10* 2] = bufs[14]; 152 | out0[0x10* 1] = bufs[16+14] + bufs[16+1]; 153 | out0[0x10* 0] = bufs[1]; 154 | 155 | out1[0x10* 0] = bufs[1]; 156 | out1[0x10* 1] = bufs[16+1] + bufs[16+9]; 157 | out1[0x10* 2] = bufs[9]; 158 | out1[0x10* 3] = bufs[16+9] + bufs[16+5]; 159 | out1[0x10* 4] = bufs[5]; 160 | out1[0x10* 5] = bufs[16+5] + bufs[16+13]; 161 | out1[0x10* 6] = bufs[13]; 162 | out1[0x10* 7] = bufs[16+13] + bufs[16+3]; 163 | out1[0x10* 8] = bufs[3]; 164 | out1[0x10* 9] = bufs[16+3] + bufs[16+11]; 165 | out1[0x10*10] = bufs[11]; 166 | out1[0x10*11] = bufs[16+11] + bufs[16+7]; 167 | out1[0x10*12] = bufs[7]; 168 | out1[0x10*13] = bufs[16+7] + bufs[16+15]; 169 | out1[0x10*14] = bufs[15]; 170 | out1[0x10*15] = bufs[16+15]; 171 | 172 | } 173 | 174 | 175 | -------------------------------------------------------------------------------- /decoders/libmpg123/mpg123lib_intern.h: -------------------------------------------------------------------------------- 1 | /* 2 | mpg123lib_intern: Common non-public stuff for libmpg123 3 | 4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | 7 | derived from the old mpg123.h 8 | */ 9 | 10 | #ifndef MPG123_H_INTERN 11 | #define MPG123_H_INTERN 12 | 13 | #define MPG123_RATES 9 14 | #define MPG123_ENCODINGS 10 15 | 16 | /* ABI conformance for other compilers. 17 | mpg123 needs 16byte-aligned stack for SSE and friends. 18 | gcc provides that, but others don't necessarily. */ 19 | #ifndef attribute_align_arg 20 | #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1) 21 | # define attribute_align_arg __attribute__((force_align_arg_pointer)) 22 | /* The gcc that can align the stack does not need the check... nor does it work with gcc 4.3+, anyway. */ 23 | #else 24 | # define attribute_align_arg 25 | # define NEED_ALIGNCHECK /* Other compilers get code to catch misaligned stack. */ 26 | #endif 27 | #endif 28 | 29 | /* export DLL symbols */ 30 | #if defined(WIN32) && defined(DYNAMIC_BUILD) 31 | #define BUILD_MPG123_DLL 32 | #endif 33 | #include "config.h" /* Load this before mpg123.h, for example for largefile stuff. */ 34 | #include "compat.h" 35 | #include "mpg123.h" 36 | 37 | #define SKIP_JUNK 1 38 | 39 | #ifndef M_PI 40 | # define M_PI 3.14159265358979323846 41 | #endif 42 | #ifndef M_SQRT2 43 | # define M_SQRT2 1.41421356237309504880 44 | #endif 45 | 46 | #ifdef SUNOS 47 | #define memmove(dst,src,size) bcopy(src,dst,size) 48 | #endif 49 | 50 | /* some stuff has to go back to mpg123.h */ 51 | #ifdef REAL_IS_FLOAT 52 | # define real float 53 | # define REAL_SCANF "%f" 54 | # define REAL_PRINTF "%f" 55 | #elif defined(REAL_IS_LONG_DOUBLE) 56 | # define real long double 57 | # define REAL_SCANF "%Lf" 58 | # define REAL_PRINTF "%Lf" 59 | #elif defined(REAL_IS_FIXED) 60 | # define real long 61 | 62 | # define REAL_RADIX 15 63 | # define REAL_FACTOR (32.0 * 1024.0) 64 | 65 | # define REAL_PLUS_32767 ( 32767 << REAL_RADIX ) 66 | # define REAL_MINUS_32768 ( -32768 << REAL_RADIX ) 67 | 68 | /* I just changed the (int) to (long) there... seemed right. */ 69 | # define DOUBLE_TO_REAL(x) ((long)((x) * REAL_FACTOR)) 70 | # define REAL_TO_DOUBLE(x) ((double)(x) / REAL_FACTOR) 71 | # define REAL_TO_SHORT(x) ((x) >> REAL_RADIX) 72 | # define REAL_MUL(x, y) (((long long)(x) * (long long)(y)) >> REAL_RADIX) 73 | # define REAL_SCANF "%ld" 74 | # define REAL_PRINTF "%ld" 75 | 76 | #else 77 | # define real double 78 | # define REAL_SCANF "%lf" 79 | # define REAL_PRINTF "%f" 80 | #endif 81 | 82 | #ifndef DOUBLE_TO_REAL 83 | # define DOUBLE_TO_REAL(x) (x) 84 | #endif 85 | #ifndef REAL_TO_DOUBLE 86 | # define REAL_TO_DOUBLE(x) (x) 87 | #endif 88 | #ifndef REAL_TO_SHORT 89 | # define REAL_TO_SHORT(x) (x) 90 | #endif 91 | #ifndef REAL_PLUS_32767 92 | # define REAL_PLUS_32767 32767.0 93 | #endif 94 | #ifndef REAL_MINUS_32768 95 | # define REAL_MINUS_32768 -32768.0 96 | #endif 97 | #ifndef REAL_MUL 98 | # define REAL_MUL(x, y) ((x) * (y)) 99 | #endif 100 | 101 | /* used to be: AUDIOBUFSIZE = n*64 with n=1,2,3 ... 102 | now: factor on minimum frame buffer size (which takes upsampling into account) */ 103 | #define AUDIOBUFSIZE 2 104 | 105 | #include "true.h" 106 | 107 | #define MAX_NAME_SIZE 81 108 | #define SBLIMIT 32 109 | #define SCALE_BLOCK 12 110 | #define SSLIMIT 18 111 | 112 | /* Same as MPG_M_* */ 113 | #define MPG_MD_STEREO 0 114 | #define MPG_MD_JOINT_STEREO 1 115 | #define MPG_MD_DUAL_CHANNEL 2 116 | #define MPG_MD_MONO 3 117 | 118 | /* float output only for generic decoder! */ 119 | #ifdef FLOATOUT 120 | #define MAXOUTBURST 1.0 121 | #define scale_t double 122 | #else 123 | /* I suspect that 32767 would be a better idea here, but Michael put this in... */ 124 | #define MAXOUTBURST 32768 125 | #define scale_t long 126 | #endif 127 | 128 | /* Pre Shift fo 16 to 8 bit converter table */ 129 | #define AUSHIFT (3) 130 | 131 | #include "decode.h" 132 | #include "parse.h" 133 | #include "optimize.h" 134 | #include "frame.h" 135 | 136 | /* fr is a mpg123_handle* by convention here... */ 137 | #define NOQUIET (!(fr->p.flags & MPG123_QUIET)) 138 | #define VERBOSE (NOQUIET && fr->p.verbose) 139 | #define VERBOSE2 (NOQUIET && fr->p.verbose > 1) 140 | #define VERBOSE3 (NOQUIET && fr->p.verbose > 2) 141 | #define VERBOSE4 (NOQUIET && fr->p.verbose > 3) 142 | #define PVERB(mp, level) (!((mp)->flags & MPG123_QUIET) && (mp)->verbose >= (level)) 143 | 144 | int decode_update(mpg123_handle *mh); 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /VisualC/playsound_static.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="playsound_static" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=playsound_static - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "playsound_static.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "playsound_static.mak" CFG="playsound_static - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "playsound_static - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "playsound_static - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "playsound_static - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "playsound_static___Win32_Release" 36 | # PROP BASE Intermediate_Dir "playsound_static___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "playsound_static___Win32_Release" 41 | # PROP Intermediate_Dir "playsound_static___Win32_Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 sdl.lib sdlmain.lib win32lib/sdl_sound_static.lib vorbis_static.lib vorbisfile_static.lib mikmod_static.lib ogg_static.lib modplug.lib smpeg.lib libFLAC.lib /nologo /subsystem:console /machine:I386 /out:"win32bin/playsound_static.exe" 54 | 55 | !ELSEIF "$(CFG)" == "playsound_static - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "playsound_static___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "playsound_static___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "playsound_static___Win32_Debug" 65 | # PROP Intermediate_Dir "playsound_static___Win32_Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 sdl.lib sdlmain.lib win32lib/sdl_sound_static_d.lib vorbis_static.lib vorbisfile_static.lib mikmod_static.lib ogg_static.lib modplug.lib smpeg.lib libFLAC.lib /nologo /subsystem:console /debug /machine:I386 /out:"win32bin/playsound_static.exe" /pdbtype:sept 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "playsound_static - Win32 Release" 84 | # Name "playsound_static - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\playsound\playsound.c 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /decoders/timidity/FAQ: -------------------------------------------------------------------------------- 1 | ---------------------------*-indented-text-*------------------------------ 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | -------------------------------------------------------------------------- 7 | 8 | Frequently Asked Questions with answers: 9 | 10 | -------------------------------------------------------------------------- 11 | Q: What is it? 12 | 13 | A: Where? Well Chris, TiMidity is a software-only synthesizer, MIDI 14 | renderer, MIDI to WAVE converter, realtime MIDI player for UNIX machines, 15 | even (I've heard) a Netscape helper application. It takes a MIDI file 16 | and writes a WAVE or raw PCM data or plays it on your digital audio 17 | device. It sounds much more realistic than FM synthesis, but you need a 18 | ~100Mhz processor to listen to 32kHz stereo music in the background while 19 | you work. 11kHz mono can be played on a low-end 486, and, to some, it 20 | still sounds better than FM. 21 | 22 | -------------------------------------------------------------------------- 23 | Q: I don't have a GUS, can I use TiMidity? 24 | 25 | A: Yes. That's the point. You don't need a Gravis Ultrasound to use 26 | TiMidity, you just need GUS-compatible patches, which are freely 27 | available on the Internet. See below for pointers. 28 | 29 | -------------------------------------------------------------------------- 30 | Q: I have a GUS, can I use TiMidity? 31 | 32 | A: The DOS port doesn't have GUS support, and TiMidity won't be taking 33 | advantage of the board's internal synthesizer under other operating 34 | systems either. So it kind of defeats the purpose. But you can use it. 35 | 36 | -------------------------------------------------------------------------- 37 | Q: I tried playing a MIDI file I got off the Net but all I got was a 38 | dozen warnings saying "No instrument mapped to tone bank 0, program 39 | xx - this instrument will not be heard". What's wrong? 40 | 41 | A: The General MIDI standard specifies 128 melodic instruments and 42 | some sixty percussion sounds. If you wish to play arbitrary General 43 | MIDI files, you'll need to get more patch files. 44 | 45 | There's a program called Midia for SGI's, which also plays MIDI 46 | files and has a lot more bells and whistles than TiMidity. It uses 47 | GUS-compatible patches, too -- so you can get the 8 MB set at 48 | ftp://archive.cs.umbc.edu/pub/midia for pretty good GM compatibility. 49 | 50 | There are also many excellent patches on the Ultrasound FTP sites. 51 | I can recommend Dustin McCartney's collections gsdrum*.zip and 52 | wow*.zip in the "[.../]sound/patches/files" directory. The huge 53 | ProPats series (pp3-*.zip) contains good patches as well. General 54 | MIDI files can also be found on these sites. 55 | 56 | This site list is from the GUS FAQ: 57 | 58 | > FTP Sites Archive Directories 59 | > --------- ------------------- 60 | > Main N.American Site: archive.orst.edu pub/packages/gravis 61 | > wuarchive.wustl.edu systems/ibmpc/ultrasound 62 | > Main Asian Site: nctuccca.edu.tw PC/ultrasound 63 | > Main European Site: src.doc.ic.ac.uk packages/ultrasound 64 | > Main Australian Site: ftp.mpx.com.au /ultrasound/general 65 | > /ultrasound/submit 66 | > South African Site: ftp.sun.ac.za /pub/packages/ultrasound 67 | > Submissions: archive.epas.utoronto.ca pub/pc/ultrasound/submit 68 | > Newly Validated Files: archive.epas.utoronto.ca pub/pc/ultrasound 69 | > 70 | > Mirrors: garbo.uwasa.fi mirror/ultrasound 71 | > ftp.st.nepean.uws.edu.au pc/ultrasound 72 | > ftp.luth.se pub/msdos/ultrasound 73 | 74 | -------------------------------------------------------------------------- 75 | Q: Some files have awful clicks and pops. 76 | 77 | A: Find out which patch is responsible for the clicking (try "timidity 78 | -P ". Add "strip=tail" in 79 | the config file after its name. If this doesn't fix it, mail me the 80 | patch. 81 | 82 | -------------------------------------------------------------------------- 83 | Q: I'm playing Fantasie Impromptu in the background. When I run Netscape, 84 | the sound gets choppy and it takes ten minutes to load. What can I do? 85 | 86 | A: Here are some things to try: 87 | 88 | - Use a lower sampling rate. 89 | 90 | - Use mono output. This can improve performance by 10-30%. 91 | (Using 8-bit instead of 16-bit output makes no difference.) 92 | 93 | - Use a smaller number of simultaneous voices. 94 | 95 | - Make sure you compiled with FAST_DECAY enabled in options.h 96 | 97 | - Recompile with an Intel-optimized gcc for a 5-15% 98 | performance increase. 99 | 100 | -------------------------------------------------------------------------- 101 | -------------------------------------------------------------------------------- /decoders/timidity/dls2.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | dls2.h 4 | 5 | Description: 6 | 7 | Interface defines and structures for the DLS2 extensions of DLS. 8 | 9 | 10 | Written by Microsoft 1998. Released for public use. 11 | 12 | */ 13 | 14 | #ifndef _INC_DLS2 15 | #define _INC_DLS2 16 | 17 | /* 18 | FOURCC's used in the DLS2 file, in addition to DLS1 chunks 19 | */ 20 | 21 | #define FOURCC_RGN2 mmioFOURCC('r','g','n','2') 22 | #define FOURCC_LAR2 mmioFOURCC('l','a','r','2') 23 | #define FOURCC_ART2 mmioFOURCC('a','r','t','2') 24 | #define FOURCC_CDL mmioFOURCC('c','d','l',' ') 25 | #define FOURCC_DLID mmioFOURCC('d','l','i','d') 26 | 27 | /* 28 | Articulation connection graph definitions. These are in addition to 29 | the definitions in the DLS1 header. 30 | */ 31 | 32 | /* Generic Sources (in addition to DLS1 sources. */ 33 | #define CONN_SRC_POLYPRESSURE 0x0007 /* Polyphonic Pressure */ 34 | #define CONN_SRC_CHANNELPRESSURE 0x0008 /* Channel Pressure */ 35 | #define CONN_SRC_VIBRATO 0x0009 /* Vibrato LFO */ 36 | #define CONN_SRC_MONOPRESSURE 0x000a /* MIDI Mono pressure */ 37 | 38 | 39 | /* Midi Controllers */ 40 | #define CONN_SRC_CC91 0x00db /* Reverb Send */ 41 | #define CONN_SRC_CC93 0x00dd /* Chorus Send */ 42 | 43 | 44 | /* Generic Destinations */ 45 | #define CONN_DST_GAIN 0x0001 /* Same as CONN_DST_ ATTENUATION, but more appropriate terminology. */ 46 | #define CONN_DST_KEYNUMBER 0x0005 /* Key Number Generator */ 47 | 48 | /* Audio Channel Output Destinations */ 49 | #define CONN_DST_LEFT 0x0010 /* Left Channel Send */ 50 | #define CONN_DST_RIGHT 0x0011 /* Right Channel Send */ 51 | #define CONN_DST_CENTER 0x0012 /* Center Channel Send */ 52 | #define CONN_DST_LEFTREAR 0x0013 /* Left Rear Channel Send */ 53 | #define CONN_DST_RIGHTREAR 0x0014 /* Right Rear Channel Send */ 54 | #define CONN_DST_LFE_CHANNEL 0x0015 /* LFE Channel Send */ 55 | #define CONN_DST_CHORUS 0x0080 /* Chorus Send */ 56 | #define CONN_DST_REVERB 0x0081 /* Reverb Send */ 57 | 58 | /* Vibrato LFO Destinations */ 59 | #define CONN_DST_VIB_FREQUENCY 0x0114 /* Vibrato Frequency */ 60 | #define CONN_DST_VIB_STARTDELAY 0x0115 /* Vibrato Start Delay */ 61 | 62 | /* EG1 Destinations */ 63 | #define CONN_DST_EG1_DELAYTIME 0x020B /* EG1 Delay Time */ 64 | #define CONN_DST_EG1_HOLDTIME 0x020C /* EG1 Hold Time */ 65 | #define CONN_DST_EG1_SHUTDOWNTIME 0x020D /* EG1 Shutdown Time */ 66 | 67 | 68 | /* EG2 Destinations */ 69 | #define CONN_DST_EG2_DELAYTIME 0x030F /* EG2 Delay Time */ 70 | #define CONN_DST_EG2_HOLDTIME 0x0310 /* EG2 Hold Time */ 71 | 72 | 73 | /* Filter Destinations */ 74 | #define CONN_DST_FILTER_CUTOFF 0x0500 /* Filter Cutoff Frequency */ 75 | #define CONN_DST_FILTER_Q 0x0501 /* Filter Resonance */ 76 | 77 | 78 | /* Transforms */ 79 | #define CONN_TRN_CONVEX 0x0002 /* Convex Transform */ 80 | #define CONN_TRN_SWITCH 0x0003 /* Switch Transform */ 81 | 82 | 83 | /* Conditional chunk operators */ 84 | #define DLS_CDL_AND 0x0001 /* X = X & Y */ 85 | #define DLS_CDL_OR 0x0002 /* X = X | Y */ 86 | #define DLS_CDL_XOR 0x0003 /* X = X ^ Y */ 87 | #define DLS_CDL_ADD 0x0004 /* X = X + Y */ 88 | #define DLS_CDL_SUBTRACT 0x0005 /* X = X - Y */ 89 | #define DLS_CDL_MULTIPLY 0x0006 /* X = X * Y */ 90 | #define DLS_CDL_DIVIDE 0x0007 /* X = X / Y */ 91 | #define DLS_CDL_LOGICAL_AND 0x0008 /* X = X && Y */ 92 | #define DLS_CDL_LOGICAL_OR 0x0009 /* X = X || Y */ 93 | #define DLS_CDL_LT 0x000A /* X = (X < Y) */ 94 | #define DLS_CDL_LE 0x000B /* X = (X <= Y) */ 95 | #define DLS_CDL_GT 0x000C /* X = (X > Y) */ 96 | #define DLS_CDL_GE 0x000D /* X = (X >= Y) */ 97 | #define DLS_CDL_EQ 0x000E /* X = (X == Y) */ 98 | #define DLS_CDL_NOT 0x000F /* X = !X */ 99 | #define DLS_CDL_CONST 0x0010 /* 32-bit constant */ 100 | #define DLS_CDL_QUERY 0x0011 /* 32-bit value returned from query */ 101 | #define DLS_CDL_QUERYSUPPORTED 0x0012 /* Test to see if query is supported by synth */ 102 | 103 | /* 104 | Loop and release 105 | */ 106 | 107 | #define WLOOP_TYPE_RELEASE 1 108 | 109 | /* 110 | WaveLink chunk 111 | */ 112 | 113 | #define F_WAVELINK_MULTICHANNEL 0x0002 114 | 115 | 116 | /* 117 | DLSID queries for 118 | */ 119 | 120 | DEFINE_GUID(DLSID_GMInHardware, 0x178f2f24, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); 121 | DEFINE_GUID(DLSID_GSInHardware, 0x178f2f25, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); 122 | DEFINE_GUID(DLSID_XGInHardware, 0x178f2f26, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); 123 | DEFINE_GUID(DLSID_SupportsDLS1, 0x178f2f27, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); 124 | DEFINE_GUID(DLSID_SupportsDLS2, 0xf14599e5, 0x4689, 0x11d2, 0xaf, 0xa6, 0x0, 0xaa, 0x0, 0x24, 0xd8, 0xb6); 125 | DEFINE_GUID(DLSID_SampleMemorySize, 0x178f2f28, 0xc364, 0x11d1, 0xa7, 0x60, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12); 126 | DEFINE_GUID(DLSID_ManufacturersID, 0xb03e1181, 0x8095, 0x11d2, 0xa1, 0xef, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); 127 | DEFINE_GUID(DLSID_ProductID, 0xb03e1182, 0x8095, 0x11d2, 0xa1, 0xef, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); 128 | DEFINE_GUID(DLSID_SamplePlaybackRate, 0x2a91f713, 0xa4bf, 0x11d2, 0xbb, 0xdf, 0x0, 0x60, 0x8, 0x33, 0xdb, 0xd8); 129 | 130 | #endif /* _INC_DLS2 */ 131 | -------------------------------------------------------------------------------- /decoders/midi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An abstract sound format decoding API. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* 21 | * MIDI decoder for SDL_sound. 22 | * 23 | * This driver handles MIDI data through a stripped-down version of TiMidity. 24 | * See the documentation in the timidity subdirectory. 25 | * 26 | * Please see the file LICENSE.txt in the source's root directory. 27 | * 28 | * This file written by Torbjörn Andersson. (d91tan@Update.UU.SE) 29 | */ 30 | 31 | #if HAVE_CONFIG_H 32 | # include 33 | #endif 34 | 35 | #ifdef SOUND_SUPPORTS_MIDI 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #include "SDL_sound.h" 42 | 43 | #define __SDL_SOUND_INTERNAL__ 44 | #include "SDL_sound_internal.h" 45 | 46 | #include "timidity.h" 47 | 48 | 49 | static int MIDI_init(void); 50 | static void MIDI_quit(void); 51 | static int MIDI_open(Sound_Sample *sample, const char *ext); 52 | static void MIDI_close(Sound_Sample *sample); 53 | static Uint32 MIDI_read(Sound_Sample *sample); 54 | static int MIDI_rewind(Sound_Sample *sample); 55 | static int MIDI_seek(Sound_Sample *sample, Uint32 ms); 56 | 57 | static const char *extensions_midi[] = { "MIDI", "MID", NULL }; 58 | const Sound_DecoderFunctions __Sound_DecoderFunctions_MIDI = 59 | { 60 | { 61 | extensions_midi, 62 | "MIDI decoder, using a subset of TiMidity", 63 | "Torbjörn Andersson ", 64 | "http://www.icculus.org/SDL_sound/" 65 | }, 66 | 67 | MIDI_init, /* init() method */ 68 | MIDI_quit, /* quit() method */ 69 | MIDI_open, /* open() method */ 70 | MIDI_close, /* close() method */ 71 | MIDI_read, /* read() method */ 72 | MIDI_rewind, /* rewind() method */ 73 | MIDI_seek /* seek() method */ 74 | }; 75 | 76 | 77 | static int MIDI_init(void) 78 | { 79 | BAIL_IF_MACRO(Timidity_Init() < 0, "MIDI: Could not initialise", 0); 80 | return(1); 81 | } /* MIDI_init */ 82 | 83 | 84 | static void MIDI_quit(void) 85 | { 86 | Timidity_Exit(); 87 | } /* MIDI_quit */ 88 | 89 | 90 | static int MIDI_open(Sound_Sample *sample, const char *ext) 91 | { 92 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 93 | SDL_RWops *rw = internal->rw; 94 | SDL_AudioSpec spec; 95 | MidiSong *song; 96 | 97 | spec.channels = 2; 98 | spec.format = AUDIO_S16SYS; 99 | spec.freq = 44100; 100 | spec.samples = 4096; 101 | 102 | song = Timidity_LoadSong(rw, &spec); 103 | BAIL_IF_MACRO(song == NULL, "MIDI: Not a MIDI file.", 0); 104 | Timidity_SetVolume(song, 100); 105 | Timidity_Start(song); 106 | 107 | SNDDBG(("MIDI: Accepting data stream.\n")); 108 | 109 | internal->decoder_private = (void *) song; 110 | internal->total_time = Timidity_GetSongLength(song); 111 | 112 | sample->actual.channels = 2; 113 | sample->actual.rate = 44100; 114 | sample->actual.format = AUDIO_S16SYS; 115 | sample->flags = SOUND_SAMPLEFLAG_CANSEEK; 116 | 117 | return(1); /* we'll handle this data. */ 118 | } /* MIDI_open */ 119 | 120 | 121 | static void MIDI_close(Sound_Sample *sample) 122 | { 123 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 124 | MidiSong *song = (MidiSong *) internal->decoder_private; 125 | 126 | Timidity_FreeSong(song); 127 | } /* MIDI_close */ 128 | 129 | 130 | static Uint32 MIDI_read(Sound_Sample *sample) 131 | { 132 | Uint32 retval; 133 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 134 | MidiSong *song = (MidiSong *) internal->decoder_private; 135 | 136 | retval = Timidity_PlaySome(song, internal->buffer, internal->buffer_size); 137 | 138 | /* Make sure the read went smoothly... */ 139 | if (retval == 0) 140 | sample->flags |= SOUND_SAMPLEFLAG_EOF; 141 | 142 | else if (retval == -1) 143 | sample->flags |= SOUND_SAMPLEFLAG_ERROR; 144 | 145 | /* (next call this EAGAIN may turn into an EOF or error.) */ 146 | else if (retval < internal->buffer_size) 147 | sample->flags |= SOUND_SAMPLEFLAG_EAGAIN; 148 | 149 | return(retval); 150 | } /* MIDI_read */ 151 | 152 | 153 | static int MIDI_rewind(Sound_Sample *sample) 154 | { 155 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 156 | MidiSong *song = (MidiSong *) internal->decoder_private; 157 | 158 | Timidity_Start(song); 159 | return(1); 160 | } /* MIDI_rewind */ 161 | 162 | 163 | static int MIDI_seek(Sound_Sample *sample, Uint32 ms) 164 | { 165 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 166 | MidiSong *song = (MidiSong *) internal->decoder_private; 167 | 168 | Timidity_Seek(song, ms); 169 | return(1); 170 | } /* MIDI_seek */ 171 | 172 | #endif /* SOUND_SUPPORTS_MIDI */ 173 | 174 | 175 | /* end of midi.c ... */ 176 | 177 | -------------------------------------------------------------------------------- /decoders/timidity/timidity.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TiMidity -- Experimental MIDI to WAVE converter 4 | Copyright (C) 1995 Tuukka Toivonen 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | */ 21 | 22 | #ifndef TIMIDITY_H 23 | #define TIMIDITY_H 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef Sint16 sample_t; 29 | typedef Sint32 final_volume_t; 30 | 31 | #define VIBRATO_SAMPLE_INCREMENTS 32 32 | 33 | /* Maximum polyphony. */ 34 | #define MAX_VOICES 48 35 | 36 | typedef struct { 37 | Sint32 38 | loop_start, loop_end, data_length, 39 | sample_rate, low_vel, high_vel, low_freq, high_freq, root_freq; 40 | Sint32 41 | envelope_rate[6], envelope_offset[6]; 42 | float 43 | volume; 44 | sample_t *data; 45 | Sint32 46 | tremolo_sweep_increment, tremolo_phase_increment, 47 | vibrato_sweep_increment, vibrato_control_ratio; 48 | Uint8 49 | tremolo_depth, vibrato_depth, 50 | modes; 51 | Sint8 52 | panning, note_to_use; 53 | } Sample; 54 | 55 | typedef struct { 56 | int 57 | bank, program, volume, sustain, panning, pitchbend, expression, 58 | mono, /* one note only on this channel -- not implemented yet */ 59 | pitchsens; 60 | /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar 61 | processor near you */ 62 | float 63 | pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ 64 | } Channel; 65 | 66 | typedef struct { 67 | Uint8 68 | status, channel, note, velocity; 69 | Sample *sample; 70 | Sint32 71 | orig_frequency, frequency, 72 | sample_offset, sample_increment, 73 | envelope_volume, envelope_target, envelope_increment, 74 | tremolo_sweep, tremolo_sweep_position, 75 | tremolo_phase, tremolo_phase_increment, 76 | vibrato_sweep, vibrato_sweep_position; 77 | 78 | final_volume_t left_mix, right_mix; 79 | 80 | float 81 | left_amp, right_amp, tremolo_volume; 82 | Sint32 83 | vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; 84 | int 85 | vibrato_phase, vibrato_control_ratio, vibrato_control_counter, 86 | envelope_stage, control_counter, panning, panned; 87 | 88 | } Voice; 89 | 90 | typedef struct { 91 | int samples; 92 | Sample *sample; 93 | } Instrument; 94 | 95 | /* Shared data */ 96 | typedef struct { 97 | char *name; 98 | int note, amp, pan, strip_loop, strip_envelope, strip_tail; 99 | } ToneBankElement; 100 | 101 | typedef struct { 102 | ToneBankElement *tone; 103 | Instrument *instrument[128]; 104 | } ToneBank; 105 | 106 | typedef struct { 107 | Sint32 time; 108 | Uint8 channel, type, a, b; 109 | } MidiEvent; 110 | 111 | typedef struct { 112 | MidiEvent event; 113 | void *next; 114 | } MidiEventList; 115 | 116 | struct _DLS_Data; 117 | typedef struct _DLS_Data DLS_Patches; 118 | 119 | typedef struct { 120 | int playing; 121 | SDL_RWops *rw; 122 | Sint32 rate; 123 | Sint32 encoding; 124 | float master_volume; 125 | Sint32 amplification; 126 | DLS_Patches *patches; 127 | ToneBank *tonebank[128]; 128 | ToneBank *drumset[128]; 129 | Instrument *default_instrument; 130 | int default_program; 131 | void (*write)(void *dp, Sint32 *lp, Sint32 c); 132 | int buffer_size; 133 | sample_t *resample_buffer; 134 | Sint32 *common_buffer; 135 | Sint32 *buffer_pointer; 136 | /* These would both fit into 32 bits, but they are often added in 137 | large multiples, so it's simpler to have two roomy ints */ 138 | /* samples per MIDI delta-t */ 139 | Sint32 sample_increment; 140 | Sint32 sample_correction; 141 | Channel channel[16]; 142 | Voice voice[MAX_VOICES]; 143 | int voices; 144 | Sint32 drumchannels; 145 | Sint32 buffered_count; 146 | Sint32 control_ratio; 147 | Sint32 lost_notes; 148 | Sint32 cut_notes; 149 | Sint32 samples; 150 | MidiEvent *events; 151 | MidiEvent *current_event; 152 | MidiEventList *evlist; 153 | Sint32 current_sample; 154 | Sint32 event_count; 155 | Sint32 at; 156 | Sint32 groomed_event_count; 157 | } MidiSong; 158 | 159 | /* Some of these are not defined in timidity.c but are here for convenience */ 160 | 161 | extern int Timidity_Init(void); 162 | extern int Timidity_Init_NoConfig(void); 163 | extern void Timidity_SetVolume(MidiSong *song, int volume); 164 | extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len); 165 | extern DLS_Patches *Timidity_LoadDLS(SDL_RWops *rw); 166 | extern void Timidity_FreeDLS(DLS_Patches *patches); 167 | extern MidiSong *Timidity_LoadDLSSong(SDL_RWops *rw, DLS_Patches *patches, SDL_AudioSpec *audio); 168 | extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio); 169 | extern void Timidity_Start(MidiSong *song); 170 | extern void Timidity_Seek(MidiSong *song, Uint32 ms); 171 | extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */ 172 | extern void Timidity_FreeSong(MidiSong *song); 173 | extern void Timidity_Exit(void); 174 | 175 | #ifdef __cplusplus 176 | } 177 | #endif 178 | #endif /* TIMIDITY_H */ 179 | -------------------------------------------------------------------------------- /decoders/libmpg123/tabinit.c: -------------------------------------------------------------------------------- 1 | /* 2 | tabinit.c: initialize tables... 3 | 4 | copyright ?-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | */ 8 | 9 | #include "mpg123lib_intern.h" 10 | #include "debug.h" 11 | 12 | /* All optimizations share this code - with the exception of MMX */ 13 | #ifndef OPT_MMX_ONLY 14 | /* that altivec alignment part here should not hurt generic code, I hope */ 15 | #ifdef OPT_ALTIVEC 16 | static ALIGNED(16) real cos64[16]; 17 | static ALIGNED(16) real cos32[8]; 18 | static ALIGNED(16) real cos16[4]; 19 | static ALIGNED(16) real cos8[2]; 20 | static ALIGNED(16) real cos4[1]; 21 | #else 22 | static real cos64[16],cos32[8],cos16[4],cos8[2],cos4[1]; 23 | #endif 24 | 25 | real *pnts[] = { cos64,cos32,cos16,cos8,cos4 }; 26 | 27 | 28 | static long intwinbase[] = { 29 | 0, -1, -1, -1, -1, -1, -1, -2, -2, -2, 30 | -2, -3, -3, -4, -4, -5, -5, -6, -7, -7, 31 | -8, -9, -10, -11, -13, -14, -16, -17, -19, -21, 32 | -24, -26, -29, -31, -35, -38, -41, -45, -49, -53, 33 | -58, -63, -68, -73, -79, -85, -91, -97, -104, -111, 34 | -117, -125, -132, -139, -147, -154, -161, -169, -176, -183, 35 | -190, -196, -202, -208, -213, -218, -222, -225, -227, -228, 36 | -228, -227, -224, -221, -215, -208, -200, -189, -177, -163, 37 | -146, -127, -106, -83, -57, -29, 2, 36, 72, 111, 38 | 153, 197, 244, 294, 347, 401, 459, 519, 581, 645, 39 | 711, 779, 848, 919, 991, 1064, 1137, 1210, 1283, 1356, 40 | 1428, 1498, 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962, 41 | 2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063, 2037, 2000, 42 | 1952, 1893, 1822, 1739, 1644, 1535, 1414, 1280, 1131, 970, 43 | 794, 605, 402, 185, -45, -288, -545, -814, -1095, -1388, 44 | -1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788, 45 | -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209, 46 | -8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959, 47 | -9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092, 48 | -7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082, 49 | -70, 998, 2122, 3300, 4533, 5818, 7154, 8540, 9975, 11455, 50 | 12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289, 51 | 30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617, 52 | 48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684, 53 | 64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835, 54 | 73415, 73908, 74313, 74630, 74856, 74992, 75038 }; 55 | 56 | void prepare_decode_tables() 57 | { 58 | int i,k,kr,divv; 59 | real *costab; 60 | 61 | for(i=0;i<5;i++) 62 | { 63 | kr=0x10>>i; divv=0x40>>i; 64 | costab = pnts[i]; 65 | for(k=0;klastscale < 0 ? fr->p.outscale : fr->lastscale), fr->decwin_mmx, fr->decwins); 76 | debug("MMX decode tables done"); 77 | } 78 | #endif 79 | 80 | #ifndef OPT_MMX_ONLY 81 | void make_decode_tables(mpg123_handle *fr) 82 | { 83 | int i,j; 84 | int idx = 0; 85 | scale_t scaleval = -(fr->lastscale < 0 ? fr->p.outscale : fr->lastscale); 86 | debug("MMX decode tables"); 87 | for(i=0,j=0;i<256;i++,j++,idx+=32) 88 | { 89 | if(idx < 512+16) 90 | fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] / 65536.0 * (double) scaleval); 91 | 92 | if(i % 32 == 31) 93 | idx -= 1023; 94 | if(i % 64 == 63) 95 | scaleval = - scaleval; 96 | } 97 | 98 | for( /* i=256 */ ;i<512;i++,j--,idx+=32) 99 | { 100 | if(idx < 512+16) 101 | fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] / 65536.0 * (double) scaleval); 102 | 103 | if(i % 32 == 31) 104 | idx -= 1023; 105 | if(i % 64 == 63) 106 | scaleval = - scaleval; 107 | } 108 | debug("MMX decode tables done"); 109 | } 110 | #endif 111 | 112 | int make_conv16to8_table(mpg123_handle *fr) 113 | { 114 | int i; 115 | int mode = fr->af.encoding; 116 | 117 | /* 118 | * ????: 8.0 is right but on SB cards '2.0' is a better value ??? 119 | */ 120 | const double mul = 8.0; 121 | 122 | if(!fr->conv16to8_buf){ 123 | fr->conv16to8_buf = (unsigned char *) malloc(8192); 124 | if(!fr->conv16to8_buf) { 125 | fr->err = MPG123_ERR_16TO8TABLE; 126 | if(NOQUIET) error("Can't allocate 16 to 8 converter table!"); 127 | return -1; 128 | } 129 | fr->conv16to8 = fr->conv16to8_buf + 4096; 130 | } 131 | 132 | if(fr->af.encoding == MPG123_ENC_ULAW_8){ 133 | double m=127.0 / log(256.0); 134 | int c1; 135 | 136 | for(i=-4096;i<4096;i++) { 137 | /* dunno whether this is a valid transformation rule ?!?!? */ 138 | if(i < 0) 139 | c1 = 127 - (int) (log( 1.0 - 255.0 * (double) i*mul / 32768.0 ) * m); 140 | else 141 | c1 = 255 - (int) (log( 1.0 + 255.0 * (double) i*mul / 32768.0 ) * m); 142 | if((c1 < 0 || c1 > 255) && NOQUIET) error2("Converror %d %d",i,c1); 143 | 144 | if(c1 == 0) 145 | c1 = 2; 146 | fr->conv16to8[i] = (unsigned char) c1; 147 | } 148 | } 149 | else if(mode == MPG123_ENC_SIGNED_8) { 150 | for(i=-4096;i<4096;i++) { 151 | fr->conv16to8[i] = i>>5; 152 | } 153 | } 154 | else if(mode == MPG123_ENC_UNSIGNED_8) { 155 | for(i=-4096;i<4096;i++) { 156 | fr->conv16to8[i] = (i>>5)+128; 157 | } 158 | } 159 | else { 160 | for(i=-4096;i<4096;i++) { 161 | fr->conv16to8[i] = 0; 162 | } 163 | } 164 | return 0; 165 | } 166 | 167 | -------------------------------------------------------------------------------- /decoders/skeleton.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An abstract sound format decoding API. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* 21 | * FMT decoder for SDL_sound. 22 | * 23 | * This driver handles FMT audio data. Blahblahblah... The author should 24 | * have done a search and replace on "fmt" and "FMT" and changed this 25 | * comment. This is the default comment in the skeleton decoder file... 26 | * 27 | * None of this code, even the parts that LOOK right, have been compiled, 28 | * so you cut-and-paste at your own risk. 29 | * 30 | * Please see the file LICENSE.txt in the source's root directory. 31 | * 32 | * This file written by Ryan C. Gordon. (icculus@icculus.org) 33 | */ 34 | 35 | #error DO NOT COMPILE THIS. 36 | #error This is an example decoder skeleton. 37 | #error You should base your code on this file, and remove these error lines 38 | #error from your version. 39 | 40 | #if HAVE_CONFIG_H 41 | # include 42 | #endif 43 | 44 | #ifdef SOUND_SUPPORTS_FMT 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | #include "SDL_sound.h" 51 | 52 | #define __SDL_SOUND_INTERNAL__ 53 | #include "SDL_sound_internal.h" 54 | 55 | static int FMT_init(void); 56 | static void FMT_quit(void); 57 | static int FMT_open(Sound_Sample *sample, const char *ext); 58 | static void FMT_close(Sound_Sample *sample); 59 | static Uint32 FMT_read(Sound_Sample *sample); 60 | static int FMT_rewind(Sound_Sample *sample); 61 | static int FMT_seek(Sound_Sample *sample, Uint32 ms); 62 | 63 | static const char *extensions_fmt[] = { "FMT", NULL }; 64 | const Sound_DecoderFunctions __Sound_DecoderFunctions_FMT = 65 | { 66 | { 67 | extensions_fmt, 68 | "FMT audio format description", 69 | "Ryan C. Gordon ", 70 | "http://www.icculus.org/SDL_sound/" 71 | }, 72 | 73 | FMT_init, /* init() method */ 74 | FMT_quit, /* quit() method */ 75 | FMT_open, /* open() method */ 76 | FMT_close, /* close() method */ 77 | FMT_read, /* read() method */ 78 | FMT_rewind, /* rewind() method */ 79 | FMT_seek /* seek() method */ 80 | }; 81 | 82 | 83 | static int FMT_init(void) 84 | { 85 | /* do any global decoder/library initialization you need here. */ 86 | 87 | return(1); /* initialization successful. */ 88 | } /* FMT_init */ 89 | 90 | 91 | static void FMT_quit(void) 92 | { 93 | /* do any global decoder/library cleanup you need here. */ 94 | } /* FMT_quit */ 95 | 96 | 97 | static int FMT_open(Sound_Sample *sample, const char *ext) 98 | { 99 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 100 | SDL_RWops *rw = internal->rw; 101 | 102 | if (can NOT accept the data) 103 | BAIL_MACRO("FMT: expected X, got Y.", 0); 104 | 105 | SNDDBG(("FMT: Accepting data stream.\n")); 106 | set up sample->actual; 107 | sample->flags = SOUND_SAMPLEFLAG_NONE; 108 | return(1); /* we'll handle this data. */ 109 | } /* FMT_open */ 110 | 111 | 112 | static void FMT_close(Sound_Sample *sample) 113 | { 114 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 115 | clean up anything you put into internal->decoder_private; 116 | } /* FMT_close */ 117 | 118 | 119 | static Uint32 FMT_read(Sound_Sample *sample) 120 | { 121 | Uint32 retval; 122 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 123 | 124 | /* 125 | * We don't actually do any decoding, so we read the fmt data 126 | * directly into the internal buffer... 127 | */ 128 | retval = SDL_RWread(internal->rw, internal->buffer, 129 | 1, internal->buffer_size); 130 | 131 | (or whatever. Do some decoding here...) 132 | 133 | /* Make sure the read went smoothly... */ 134 | if (retval == 0) 135 | sample->flags |= SOUND_SAMPLEFLAG_EOF; 136 | 137 | else if (retval == -1) 138 | sample->flags |= SOUND_SAMPLEFLAG_ERROR; 139 | 140 | /* (next call this EAGAIN may turn into an EOF or error.) */ 141 | else if (retval < internal->buffer_size) 142 | sample->flags |= SOUND_SAMPLEFLAG_EAGAIN; 143 | 144 | (or whatever. retval == number of bytes you put in internal->buffer). 145 | 146 | return(retval); 147 | } /* FMT_read */ 148 | 149 | 150 | static int FMT_rewind(Sound_Sample *sample) 151 | { 152 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 153 | 154 | /* seek to the appropriate place... */ 155 | BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, SEEK_SET) != 0, ERR_IO_ERROR, 0); 156 | 157 | (reset state as necessary.) 158 | 159 | return(1); /* success. */ 160 | } /* FMT_rewind */ 161 | 162 | 163 | static int FMT_seek(Sound_Sample *sample, Uint32 ms) 164 | { 165 | Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 166 | 167 | /* seek to the appropriate place... */ 168 | BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, SEEK_SET) != 0, ERR_IO_ERROR, 0); 169 | 170 | (set state as necessary.) 171 | 172 | return(1); /* success. */ 173 | } /* FMT_seek */ 174 | 175 | 176 | #endif /* SOUND_SUPPORTS_FMT */ 177 | 178 | 179 | /* end of fmt.c ... */ 180 | 181 | -------------------------------------------------------------------------------- /playsound/physfsrwops.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code provides a glue layer between PhysicsFS and Simple Directmedia 3 | * Layer's (SDL) RWops i/o abstraction. 4 | * 5 | * License: this code is public domain. I make no warranty that it is useful, 6 | * correct, harmless, or environmentally safe. 7 | * 8 | * This particular file may be used however you like, including copying it 9 | * verbatim into a closed-source project, exploiting it commercially, and 10 | * removing any trace of my name from the source (although I hope you won't 11 | * do that). I welcome enhancements and corrections to this file, but I do 12 | * not require you to send me patches if you make changes. 13 | * 14 | * Unless otherwise stated, the rest of PhysicsFS falls under the GNU Lesser 15 | * General Public License: http://www.gnu.org/licenses/lgpl.txt 16 | * 17 | * SDL falls under the LGPL, too. You can get SDL at http://www.libsdl.org/ 18 | * 19 | * This file was written by Ryan C. Gordon. (icculus@icculus.org). 20 | */ 21 | 22 | #if SUPPORT_PHYSFS 23 | 24 | #include /* used for SEEK_SET, SEEK_CUR, SEEK_END ... */ 25 | #include "physfsrwops.h" 26 | 27 | static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) 28 | { 29 | PHYSFS_file *handle = (PHYSFS_file *) rw->hidden.unknown.data1; 30 | int pos = 0; 31 | 32 | if (whence == SEEK_SET) 33 | { 34 | pos = offset; 35 | } /* if */ 36 | 37 | else if (whence == SEEK_CUR) 38 | { 39 | PHYSFS_sint64 current = PHYSFS_tell(handle); 40 | if (current == -1) 41 | { 42 | SDL_SetError("Can't find position in file: %s", 43 | PHYSFS_getLastError()); 44 | return(-1); 45 | } /* if */ 46 | 47 | pos = (int) current; 48 | if ( ((PHYSFS_sint64) pos) != current ) 49 | { 50 | SDL_SetError("Can't fit current file position in an int!"); 51 | return(-1); 52 | } /* if */ 53 | 54 | if (offset == 0) /* this is a "tell" call. We're done. */ 55 | return(pos); 56 | 57 | pos += offset; 58 | } /* else if */ 59 | 60 | else if (whence == SEEK_END) 61 | { 62 | PHYSFS_sint64 len = PHYSFS_fileLength(handle); 63 | if (len == -1) 64 | { 65 | SDL_SetError("Can't find end of file: %s", PHYSFS_getLastError()); 66 | return(-1); 67 | } /* if */ 68 | 69 | pos = (int) len; 70 | if ( ((PHYSFS_sint64) pos) != len ) 71 | { 72 | SDL_SetError("Can't fit end-of-file position in an int!"); 73 | return(-1); 74 | } /* if */ 75 | 76 | pos += offset; 77 | } /* else if */ 78 | 79 | else 80 | { 81 | SDL_SetError("Invalid 'whence' parameter."); 82 | return(-1); 83 | } /* else */ 84 | 85 | if ( pos < 0 ) 86 | { 87 | SDL_SetError("Attempt to seek past start of file."); 88 | return(-1); 89 | } /* if */ 90 | 91 | if (!PHYSFS_seek(handle, (PHYSFS_uint64) pos)) 92 | { 93 | SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); 94 | return(-1); 95 | } /* if */ 96 | 97 | return(pos); 98 | } /* physfsrwops_seek */ 99 | 100 | 101 | static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum) 102 | { 103 | PHYSFS_file *handle = (PHYSFS_file *) rw->hidden.unknown.data1; 104 | PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum); 105 | if (rc != maxnum) 106 | { 107 | if (!PHYSFS_eof(handle)) /* not EOF? Must be an error. */ 108 | SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); 109 | } /* if */ 110 | 111 | return((int) rc); 112 | } /* physfsrwops_read */ 113 | 114 | 115 | static int physfsrwops_write(SDL_RWops *rw, const void *ptr, int size, int num) 116 | { 117 | PHYSFS_file *handle = (PHYSFS_file *) rw->hidden.unknown.data1; 118 | PHYSFS_sint64 rc = PHYSFS_write(handle, ptr, size, num); 119 | if (rc != num) 120 | SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); 121 | 122 | return((int) rc); 123 | } /* physfsrwops_write */ 124 | 125 | 126 | static int physfsrwops_close(SDL_RWops *rw) 127 | { 128 | PHYSFS_file *handle = (PHYSFS_file *) rw->hidden.unknown.data1; 129 | if (!PHYSFS_close(handle)) 130 | { 131 | SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); 132 | return(-1); 133 | } /* if */ 134 | 135 | SDL_FreeRW(rw); 136 | return(0); 137 | } /* physfsrwops_close */ 138 | 139 | 140 | static SDL_RWops *create_rwops(PHYSFS_file *handle) 141 | { 142 | SDL_RWops *retval = NULL; 143 | 144 | if (handle == NULL) 145 | SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError()); 146 | else 147 | { 148 | retval = SDL_AllocRW(); 149 | if (retval != NULL) 150 | { 151 | retval->seek = physfsrwops_seek; 152 | retval->read = physfsrwops_read; 153 | retval->write = physfsrwops_write; 154 | retval->close = physfsrwops_close; 155 | retval->hidden.unknown.data1 = handle; 156 | } /* if */ 157 | } /* else */ 158 | 159 | return(retval); 160 | } /* create_rwops */ 161 | 162 | 163 | SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *handle) 164 | { 165 | SDL_RWops *retval = NULL; 166 | if (handle == NULL) 167 | SDL_SetError("NULL pointer passed to PHYSFSRWOPS_makeRWops()."); 168 | else 169 | retval = create_rwops(handle); 170 | 171 | return(retval); 172 | } /* PHYSFSRWOPS_makeRWops */ 173 | 174 | 175 | SDL_RWops *PHYSFSRWOPS_openRead(const char *fname) 176 | { 177 | return(create_rwops(PHYSFS_openRead(fname))); 178 | } /* PHYSFSRWOPS_openRead */ 179 | 180 | 181 | SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname) 182 | { 183 | return(create_rwops(PHYSFS_openWrite(fname))); 184 | } /* PHYSFSRWOPS_openWrite */ 185 | 186 | 187 | SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname) 188 | { 189 | return(create_rwops(PHYSFS_openAppend(fname))); 190 | } /* PHYSFSRWOPS_openAppend */ 191 | 192 | #endif 193 | 194 | /* end of physfsrwops.c ... */ 195 | 196 | -------------------------------------------------------------------------------- /decoders/libmpg123/tabinit_mmx.S: -------------------------------------------------------------------------------- 1 | /* 2 | tabinit_mmx: make_decode_tables_mmx 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by the mysterious higway (apparently) 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | .data 12 | ALIGN32 13 | .globl ASM_NAME(costab_mmxsse) 14 | ASM_NAME(costab_mmxsse): 15 | .long 1056974725 16 | .long 1057056395 17 | .long 1057223771 18 | .long 1057485416 19 | .long 1057855544 20 | .long 1058356026 21 | .long 1059019886 22 | .long 1059897405 23 | .long 1061067246 24 | .long 1062657950 25 | .long 1064892987 26 | .long 1066774581 27 | .long 1069414683 28 | .long 1073984175 29 | .long 1079645762 30 | .long 1092815430 31 | .long 1057005197 32 | .long 1057342072 33 | .long 1058087743 34 | .long 1059427869 35 | .long 1061799040 36 | .long 1065862217 37 | .long 1071413542 38 | .long 1084439708 39 | .long 1057128951 40 | .long 1058664893 41 | .long 1063675095 42 | .long 1076102863 43 | .long 1057655764 44 | .long 1067924853 45 | .long 1060439283 46 | ALIGN32 47 | intwinbase: 48 | .value 0, -1, -1, -1, -1, -1, -1, -2 49 | .value -2, -2, -2, -3, -3, -4, -4, -5 50 | .value -5, -6, -7, -7, -8, -9, -10, -11 51 | .value -13, -14, -16, -17, -19, -21, -24, -26 52 | .value -29, -31, -35, -38, -41, -45, -49, -53 53 | .value -58, -63, -68, -73, -79, -85, -91, -97 54 | .value -104, -111, -117, -125, -132, -139, -147, -154 55 | .value -161, -169, -176, -183, -190, -196, -202, -208 56 | .value -213, -218, -222, -225, -227, -228, -228, -227 57 | .value -224, -221, -215, -208, -200, -189, -177, -163 58 | .value -146, -127, -106, -83, -57, -29, 2, 36 59 | .value 72, 111, 153, 197, 244, 294, 347, 401 60 | .value 459, 519, 581, 645, 711, 779, 848, 919 61 | .value 991, 1064, 1137, 1210, 1283, 1356, 1428, 1498 62 | .value 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962 63 | .value 2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063 64 | .value 2037, 2000, 1952, 1893, 1822, 1739, 1644, 1535 65 | .value 1414, 1280, 1131, 970, 794, 605, 402, 185 66 | .value -45, -288, -545, -814, -1095, -1388, -1692, -2006 67 | .value -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788 68 | .value -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597 69 | .value -7910, -8209, -8491, -8755, -8998, -9219, -9416, -9585 70 | .value -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750 71 | .value -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134 72 | .value -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082 73 | .value -70, 998, 2122, 3300, 4533, 5818, 7154, 8540 74 | .value 9975, 11455, 12980, 14548, 16155, 17799, 19478, 21189 75 | .value 22929, 24694, 26482, 28289, 30112, 31947,-26209,-24360 76 | .value -22511,-20664,-18824,-16994,-15179,-13383,-11610, -9863 77 | .value -8147, -6466, -4822, -3222, -1667, -162, 1289, 2684 78 | .value 4019, 5290, 6494, 7629, 8692, 9679, 10590, 11420 79 | .value 12169, 12835, 13415, 13908, 14313, 14630, 14856, 14992 80 | .value 15038 81 | 82 | intwindiv: 83 | .long 0x47800000 # 65536.0 84 | .text 85 | ALIGN32 86 | /* void make_decode_tables_mmx_asm(long scaleval, float* decwin_mmx, float *decwins); */ 87 | .globl ASM_NAME(make_decode_tables_mmx_asm) 88 | ASM_NAME(make_decode_tables_mmx_asm): 89 | pushl %edi 90 | pushl %esi 91 | pushl %ebx 92 | /* stack: 0=ebx, 4=esi, 8=edi, 12=back, 16=scaleval, 20=decwin_mmx, 24=decwins */ 93 | 94 | xorl %ecx,%ecx 95 | xorl %ebx,%ebx 96 | movl $32,%esi 97 | movl $intwinbase,%edi 98 | negl 16(%esp) /* scaleval */ 99 | pushl $2 /* intwinbase step */ 100 | /* stack: 20=scaleval 24=decwin_mmx, 28=decwins */ 101 | .L00: 102 | cmpl $528,%ecx 103 | jnc .L02 104 | movswl (%edi),%eax 105 | cmpl $intwinbase+444,%edi 106 | jc .L01 107 | addl $60000,%eax 108 | .L01: 109 | pushl %eax 110 | /* stack: 24=scaleval 28=decwin_mmx, 32=decwins */ 111 | fildl (%esp) 112 | fdivs intwindiv 113 | fimull 24(%esp) /* scaleval */ 114 | /* eax used to be popped the line before... I'll just use it here a bit */ 115 | movl 28(%esp),%eax /* decwin_mmx */ 116 | fsts (%eax,%ecx,4) 117 | fstps 64(%eax,%ecx,4) 118 | popl %eax 119 | /* stack: 20=scaleval 24=decwin_mmx, 28=decwins */ 120 | .L02: 121 | leal -1(%esi),%edx 122 | and %ebx,%edx 123 | cmp $31,%edx 124 | jnz .L03 125 | addl $-1023,%ecx 126 | test %esi,%ebx 127 | jz .L03 128 | negl 20(%esp) 129 | .L03: 130 | addl %esi,%ecx 131 | addl (%esp),%edi 132 | incl %ebx 133 | cmpl $intwinbase,%edi 134 | jz .L04 135 | cmp $256,%ebx 136 | jnz .L00 137 | negl (%esp) 138 | jmp .L00 139 | .L04: 140 | popl %eax 141 | 142 | xorl %ecx,%ecx 143 | xorl %ebx,%ebx 144 | pushl $2 /* paired with popl above */ 145 | .L05: 146 | cmpl $528,%ecx 147 | jnc .L11 148 | movswl (%edi),%eax 149 | cmpl $intwinbase+444,%edi 150 | jc .L06 151 | addl $60000,%eax 152 | .L06: 153 | cltd 154 | imull 20(%esp) 155 | shrdl $17,%edx,%eax 156 | cmpl $32767,%eax 157 | movl $1055,%edx 158 | jle .L07 159 | movl $32767,%eax 160 | jmp .L08 161 | .L07: 162 | cmpl $-32767,%eax 163 | jge .L08 164 | movl $-32767,%eax 165 | .L08: 166 | /* going to use ebx for decwins, watch the jumps */ 167 | pushl %ebx 168 | /* stack: 24=scaleval 28=decwin_mmx, 32=decwins */ 169 | movl 32(%esp),%ebx 170 | cmpl $512,%ecx 171 | jnc .L09 172 | subl %ecx,%edx 173 | movw %ax,(%ebx,%edx,2) /* decwins */ 174 | movw %ax,-32(%ebx,%edx,2) 175 | .L09: 176 | testl $1,%ecx 177 | jnz .L10 178 | negl %eax 179 | .L10: 180 | movw %ax,(%ebx,%ecx,2) 181 | movw %ax,32(%ebx,%ecx,2) 182 | popl %ebx /* that has to match the pushl before */ 183 | .L11: 184 | leal -1(%esi),%edx 185 | and %ebx,%edx 186 | cmp $31,%edx 187 | jnz .L12 188 | addl $-1023,%ecx 189 | test %esi,%ebx 190 | jz .L12 191 | negl 20(%esp) 192 | .L12: 193 | addl %esi,%ecx 194 | addl (%esp),%edi 195 | incl %ebx 196 | cmpl $intwinbase,%edi 197 | jz .L13 198 | cmp $256,%ebx 199 | jnz .L05 200 | negl (%esp) 201 | jmp .L05 202 | .L13: 203 | popl %eax 204 | 205 | popl %ebx 206 | popl %esi 207 | popl %edi 208 | ret 209 | 210 | /* Mark non-executable stack. */ 211 | #if defined(__linux__) && defined(__ELF__) 212 | .section .note.GNU-stack,"",%progbits 213 | #endif 214 | -------------------------------------------------------------------------------- /decoders/libmpg123/decode_sse3d.h: -------------------------------------------------------------------------------- 1 | /* 2 | decode_sse3d: Synth for SSE and extended 3DNow (yeah, the name is a relic) 3 | 4 | copyright 2006-2007 by Zuxy Meng/the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by the mysterious higway for MMX (apparently) 7 | then developed into SSE opt by Zuxy Meng, also building on Romain Dolbeau's AltiVec 8 | Both have agreed to distribution under LGPL 2.1 . 9 | 10 | Transformed back into standalone asm, with help of 11 | gcc -S -DHAVE_CONFIG_H -I. -march=pentium -O3 -Wall -pedantic -fno-strict-aliasing -DREAL_IS_FLOAT -c -o decode_mmxsse.{S,c} 12 | 13 | The difference between SSE and 3DNowExt is the dct64 function and the synth function name. 14 | This template here uses the SYNTH_NAME and MPL_DCT64 macros for this - see decode_sse.S and decode_3dnowext.S... 15 | That's not memory efficient since there's doubled code, but it's easier than giving another function pointer. 16 | Maybe I'll change it in future, but now I need something that works. 17 | 18 | Original comment from MPlayer source follows: 19 | */ 20 | 21 | /* 22 | * this code comes under GPL 23 | * This code was taken from http://www.mpg123.org 24 | * See ChangeLog of mpg123-0.59s-pre.1 for detail 25 | * Applied to mplayer by Nick Kurshev 26 | * 27 | * Local ChangeLog: 28 | * - Partial loops unrolling and removing MOVW insn from loops 29 | */ 30 | 31 | #include "mangle.h" 32 | 33 | .data 34 | ALIGN8 35 | one_null: 36 | .long -65536 37 | .long -65536 38 | ALIGN8 39 | null_one: 40 | .long 65535 41 | .long 65535 42 | 43 | .text 44 | ALIGN16,,15 45 | /* void SYNTH_NAME(real *bandPtr, int channel, short *samples, short *buffs, int *bo, float *decwins) */ 46 | .globl SYNTH_NAME 47 | SYNTH_NAME: 48 | pushl %ebp 49 | /* stack:0=ebp 4=back 8=bandptr 12=channel 16=samples 20=buffs 24=bo 28=decwins */ 50 | movl %esp, %ebp 51 | /* Now the old stack addresses are preserved via %epb. */ 52 | subl $4,%esp /* What has been called temp before. */ 53 | pushl %edi 54 | pushl %esi 55 | pushl %ebx 56 | #define TEMP 12(%esp) 57 | #APP 58 | movl 12(%ebp),%ecx 59 | movl 16(%ebp),%edi 60 | movl $15,%ebx 61 | movl 24(%ebp),%edx 62 | leal (%edi,%ecx,2),%edi 63 | decl %ecx 64 | movl 20(%ebp),%esi 65 | movl (%edx),%eax 66 | jecxz .L01 67 | decl %eax 68 | andl %ebx,%eax 69 | leal 1088(%esi),%esi 70 | movl %eax,(%edx) 71 | .L01: 72 | leal (%esi,%eax,2),%edx 73 | movl %eax,TEMP 74 | incl %eax 75 | andl %ebx,%eax 76 | leal 544(%esi,%eax,2),%ecx 77 | incl %ebx 78 | testl $1, %eax 79 | jnz .L02 80 | xchgl %edx,%ecx 81 | incl TEMP 82 | leal 544(%esi),%esi 83 | .L02: 84 | emms 85 | pushl 8(%ebp) 86 | pushl %edx 87 | pushl %ecx 88 | call MPL_DCT64 89 | addl $12, %esp 90 | leal 1(%ebx), %ecx 91 | subl TEMP,%ebx 92 | pushl %ecx 93 | /* leal ASM_NAME(decwins)(%ebx,%ebx,1), %edx */ 94 | movl 28(%ebp),%ecx 95 | leal (%ecx,%ebx,2), %edx 96 | movl (%esp),%ecx /* restore, but leave value on stack */ 97 | shrl $1, %ecx 98 | ALIGN16 99 | .L03: 100 | movq (%edx),%mm0 101 | movq 64(%edx),%mm4 102 | pmaddwd (%esi),%mm0 103 | pmaddwd 32(%esi),%mm4 104 | movq 8(%edx),%mm1 105 | movq 72(%edx),%mm5 106 | pmaddwd 8(%esi),%mm1 107 | pmaddwd 40(%esi),%mm5 108 | movq 16(%edx),%mm2 109 | movq 80(%edx),%mm6 110 | pmaddwd 16(%esi),%mm2 111 | pmaddwd 48(%esi),%mm6 112 | movq 24(%edx),%mm3 113 | movq 88(%edx),%mm7 114 | pmaddwd 24(%esi),%mm3 115 | pmaddwd 56(%esi),%mm7 116 | paddd %mm1,%mm0 117 | paddd %mm5,%mm4 118 | paddd %mm2,%mm0 119 | paddd %mm6,%mm4 120 | paddd %mm3,%mm0 121 | paddd %mm7,%mm4 122 | movq %mm0,%mm1 123 | movq %mm4,%mm5 124 | psrlq $32,%mm1 125 | psrlq $32,%mm5 126 | paddd %mm1,%mm0 127 | paddd %mm5,%mm4 128 | psrad $13,%mm0 129 | psrad $13,%mm4 130 | packssdw %mm0,%mm0 131 | packssdw %mm4,%mm4 132 | movq (%edi), %mm1 133 | punpckldq %mm4, %mm0 134 | pand one_null, %mm1 135 | pand null_one, %mm0 136 | por %mm0, %mm1 137 | movq %mm1,(%edi) 138 | leal 64(%esi),%esi 139 | leal 128(%edx),%edx 140 | leal 8(%edi),%edi 141 | decl %ecx 142 | jnz .L03 143 | popl %ecx 144 | andl $1, %ecx 145 | jecxz .next_loop 146 | movq (%edx),%mm0 147 | pmaddwd (%esi),%mm0 148 | movq 8(%edx),%mm1 149 | pmaddwd 8(%esi),%mm1 150 | movq 16(%edx),%mm2 151 | pmaddwd 16(%esi),%mm2 152 | movq 24(%edx),%mm3 153 | pmaddwd 24(%esi),%mm3 154 | paddd %mm1,%mm0 155 | paddd %mm2,%mm0 156 | paddd %mm3,%mm0 157 | movq %mm0,%mm1 158 | psrlq $32,%mm1 159 | paddd %mm1,%mm0 160 | psrad $13,%mm0 161 | packssdw %mm0,%mm0 162 | movd %mm0,%eax 163 | movw %ax, (%edi) 164 | leal 32(%esi),%esi 165 | leal 64(%edx),%edx 166 | leal 4(%edi),%edi 167 | .next_loop: 168 | subl $64,%esi 169 | movl $7,%ecx 170 | ALIGN16 171 | .L04: 172 | movq (%edx),%mm0 173 | movq 64(%edx),%mm4 174 | pmaddwd (%esi),%mm0 175 | pmaddwd -32(%esi),%mm4 176 | movq 8(%edx),%mm1 177 | movq 72(%edx),%mm5 178 | pmaddwd 8(%esi),%mm1 179 | pmaddwd -24(%esi),%mm5 180 | movq 16(%edx),%mm2 181 | movq 80(%edx),%mm6 182 | pmaddwd 16(%esi),%mm2 183 | pmaddwd -16(%esi),%mm6 184 | movq 24(%edx),%mm3 185 | movq 88(%edx),%mm7 186 | pmaddwd 24(%esi),%mm3 187 | pmaddwd -8(%esi),%mm7 188 | paddd %mm1,%mm0 189 | paddd %mm5,%mm4 190 | paddd %mm2,%mm0 191 | paddd %mm6,%mm4 192 | paddd %mm3,%mm0 193 | paddd %mm7,%mm4 194 | movq %mm0,%mm1 195 | movq %mm4,%mm5 196 | psrlq $32,%mm1 197 | psrlq $32,%mm5 198 | paddd %mm0,%mm1 199 | paddd %mm4,%mm5 200 | psrad $13,%mm1 201 | psrad $13,%mm5 202 | packssdw %mm1,%mm1 203 | packssdw %mm5,%mm5 204 | psubd %mm0,%mm0 205 | psubd %mm4,%mm4 206 | psubsw %mm1,%mm0 207 | psubsw %mm5,%mm4 208 | movq (%edi), %mm1 209 | punpckldq %mm4, %mm0 210 | pand one_null, %mm1 211 | pand null_one, %mm0 212 | por %mm0, %mm1 213 | movq %mm1,(%edi) 214 | subl $64,%esi 215 | addl $128,%edx 216 | leal 8(%edi),%edi 217 | decl %ecx 218 | jnz .L04 219 | movq (%edx),%mm0 220 | pmaddwd (%esi),%mm0 221 | movq 8(%edx),%mm1 222 | pmaddwd 8(%esi),%mm1 223 | movq 16(%edx),%mm2 224 | pmaddwd 16(%esi),%mm2 225 | movq 24(%edx),%mm3 226 | pmaddwd 24(%esi),%mm3 227 | paddd %mm1,%mm0 228 | paddd %mm2,%mm0 229 | paddd %mm3,%mm0 230 | movq %mm0,%mm1 231 | psrlq $32,%mm1 232 | paddd %mm0,%mm1 233 | psrad $13,%mm1 234 | packssdw %mm1,%mm1 235 | psubd %mm0,%mm0 236 | psubsw %mm1,%mm0 237 | movd %mm0,%eax 238 | movw %ax,(%edi) 239 | emms 240 | 241 | #NO_APP 242 | popl %ebx 243 | popl %esi 244 | popl %edi 245 | addl $4,%esp 246 | popl %ebp 247 | ret 248 | -------------------------------------------------------------------------------- /extra_rwops.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An abstract sound format decoding API. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* 21 | * Some extra RWops that are needed or are just handy to have. 22 | * 23 | * Please see the file LICENSE.txt in the source's root directory. 24 | * 25 | * This file written by Ryan C. Gordon. (icculus@icculus.org) 26 | */ 27 | 28 | #include 29 | #include 30 | #include "SDL.h" 31 | 32 | 33 | /* 34 | * The Reference Counter RWops... 35 | */ 36 | 37 | 38 | typedef struct 39 | { 40 | SDL_RWops *rw; /* The actual RWops we're refcounting... */ 41 | int refcount; /* The refcount; starts at 1. If goes to 0, delete. */ 42 | } RWRefCounterData; 43 | 44 | 45 | /* Just pass through to the actual SDL_RWops's method... */ 46 | static int refcounter_seek(SDL_RWops *rw, int offset, int whence) 47 | { 48 | RWRefCounterData *data = (RWRefCounterData *) rw->hidden.unknown.data1; 49 | return(data->rw->seek(data->rw, offset, whence)); 50 | } /* refcounter_seek */ 51 | 52 | 53 | /* Just pass through to the actual SDL_RWops's method... */ 54 | static int refcounter_read(SDL_RWops *rw, void *ptr, int size, int maxnum) 55 | { 56 | RWRefCounterData *data = (RWRefCounterData *) rw->hidden.unknown.data1; 57 | return(data->rw->read(data->rw, ptr, size, maxnum)); 58 | } /* refcounter_read */ 59 | 60 | 61 | /* Just pass through to the actual SDL_RWops's method... */ 62 | static int refcounter_write(SDL_RWops *rw, const void *ptr, int size, int num) 63 | { 64 | RWRefCounterData *data = (RWRefCounterData *) rw->hidden.unknown.data1; 65 | return(data->rw->write(data->rw, ptr, size, num)); 66 | } /* refcounter_write */ 67 | 68 | 69 | /* 70 | * Decrement the reference count. If there are no more references, pass 71 | * through to the actual SDL_RWops's method, and then clean ourselves up. 72 | */ 73 | static int refcounter_close(SDL_RWops *rw) 74 | { 75 | int retval = 0; 76 | RWRefCounterData *data = (RWRefCounterData *) rw->hidden.unknown.data1; 77 | data->refcount--; 78 | if (data->refcount <= 0) 79 | { 80 | retval = data->rw->close(data->rw); 81 | free(data); 82 | SDL_FreeRW(rw); 83 | } /* if */ 84 | 85 | return(retval); 86 | } /* refcounter_close */ 87 | 88 | 89 | void RWops_RWRefCounter_addRef(SDL_RWops *rw) 90 | { 91 | RWRefCounterData *data = (RWRefCounterData *) rw->hidden.unknown.data1; 92 | data->refcount++; 93 | } /* RWops_RWRefCounter_addRef */ 94 | 95 | 96 | SDL_RWops *RWops_RWRefCounter_new(SDL_RWops *rw) 97 | { 98 | SDL_RWops *retval = NULL; 99 | 100 | if (rw == NULL) 101 | { 102 | SDL_SetError("NULL argument to RWops_RWRefCounter_new()."); 103 | return(NULL); 104 | } /* if */ 105 | 106 | retval = SDL_AllocRW(); 107 | if (retval != NULL) 108 | { 109 | RWRefCounterData *data; 110 | data = (RWRefCounterData *) malloc(sizeof (RWRefCounterData)); 111 | if (data == NULL) 112 | { 113 | SDL_SetError("Out of memory."); 114 | SDL_FreeRW(retval); 115 | retval = NULL; 116 | } /* if */ 117 | else 118 | { 119 | data->rw = rw; 120 | data->refcount = 1; 121 | retval->hidden.unknown.data1 = data; 122 | retval->seek = refcounter_seek; 123 | retval->read = refcounter_read; 124 | retval->write = refcounter_write; 125 | retval->close = refcounter_close; 126 | } /* else */ 127 | } /* if */ 128 | 129 | return(retval); 130 | } /* RWops_RWRefCounter_new */ 131 | 132 | 133 | 134 | /* 135 | * RWops pooling... 136 | */ 137 | 138 | static SDL_RWops *rwops_pool = NULL; 139 | static SDL_mutex *rwops_pool_mutex = NULL; 140 | 141 | SDL_RWops *RWops_pooled_alloc(void) 142 | { 143 | SDL_RWops *rw; 144 | if (rwops_pool_mutex == NULL) 145 | return(NULL); /* never initialized. */ 146 | 147 | SDL_LockMutex(rwops_pool_mutex); 148 | rw = rwops_pool; 149 | if (rw) 150 | rwops_pool = (SDL_RWops *) (rw->hidden.unknown.data1); 151 | SDL_UnlockMutex(rwops_pool_mutex); 152 | 153 | if (!rw) 154 | rw = (SDL_RWops *) malloc(sizeof (SDL_RWops)); 155 | 156 | return(rw); 157 | } /* RWops_pooled_alloc */ 158 | 159 | 160 | void RWops_pooled_free(SDL_RWops *rw) 161 | { 162 | if (rwops_pool_mutex == NULL) 163 | return; /* never initialized...why are we here? */ 164 | 165 | if (rw == NULL) 166 | return; 167 | 168 | SDL_LockMutex(rwops_pool_mutex); 169 | rw->hidden.unknown.data1 = rwops_pool; 170 | rwops_pool = rw; 171 | SDL_UnlockMutex(rwops_pool_mutex); 172 | } /* RWops_pooled_free */ 173 | 174 | 175 | int RWops_pooled_init(void) 176 | { 177 | const int preallocate = 50; 178 | int i; 179 | 180 | rwops_pool_mutex = SDL_CreateMutex(); 181 | if (rwops_pool_mutex == NULL) 182 | return(0); 183 | 184 | for (i = 0; i < preallocate; i++) 185 | RWops_pooled_free(RWops_pooled_alloc()); 186 | 187 | return(1); 188 | } /* RWops_pooled_init */ 189 | 190 | 191 | void RWops_pooled_deinit(void) 192 | { 193 | SDL_RWops *cur; 194 | SDL_RWops *next; 195 | 196 | if (rwops_pool_mutex == NULL) 197 | return; /* never initialized. */ 198 | 199 | SDL_LockMutex(rwops_pool_mutex); 200 | /* all allocated rwops must be in the pool now, or the memory leaks. */ 201 | cur = rwops_pool; 202 | rwops_pool = NULL; 203 | SDL_UnlockMutex(rwops_pool_mutex); 204 | SDL_DestroyMutex(rwops_pool_mutex); 205 | rwops_pool_mutex = NULL; 206 | 207 | while (cur) 208 | { 209 | next = (SDL_RWops *) (cur->hidden.unknown.data1); 210 | free(cur); 211 | cur = next; 212 | } /* while */ 213 | } /* RWops_pooled_deinit */ 214 | 215 | /* end of extra_rwops.c ... */ 216 | 217 | 218 | -------------------------------------------------------------------------------- /filter_templates.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Extended Audio Converter for SDL (Simple DirectMedia Layer) 3 | * Copyright (C) 2002 Frank Ranostaj 4 | * Institute of Applied Physik 5 | * Johann Wolfgang Goethe-Universität 6 | * Frankfurt am Main, Germany 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the Free 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * Frank Ranostaj 23 | * ranostaj@stud.uni-frankfurt.de 24 | * 25 | * (This code blatantly abducted for SDL_sound. Thanks, Frank! --ryan.) 26 | */ 27 | 28 | #ifndef Suffix 29 | #error include filter_template.h with defined Suffix macro! 30 | #else 31 | #define CH(x) (Suffix((x)*)) 32 | 33 | /*-------------------------------------------------------------------------*/ 34 | /* this filter (Kaiser-window beta=6.8) gives a decent -80dB attentuation */ 35 | /*-------------------------------------------------------------------------*/ 36 | #define sum_d(v,dx) ((int) v[CH(dx)] + v[CH(1-dx)]) 37 | static Sint16* Suffix(doubleRate)( Sint16 *outp, Sint16 *inp, int length, 38 | VarFilter* filt, RateAux* aux ) 39 | { 40 | int out; 41 | Sint16 *to; 42 | 43 | to = inp - length; 44 | 45 | while( inp > to ) 46 | { 47 | out = 0; 48 | out-= 9 * sum_d( inp, 16); 49 | out+= 23 * sum_d( inp, 15); 50 | out-= 46 * sum_d( inp, 14); 51 | out+= 83 * sum_d( inp, 13); 52 | out-= 138 * sum_d( inp, 12); 53 | out+= 217 * sum_d( inp, 11); 54 | out-= 326 * sum_d( inp, 10); 55 | out+= 474 * sum_d( inp, 9); 56 | out-= 671 * sum_d( inp, 8); 57 | out+= 936 * sum_d( inp, 7); 58 | out-= 1295 * sum_d( inp, 6); 59 | out+= 1800 * sum_d( inp, 5); 60 | out-= 2560 * sum_d( inp, 4); 61 | out+= 3863 * sum_d( inp, 3); 62 | out-= 6764 * sum_d( inp, 2); 63 | out+= 20798 * sum_d( inp, 1); 64 | 65 | outp[CH(1)] = ( 32770 * inp[CH(1)] + out) >> 16; 66 | outp[CH(0)] = ( 32770 * inp[CH(0)] + out) >> 16; 67 | 68 | inp -= CH(1); 69 | outp -= CH(2); 70 | } 71 | 72 | return outp; 73 | } 74 | #undef sum_d 75 | 76 | /*-------------------------------------------------------------------------*/ 77 | #define sum_h(v,dx) ((int) v[CH(dx)] + v[CH(-dx)]) 78 | static Sint16* Suffix(halfRate)( Sint16 *outp, Sint16 *inp, int length, 79 | VarFilter* filt, RateAux* aux ) 80 | { 81 | int out; 82 | Sint16* to; 83 | 84 | to = inp + length; 85 | inp += aux->carry; 86 | 87 | while( inp < to ) 88 | { 89 | out = 0; 90 | out-= 9 * sum_h( inp, 31); 91 | out+= 23 * sum_h( inp, 29); 92 | out-= 46 * sum_h( inp, 27); 93 | out+= 83 * sum_h( inp, 25); 94 | out-= 138 * sum_h( inp, 23); 95 | out+= 217 * sum_h( inp, 21); 96 | out-= 326 * sum_h( inp, 19); 97 | out+= 474 * sum_h( inp, 17); 98 | out-= 671 * sum_h( inp, 15); 99 | out+= 936 * sum_h( inp, 13); 100 | out-= 1295 * sum_h( inp, 11); 101 | out+= 1800 * sum_h( inp, 9); 102 | out-= 2560 * sum_h( inp, 7); 103 | out+= 3863 * sum_h( inp, 5); 104 | out-= 6764 * sum_h( inp, 3); 105 | out+= 20798 * sum_h( inp, 1); 106 | out+= 32770 * (int)inp[0]; 107 | 108 | outp[0] = out >> 16; 109 | 110 | inp += CH(2); 111 | outp += CH(1); 112 | } 113 | 114 | aux->carry = inp < to + CH(1) ? 0 : CH(1); 115 | return outp; 116 | } 117 | #undef sum_h 118 | 119 | /*-------------------------------------------------------------------------*/ 120 | static Sint16* Suffix(increaseRate)( Sint16 *outp, Sint16 *inp, int length, 121 | VarFilter* filter, RateAux* aux ) 122 | { 123 | const static int fsize = CH(2*_fsize); 124 | Sint16 *f; 125 | int out; 126 | int i, pos; 127 | Sint16* to; 128 | 129 | inp -= fsize; 130 | to = inp - length; 131 | pos = aux->pos; 132 | 133 | while( inp > to ) 134 | { 135 | out = 0; 136 | f = filter->c[pos]; 137 | for( i = _fsize + 1; --i; inp+=CH(4), f+=4 ) 138 | { 139 | out+= f[0] * (int)inp[CH(0)]; 140 | out+= f[1] * (int)inp[CH(1)]; 141 | out+= f[2] * (int)inp[CH(2)]; 142 | out+= f[3] * (int)inp[CH(3)]; 143 | } 144 | outp[0] = out >> 16; 145 | 146 | pos = ( pos + filter->ratio.denominator - 1 ) 147 | % filter->ratio.denominator; 148 | inp -= CH( 4 * _fsize ); 149 | inp -= CH( filter->incr[pos] ); 150 | outp -= CH(1); 151 | } 152 | 153 | aux->pos = pos; 154 | return outp; 155 | } 156 | 157 | /*-------------------------------------------------------------------------*/ 158 | static Sint16* Suffix(decreaseRate)( Sint16 *outp, Sint16 *inp, int length, 159 | VarFilter* filter, RateAux* aux ) 160 | { 161 | const static int fsize = CH(2*_fsize); 162 | Sint16 *f; 163 | int out; 164 | int i, pos; 165 | Sint16 *to; 166 | 167 | inp -= fsize; 168 | to = inp + length; 169 | pos = aux->pos; 170 | inp += aux->carry; 171 | 172 | while( inp < to ) 173 | { 174 | out = 0; 175 | f = filter->c[pos]; 176 | for( i = _fsize + 1; --i; inp+=CH(4), f+=4 ) 177 | { 178 | out+= f[0] * (int)inp[CH(0)]; 179 | out+= f[1] * (int)inp[CH(1)]; 180 | out+= f[2] * (int)inp[CH(2)]; 181 | out+= f[3] * (int)inp[CH(3)]; 182 | } 183 | outp[0] = out >> 16; 184 | 185 | inp -= CH( 4 * _fsize ); 186 | inp += CH( filter->incr[pos] ); 187 | outp += CH(1); 188 | pos = ( pos + 1 ) % filter->ratio.denominator; 189 | } 190 | 191 | aux->pos = pos; 192 | aux->carry = inp < to + CH(1) ? 0 : CH(1); 193 | return outp; 194 | } 195 | 196 | /*-------------------------------------------------------------------------*/ 197 | #undef CH 198 | #endif /* Suffix */ 199 | 200 | -------------------------------------------------------------------------------- /mixer/converters.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SDL_sound -- An sound processing toolkit. 3 | * Copyright (C) 2001 Ryan C. Gordon. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /** 21 | * This file implements the mixer itself. Largely, this is handled in the 22 | * SDL audio callback. 23 | * 24 | * Documentation is in SDL_sound.h ... It's verbose, honest. :) 25 | * 26 | * Please see the file LICENSE.txt in the source's root directory. 27 | * 28 | * This file written by Ryan C. Gordon. (icculus@icculus.org) 29 | */ 30 | 31 | #if HAVE_CONFIG_H 32 | # include 33 | #endif 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include "SDL.h" 40 | #include "SDL_thread.h" 41 | #include "SDL_sound.h" 42 | 43 | #define __SDL_SOUND_INTERNAL__ 44 | #include "SDL_sound_internal.h" 45 | 46 | 47 | static void conv_mix_buf_u8_mono(void *userdata, Uint8 *_stream, int len) 48 | { 49 | register Uint8 *stream = _stream; 50 | register Uint32 i; 51 | register Uint32 max = len * 2; 52 | for (i = 0; i < max; i += 2) 53 | { 54 | *stream = (Uint8) ((((mixbuf[i]+mixbuf[i+1])*0.5f) * 127.0f) + 128.0f); 55 | stream++; 56 | } /* for */ 57 | } /* conv_mix_buf_s8s */ 58 | 59 | static void conv_mix_buf_s8_mono(void *userdata, Uint8 *_stream, int len) 60 | { 61 | register Uint32 i; 62 | register Sint8 *stream = (Sint8 *) _stream; 63 | register Uint32 max = len * 2; 64 | for (i = 0; i < max; i += 2) 65 | { 66 | *stream = (Sint8) (((mixbuf[i] + mixbuf[i+1]) * 0.5f) * 127.0f); 67 | stream++; 68 | } /* for */ 69 | } /* conv_mix_buf_s8s */ 70 | 71 | static void conv_mix_buf_s16_lsb_mono(void *userdata, Uint8 *_stream, int len) 72 | { 73 | register Uint32 i; 74 | register Sint16 *stream = (Sint16 *) _stream; 75 | register Sint16 val; 76 | register Uint32 max = len / 2; 77 | for (i = 0; i < max; i += 2) 78 | { 79 | val = (Sint16) (((mixbuf[i] + mixbuf[i+1]) * 0.5f) * 32767.0f); 80 | *stream = SDL_SwapLE16(val); 81 | stream++; 82 | } /* for */ 83 | } /* conv_mix_buf_s16_lsb_mono */ 84 | 85 | static void conv_mix_buf_s16_msb_mono(void *userdata, Uint8 *_stream, int len) 86 | { 87 | register Uint32 i; 88 | register Sint16 *stream = (Sint16 *) _stream; 89 | register Sint16 val; 90 | register Uint32 max = len / 2; 91 | for (i = 0; i < max; i += 2) 92 | { 93 | val = (Sint16) (((mixbuf[i] + mixbuf[i+1]) * 0.5f) * 32767.0f); 94 | *stream = SDL_SwapBE16(val); 95 | stream++; 96 | } /* for */ 97 | } /* conv_mix_buf_s16_msb_mono */ 98 | 99 | static void conv_mix_buf_u16_lsb_mono(void *userdata, Uint8 *_stream, int len) 100 | { 101 | register Uint32 i; 102 | register Uint16 *stream = (Uint16 *) _stream; 103 | register Uint16 val; 104 | register Uint32 max = len / 2; 105 | for (i = 0; i < max; i += 2) 106 | { 107 | val = (Uint16)((((mixbuf[i]+mixbuf[i+1])*0.5f) * 32767.0f) + 32768.0f); 108 | *stream = SDL_SwapLE16(val); 109 | stream++; 110 | } /* for */ 111 | } /* conv_mix_buf_s16_lsb_mono */ 112 | 113 | static void conv_mix_buf_u16_msb_mono(void *userdata, Uint8 *_stream, int len) 114 | { 115 | register Uint32 i; 116 | register Uint16 *stream = (Uint16 *) _stream; 117 | register Uint16 val; 118 | register Uint32 max = len / 2; 119 | for (i = 0; i < max; i += 2) 120 | { 121 | val = (Uint16)((((mixbuf[i]+mixbuf[i+1])*0.5f) * 32767.0f) + 32768.0f); 122 | *stream = SDL_SwapBE16(val); 123 | stream++; 124 | } /* for */ 125 | } /* conv_mix_buf_s16_lsb_mono */ 126 | 127 | static void conv_mix_buf_u8_stereo(void *userdata, Uint8 *_stream, int len) 128 | { 129 | register Uint32 i; 130 | register Uint8 *stream = _stream; 131 | register Uint32 max = len; 132 | for (i = 0; i < max; i++) 133 | { 134 | *stream = (Uint8) ((mixbuf[i] * 127.0f) + 128.0f); 135 | stream++; 136 | } /* for */ 137 | } /* conv_mix_buf_s8s */ 138 | 139 | static void conv_mix_buf_s8_stereo(void *userdata, Uint8 *_stream, int len) 140 | { 141 | register Uint32 i; 142 | register Sint8 *stream = (Sint8 *) _stream; 143 | register Uint32 max = len; 144 | for (i = 0; i < max; i++) 145 | { 146 | *stream = (Sint8) (mixbuf[i] * 127.0f); 147 | stream++; 148 | } /* for */ 149 | } /* conv_mix_buf_s8s */ 150 | 151 | static void conv_mix_buf_s16lsb_stereo(void *userdata, Uint8 *_stream, int len) 152 | { 153 | register Uint32 i; 154 | register Sint16 *stream = (Sint16 *) _stream; 155 | register Sint16 val; 156 | register Uint32 max = len / 2; 157 | for (i = 0; i < max; i++) 158 | { 159 | val = (Sint16) (mixbuf[i] * 32767.0f); 160 | *stream = SDL_SwapLE16(val); 161 | stream++; 162 | } /* for */ 163 | } /* conv_mix_buf_s16_lsb_stereo */ 164 | 165 | static void conv_mix_buf_s16msb_stereo(void *userdata, Uint8 *_stream, int len) 166 | { 167 | register Uint32 i; 168 | register Sint16 *stream = (Sint16 *) _stream; 169 | register Sint16 val; 170 | register Uint32 max = len / 2; 171 | for (i = 0; i < max; i++) 172 | { 173 | val = (Sint16) (mixbuf[i] * 32767.0f); 174 | *stream = SDL_SwapBE16(val); 175 | stream++; 176 | } /* for */ 177 | } /* conv_mix_buf_s16_msb_stereo */ 178 | 179 | static void conv_mix_buf_u16lsb_stereo(void *userdata, Uint8 *_stream, int len) 180 | { 181 | register Uint32 i; 182 | register Uint16 *stream = (Uint16 *) _stream; 183 | register Uint16 val; 184 | register Uint32 max = len / 2; 185 | for (i = 0; i < max; i++) 186 | { 187 | val = (Uint16) ((mixbuf[i] * 32767.0f) + 32768.0f); 188 | *stream = SDL_SwapLE16(val); 189 | stream++; 190 | } /* for */ 191 | } /* conv_mix_buf_s16_lsb_stereo */ 192 | 193 | static void conv_mix_buf_u16msb_stereo(void *userdata, Uint8 *_stream, int len) 194 | { 195 | register Uint32 i; 196 | register Uint16 *stream = (Uint16 *) _stream; 197 | register Uint16 val; 198 | register Uint32 max = len / 2; 199 | for (i = 0; i < max; i++) 200 | { 201 | val = (Uint16) ((mixbuf[i] * 32767.0f) + 32768.0f); 202 | *stream = SDL_SwapBE16(val); 203 | stream++; 204 | } /* for */ 205 | } /* conv_mix_buf_s16_msb_stereo */ 206 | 207 | /* end of converters.c ... */ 208 | 209 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 2 | dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS 3 | dnl 4 | AC_DEFUN([AM_PATH_SDL], 5 | [dnl 6 | dnl Get the cflags and libraries from the sdl-config script 7 | dnl 8 | AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], 9 | sdl_prefix="$withval", sdl_prefix="") 10 | AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], 11 | sdl_exec_prefix="$withval", sdl_exec_prefix="") 12 | AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], 13 | , enable_sdltest=yes) 14 | 15 | if test x$sdl_exec_prefix != x ; then 16 | sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 17 | if test x${SDL_CONFIG+set} != xset ; then 18 | SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config 19 | fi 20 | fi 21 | if test x$sdl_prefix != x ; then 22 | sdl_args="$sdl_args --prefix=$sdl_prefix" 23 | if test x${SDL_CONFIG+set} != xset ; then 24 | SDL_CONFIG=$sdl_prefix/bin/sdl-config 25 | fi 26 | fi 27 | 28 | AC_REQUIRE([AC_CANONICAL_TARGET]) 29 | PATH="$prefix/bin:$prefix/usr/bin:$PATH" 30 | AC_PATH_PROG(SDL1_CONFIG, sdl-config, no, [$PATH]) 31 | AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) 32 | 33 | if test "$SDL2_CONFIG" != "no" ; then 34 | SDL_CONFIG=$SDL2_CONFIG 35 | else 36 | SDL_CONFIG=$SDL1_CONFIG 37 | fi 38 | 39 | min_sdl_version=ifelse([$1], ,0.11.0,$1) 40 | AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) 41 | no_sdl="" 42 | if test "$SDL_CONFIG" = "no" ; then 43 | no_sdl=yes 44 | else 45 | SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` 46 | SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` 47 | 48 | sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ 49 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 50 | sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ 51 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 52 | sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ 53 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 54 | if test "x$enable_sdltest" = "xyes" ; then 55 | ac_save_CFLAGS="$CFLAGS" 56 | ac_save_CXXFLAGS="$CXXFLAGS" 57 | ac_save_LIBS="$LIBS" 58 | CFLAGS="$CFLAGS $SDL_CFLAGS" 59 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" 60 | LIBS="$LIBS $SDL_LIBS" 61 | dnl 62 | dnl Now check if the installed SDL is sufficiently new. (Also sanity 63 | dnl checks the results of sdl-config to some extent 64 | dnl 65 | rm -f conf.sdltest 66 | AC_TRY_RUN([ 67 | #include 68 | #include 69 | #include 70 | #include "SDL.h" 71 | 72 | char* 73 | my_strdup (char *str) 74 | { 75 | char *new_str; 76 | 77 | if (str) 78 | { 79 | new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); 80 | strcpy (new_str, str); 81 | } 82 | else 83 | new_str = NULL; 84 | 85 | return new_str; 86 | } 87 | 88 | int main (int argc, char *argv[]) 89 | { 90 | int major, minor, micro; 91 | char *tmp_version; 92 | 93 | /* This hangs on some systems (?) 94 | system ("touch conf.sdltest"); 95 | */ 96 | { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } 97 | 98 | /* HP/UX 9 (%@#!) writes to sscanf strings */ 99 | tmp_version = my_strdup("$min_sdl_version"); 100 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 101 | printf("%s, bad version string\n", "$min_sdl_version"); 102 | exit(1); 103 | } 104 | 105 | if (($sdl_major_version > major) || 106 | (($sdl_major_version == major) && ($sdl_minor_version > minor)) || 107 | (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) 108 | { 109 | return 0; 110 | } 111 | else 112 | { 113 | printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); 114 | printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); 115 | printf("*** best to upgrade to the required version.\n"); 116 | printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); 117 | printf("*** to point to the correct copy of sdl-config, and remove the file\n"); 118 | printf("*** config.cache before re-running configure\n"); 119 | return 1; 120 | } 121 | } 122 | 123 | ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 124 | CFLAGS="$ac_save_CFLAGS" 125 | LIBS="$ac_save_LIBS" 126 | fi 127 | fi 128 | if test "x$no_sdl" = x ; then 129 | AC_MSG_RESULT(yes) 130 | ifelse([$2], , :, [$2]) 131 | else 132 | AC_MSG_RESULT(no) 133 | if test "$SDL_CONFIG" = "no" ; then 134 | echo "*** The sdl-config script installed by SDL could not be found" 135 | echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" 136 | echo "*** your path, or set the SDL_CONFIG environment variable to the" 137 | echo "*** full path to sdl-config." 138 | else 139 | if test -f conf.sdltest ; then 140 | : 141 | else 142 | echo "*** Could not run SDL test program, checking why..." 143 | CFLAGS="$CFLAGS $SDL_CFLAGS" 144 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" 145 | LIBS="$LIBS $SDL_LIBS" 146 | AC_TRY_LINK([ 147 | #include 148 | #include "SDL.h" 149 | 150 | int main(int argc, char *argv[]) 151 | { return 0; } 152 | #undef main 153 | #define main K_and_R_C_main 154 | ], [ return 0; ], 155 | [ echo "*** The test program compiled, but did not run. This usually means" 156 | echo "*** that the run-time linker is not finding SDL or finding the wrong" 157 | echo "*** version of SDL. If it is not finding SDL, you'll need to set your" 158 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 159 | echo "*** to the installed location Also, make sure you have run ldconfig if that" 160 | echo "*** is required on your system" 161 | echo "***" 162 | echo "*** If you have an old version installed, it is best to remove it, although" 163 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 164 | [ echo "*** The test program failed to compile or link. See the file config.log for the" 165 | echo "*** exact error that occured. This usually means SDL was incorrectly installed" 166 | echo "*** or that you have moved SDL since it was installed. In the latter case, you" 167 | echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) 168 | CFLAGS="$ac_save_CFLAGS" 169 | CXXFLAGS="$ac_save_CXXFLAGS" 170 | LIBS="$ac_save_LIBS" 171 | fi 172 | fi 173 | SDL_CFLAGS="" 174 | SDL_CXXFLAGS="" 175 | SDL_LIBS="" 176 | ifelse([$3], , :, [$3]) 177 | fi 178 | AC_SUBST(SDL_CFLAGS) 179 | AC_SUBST(SDL_LIBS) 180 | rm -f conf.sdltest 181 | ]) 182 | --------------------------------------------------------------------------------