1 /* sdl_synth.h -- SDL music synthesizer 2 * $Id: sdl_synth.h,v 1.2 2005/06/29 03:20:34 kvance Exp $ 3 * Copyright (C) 2002 Kev Vance <kvance@kvance.com> 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., 59 Temple Place Suite 330; Boston, MA 02111-1307, USA. 18 */ 19 20 #ifndef _SYNTH_H 21 #define _SYNTH_H 1 22 23 #include "SDL.h" 24 25 #include "notes.h" 26 27 /* On/off value for various states of signedness and bits */ 28 #define U8_0 112 29 #define U8_1 142 30 #define S8_0 -15 31 #define S8_1 15 32 #define U16_0 28927 33 #define U16_1 36607 34 #define S16_0 -3840 35 #define S16_1 3840 36 37 /* TODO: rename these functions */ 38 39 /* Open the synthesizer and store audio spec in "spec" (true on error) */ 40 int OpenSynth(SDL_AudioSpec * spec); 41 42 /* Close the synthesizer */ 43 void CloseSynth(void); 44 45 /* Returns true if the buffer is empty */ 46 int IsSynthBufferEmpty(); 47 48 /* Play a note on to the SDL synthesizer */ 49 void SynthPlayNote(SDL_AudioSpec audiospec, musicalNote note, musicSettings settings); 50 51 /* Add a frequency and duration to the SDL audio 52 * buffer */ 53 void AddToBuffer(SDL_AudioSpec spec, float freq, float seconds); 54 55 /* Internal audio callback function (don't call manually!) */ 56 void AudioCallback(SDL_AudioSpec *spec, Uint8 *stream, int len); 57 58 /* Cleanup memory used by audio system */ 59 void AudioCleanUp(); 60 61 #endif 62