sdlfilemusic.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 2005 by Tobias Nadler                                         */
00005 /*                                                                              */
00006 /*  This library is free software; you can redistribute it and/or               */
00007 /*  modify it under the terms of the GNU Lesser General Public                  */
00008 /*  License as published by the Free Software Foundation; either                */
00009 /*  version 2.1 of the License, or (at your option) any later version.          */
00010 /*                                                                              */
00011 /*  This library is distributed in the hope that it will be useful,             */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of              */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           */
00014 /*  Lesser General Public License for more details.                             */
00015 /*                                                                              */
00016 /*  You should have received a copy of the GNU Lesser General Public            */
00017 /*  License along with this library; if not, write to the Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
00019 /*                                                                              */
00020 /********************************************************************************/
00021 
00022 #ifndef SDLFILEMUSIC_H
00023 #define SDLFILEMUSIC_H
00024 
00025 #include "SDL/SDL_mixer.h"
00026 #include "sdlaudio.h"
00027 
00042 class DECLSPEC SdlMusic : public SdlAudio
00043 {
00044 public:
00050     DECLSPEC SdlMusic( const char *name );
00051     virtual DECLSPEC ~SdlMusic();
00052 
00053     virtual DECLSPEC int play( int loops = 0 );// returns 0, if any music is played, otherwise -1
00054     virtual DECLSPEC int fadeIn( int ms, int loops = 0 );
00055     virtual DECLSPEC bool isPlaying();
00056     virtual DECLSPEC void pause();
00057     virtual DECLSPEC bool isPaused();
00058     virtual DECLSPEC void resume();
00059     virtual DECLSPEC void stop();
00060     virtual DECLSPEC int fadeOut( int ms );
00061     virtual DECLSPEC Mix_Fading fadeStatus();
00062 
00063     virtual DECLSPEC void setVolume( int v );
00064     virtual DECLSPEC int getVolume()    { return nVolume; }
00065 
00071     virtual int getChannel()    { return isPlaying() ? 0 : -1; }
00072 
00073     virtual bool isMusic()  { return true; }
00074 
00078     static SdlMusic *getPlayingStream() { return musPlaying; }
00085     static DECLSPEC void setGlbVolume( int v );
00086 protected:
00092     DECLSPEC void destroy();
00093 
00095     Mix_Music *mixMusic;
00097     int nVolume;
00099     bool bPlaying;
00100 
00102     static int g_nVolume;
00104     static SdlMusic *musPlaying;
00109     static void onMusicFinished()
00110     {
00111         if( musPlaying != 0 )   {// just to be on the safe side
00112             musPlaying->bPlaying = false;
00113             if( musPlaying->cb )
00114                 (*musPlaying->cb)( (SdlAudio*)musPlaying, musPlaying->cbData );
00115         }
00116     }
00117 };
00118 
00119 
00130 class DECLSPEC SdlFileMusic : public SdlMusic
00131 {
00132 public:
00141     DECLSPEC SdlFileMusic( const char *fn, const char *name = 0 );
00142     virtual DECLSPEC ~SdlFileMusic();
00143 
00150     DECLSPEC bool load( const char *fn );
00151 };
00152 
00153 #endif

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1