00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OSDL_SOUND_H_
00028 #define OSDL_SOUND_H_
00029
00030
00031 #include "OSDLAudible.h"
00032 #include "OSDLUtils.h"
00033
00034
00035 #include "Ceylan.h"
00036
00037
00038 #include <string>
00039
00040
00041
00042 #if ! defined(OSDL_USES_SDL_MIXER) || OSDL_USES_SDL_MIXER
00043
00044
00045 struct Mix_Chunk ;
00046
00047 #endif // ! defined(OSDL_USES_SDL_MIXER) || OSDL_USES_SDL_MIXER
00048
00049
00050
00051
00052 namespace OSDL
00053 {
00054
00055
00056
00057 namespace Audio
00058 {
00059
00060
00061
00063 #if ! defined(OSDL_USES_SDL_MIXER) || OSDL_USES_SDL_MIXER
00064
00065 typedef ::Mix_Chunk LowLevelSound ;
00066
00067 #else // OSDL_USES_SDL_MIXER
00068
00069
00074 struct LowLevelSound
00075 {
00076
00077
00079 Ceylan::Uint16 _frequency ;
00080
00081
00083 Ceylan::Uint8 _bitDepth ;
00084
00085
00087 Ceylan::Uint8 _mode ;
00088
00089
00091 Ceylan::Byte * _samples ;
00092
00093
00095 Ceylan::Uint32 _size ;
00096
00097
00098 } ;
00099
00100
00101 #endif // OSDL_USES_SDL_MIXER
00102
00103
00104
00105
00107 class OSDL_DLL SoundException: public AudibleException
00108 {
00109 public:
00110
00111 SoundException( const std::string & reason ) ;
00112 virtual ~SoundException() throw() ;
00113 } ;
00114
00115
00116
00117
00118 class Sound ;
00119
00120
00122 typedef Ceylan::CountedPointer<Sound> SoundCountedPtr ;
00123
00124
00125
00126
00151 class OSDL_DLL Sound: public Audible,
00152 public Ceylan::LoadableWithContent<LowLevelSound>
00153 {
00154
00155
00156
00157 public:
00158
00159
00160
00181 explicit Sound( const std::string & soundFile,
00182 bool preload = true ) ;
00183
00184
00185
00187 virtual ~Sound() throw() ;
00188
00189
00190
00191
00192
00193
00194
00195
00205 virtual bool load() ;
00206
00207
00208
00221 virtual bool unload() ;
00222
00223
00224
00225
00226
00227
00228
00229
00238 virtual Volume getVolume() const ;
00239
00240
00241
00254 virtual void setVolume( Volume newVolume ) ;
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00297 virtual void play( PlaybackCount playCount = 1 ) ;
00298
00299
00300
00319 virtual ChannelNumber playReturnChannel(
00320 PlaybackCount playCount = 1 ) ;
00321
00322
00323
00340 virtual void play(
00341 ChannelNumber mixingChannelNumber,
00342 PlaybackCount playCount = 1 ) ;
00343
00344
00345
00346
00347
00348
00349
00350
00369 virtual void playForAtMost(
00370 Ceylan::System::Millisecond maxDuration,
00371 PlaybackCount playCount = 1 ) ;
00372
00373
00374
00395 virtual ChannelNumber playForAtMostReturnChannel(
00396 Ceylan::System::Millisecond maxDuration,
00397 PlaybackCount playCount = 1 ) ;
00398
00399
00400
00422 virtual void playForAtMost(
00423 Ceylan::System::Millisecond maxDuration,
00424 ChannelNumber mixingChannelNumber,
00425 PlaybackCount playCount = 1 ) ;
00426
00427
00428
00429
00430
00431
00432
00433
00454 virtual void playWithFadeIn(
00455 Ceylan::System::Millisecond fadeInMaxDuration,
00456 PlaybackCount playCount = 1 ) ;
00457
00458
00459
00482 virtual ChannelNumber playWithFadeInReturnChannel(
00483 Ceylan::System::Millisecond fadeInMaxDuration,
00484 PlaybackCount playCount = 1 ) ;
00485
00486
00487
00511 virtual void playWithFadeIn(
00512 Ceylan::System::Millisecond fadeInMaxDuration,
00513 ChannelNumber mixingChannelNumber,
00514 PlaybackCount playCount = 1 ) ;
00515
00516
00517
00518
00519
00520
00521
00522
00546 virtual void playWithFadeInForAtMost(
00547 Ceylan::System::Millisecond playbackMaxDuration,
00548 Ceylan::System::Millisecond fadeInMaxDuration,
00549 PlaybackCount playCount = 1 ) ;
00550
00551
00552
00578 virtual ChannelNumber playWithFadeInForAtMostReturnChannel(
00579 Ceylan::System::Millisecond playbackMaxDuration,
00580 Ceylan::System::Millisecond fadeInMaxDuration,
00581 PlaybackCount playCount = 1 ) ;
00582
00583
00584
00611 virtual void playWithFadeInForAtMost(
00612 Ceylan::System::Millisecond playbackMaxDuration,
00613 Ceylan::System::Millisecond fadeInMaxDuration,
00614 ChannelNumber mixingChannelNumber,
00615 PlaybackCount playCount = 1 ) ;
00616
00617
00618
00619
00632 virtual const std::string toString(
00633 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00634
00635
00636
00637
00638
00639 protected:
00640
00641
00653 OSDL::Utils::DataStream * _dataStream ;
00654
00655
00656
00657
00658 private:
00659
00660
00669 explicit Sound( const Sound & source ) ;
00670
00671
00672
00681 Sound & operator = ( const Sound & source ) ;
00682
00683
00684 } ;
00685
00686
00687 }
00688
00689 }
00690
00691
00692
00693 #endif // OSDL_SOUND_H_
00694