AudioProcess.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2005-2007 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef AUDIOPROCESS_H_INCLUDED
00020 #define AUDIOPROCESS_H_INCLUDED
00021 
00022 #include "Process.h"
00023 #include "intrinsics.h"
00024 #include <list>
00025 #include <string>
00026 
00027 namespace Pentagram {
00028         class AudioSample;
00029 }
00030 
00031 class AudioProcess :
00032         public Process
00033 {
00034         struct SampleInfo {
00035                 sint32          sfxnum;
00036                 sint32          priority;
00037                 ObjId           objid;
00038                 sint32          loops;
00039                 sint32          channel;
00040                 std::string barked;
00041                 uint32          curspeech_start, curspeech_end;
00042                 uint32          pitch_shift;    // 0x10000 is normal
00043                 uint16          volume;                 // 0-256
00044                 
00045                 SampleInfo() : sfxnum(-1) { }
00046                 SampleInfo(sint32 s,sint32 p,ObjId o,sint32 l,sint32 c,uint32 ps,uint16 v) : 
00047                         sfxnum(s),priority(p),objid(o),loops(l),channel(c),
00048                         pitch_shift(ps), volume(v) { }
00049                 SampleInfo(std::string &b,sint32 shpnum,ObjId o,sint32 c,
00050                                    uint32 s,uint32 e,uint32 ps,uint16 v) : 
00051                         sfxnum(-1),priority(shpnum),objid(o),loops(0),channel(c),barked(b),
00052                         curspeech_start(s), curspeech_end(e), pitch_shift(ps), volume(v) { }
00053         };
00054 
00055         std::list<SampleInfo>   sample_info;
00056 
00057 public:
00058         // p_dynamic_class stuff
00059         ENABLE_RUNTIME_CLASSTYPE();
00060 
00061         AudioProcess(void);
00062         virtual ~AudioProcess(void);
00063 
00065         static AudioProcess     * get_instance() { return the_audio_process; }
00066 
00067         INTRINSIC(I_playSFX);
00068         INTRINSIC(I_playAmbientSFX);
00069         INTRINSIC(I_isSFXPlaying);
00070         INTRINSIC(I_setVolumeSFX);
00071         INTRINSIC(I_stopSFX);
00072 
00073         static void ConCmd_listSFX(const Console::ArgvType &argv);
00074         static void ConCmd_stopSFX(const Console::ArgvType &argv);
00075         static void ConCmd_playSFX(const Console::ArgvType &argv);
00076 
00077 
00078         virtual bool run(const uint32 framenum);
00079 
00080         void playSFX(int sfxnum, int priority, ObjId objid, int loops,
00081                                  bool no_duplicates=false, uint32 pitch_shift=0x10000,
00082                                  uint16 volume=0x80);
00083         void stopSFX(int sfxnum, ObjId objid);
00084         bool isSFXPlaying(int sfxnum);
00085         void setVolumeSFX(int sfxnum, uint8 volume);
00086 
00087         bool playSpeech(std::string &barked, int shapenum, ObjId objid, 
00088                                         uint32 pitch_shift=0x10000,uint16 volume=256);
00089         void stopSpeech(std::string &barked, int shapenum, ObjId objid);
00090         bool isSpeechPlaying(std::string &barked, int shapenum);
00091 
00093         uint32 getSpeechLength(std::string &barked, int shapenum) const;
00094 
00097         int playSample(Pentagram::AudioSample* sample, int priority, int loops, 
00098                                    uint32 pitch_shift=0x10000, int lvol=256, int rvol=256);
00099 
00101         void pauseAllSamples();
00103         void unpauseAllSamples();
00104 
00106         void stopAllExceptSpeech();
00107 
00108         // AudioProcess::playSound console command
00109         //static void ConCmd_playSound(const Console::ArgvType &argv);
00110 
00111         bool loadData(IDataSource* ids, uint32 version);
00112 
00113 private:
00114         virtual void saveData(ODataSource* ods);
00115         uint32 paused;
00116 
00120         bool continueSpeech(SampleInfo& si);
00121 
00122         bool calculateSoundVolume(ObjId objid, int &lvol, int &rvol) const;
00123 
00124         static AudioProcess     *       the_audio_process;
00125 };
00126 
00127 #endif

Generated on Fri Jul 27 22:27:09 2007 for pentagram by  doxygen 1.4.7