/* * WaveSample Class * * Allows an 8 bit or 16 bit monoaural wave (.WAV) file to be loaded and played * * Including automatic L-R positioning effects * * Copyright (C) 2008 Alejandro Valenzuela Roca, * * http://mexinetica.com/~lanjoe9 * * This file is part of MotorJ, a free framework for videogame development. * * * * MotorJ is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MotorJ is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with MotorJ. If not, see . */ #ifdef NINTENDO_DS #include #include #endif #ifdef PC_SDL #include #include #endif #include #include #include #include "support.h" #ifndef WAVESAMPLE_CLASS_H #define WAVESAMPLE_CLASS_H //! Sound effect emitter with attenuation and panning /*! * * Wave Sample emitter * * Emits sounds stored as wave files. Has attenuation and panning capabilities * */ class mjWaveSample { public: mjWaveSample(); ~mjWaveSample(); //!Open a file from the filesystem. If there was one loaded already, its allocated memory will be freed. int LoadFile(const char * filename); //!Play a previously loaded file with specified volume [0-127] and balance [left:1-center:127-right:255] void Play(unsigned vol, unsigned balance); //!Play a previously loaded file specifying the listener's position, left-hand direction, //!the position of the sound source, attenuation due to distance [unitary percentage per unit of distance] //!and maximum initial volume [0..127] void Play3D(vector3 &observer_pos, vector3 &observer_dirleft, vector3 &soundsource_pos, float attenuation, unsigned maxvol); private: unsigned imaxvol; FILE * wavefile; #ifdef NINTENDO_DS TransferSoundData tsd; char * wavebuffer; #endif #ifdef PC_SDL Mix_Chunk * cMixC; int channel; #endif }; #endif