Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

mixer.h

00001 /*
00002   libwftk - Worldforge Toolkit - a widget library
00003   Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org>
00004   Based on code copyright  (C) 1999-2002  Karsten Laux 
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
00018   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019   Boston, MA  02111-1307, SA.
00020 */
00021 
00022 // writtten May 1999
00023 
00024 #ifndef _WFTK_MIXER_H
00025 #define _WFTK_MIXER_H
00026 
00027 #include <sigc++/object.h>
00028 #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
00029 #include <sigc++/signal_system.h>
00030 #else
00031 #include <sigc++/signal.h>
00032 #endif
00033 
00034 #include <SDL/SDL_types.h>
00035 #include <string>
00036 
00037 namespace wftk {
00038 
00039 class Music;
00040 class Sample;
00041 
00043 class Mixer : virtual public SigC::Object
00044 {
00045 //OBJECT
00046   
00047 public:
00049   Mixer(bool use_sound);
00051   ~Mixer();
00053   static Mixer* instance() {return instance_ ? instance_ : new Mixer(true);}
00055   static bool isInit() {return instance_ != 0;}
00057   bool audioAvailable() { return audio_open_; }
00059   const Music* currentSong() const { return music_; }
00061   int setActiveChannels(int);
00063   void setMusic(const std::string& s);
00065   void setMusic(const Music&);
00067   void startMusic();
00069   void stopMusic();
00071   void pauseMusic();
00073   void resumeMusic();
00075   void rewindMusic();
00077   void playSample(const std::string& s);
00079   void playSample(const Sample&);
00081   int setVolume(int);
00083   int setMusicVolume(int);
00085   int getMusicVolume() const {return volume_;}
00086 
00090   void enableHook(bool);
00091   
00097   SigC::Signal2<void, Uint8*, int> data;
00098 
00099  private:
00100   // unimplemented
00101   Mixer(const Mixer&);
00102   Mixer& operator=(const Mixer&);
00103 
00105   bool audio_open_;
00107   static void mixer_callback(void*, Uint8*, int);
00108 
00110   int audio_rate_;
00112   Uint16 audio_format_;
00114   int audio_channels_;
00115 
00117   const Music* music_;
00119   int volume_;
00120 
00122   static Mixer* instance_;
00123 };
00124 
00125 } // namespace wftk
00126 
00127 #endif // _WFTK_MIXER_H

Generated Tue Aug 9 18:40:26 2005.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.