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_AUDIO_H_
00028 #define OSDL_AUDIO_H_
00029
00030
00031 #include "OSDLAudioCommon.h"
00032 #include "OSDLMusic.h"
00033
00034 #include "Ceylan.h"
00035
00036 #include <string>
00037 #include <vector>
00038
00039
00040
00041
00042 namespace OSDL
00043 {
00044
00045
00046
00047
00048 class CommonModule ;
00049
00050
00051
00052 namespace Audio
00053 {
00054
00055
00056
00057
00058 class AudioChannel ;
00059
00060
00061
00068 std::string sampleFormatToString( SampleFormat format ) ;
00069
00070
00071
00078 std::string channelFormatToString( ChannelFormat format ) ;
00079
00080
00081
00082
00093 class OSDL_DLL AudioModule : public Ceylan::Module
00094 {
00095
00096
00097
00098
00099 friend class OSDL::CommonModule ;
00100
00101
00102
00118 OSDL_DLL friend AudioModule & getExistingAudioModule() ;
00119
00120
00121
00122 public:
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00135 static const SampleFormat Uint8SampleFormat ;
00136
00137
00139 static const SampleFormat Sint8SampleFormat ;
00140
00141
00142
00144 static const SampleFormat LittleUint16SampleFormat ;
00145
00146
00148 static const SampleFormat LittleSint16SampleFormat ;
00149
00150
00151
00153 static const SampleFormat BigUint16SampleFormat ;
00154
00155
00157 static const SampleFormat BigSint16SampleFormat ;
00158
00159
00160
00162 static const SampleFormat NativeUint16SampleFormat ;
00163
00164
00166 static const SampleFormat NativeSint16SampleFormat ;
00167
00168
00169
00171 static const SampleFormat IMAADPCMSampleFormat ;
00172
00173
00174
00175
00176
00177
00178
00179
00180
00182 static const ChannelFormat Mono ;
00183
00184
00186 static const ChannelFormat Stereo ;
00187
00188
00189
00191 static const Volume MinVolume ;
00192
00193
00195 static const Volume MaxVolume ;
00196
00197
00198
00200 typedef Ceylan::Uint16 ChannelNumber ;
00201
00202
00203
00255 virtual void setMode(
00256 Ceylan::Maths::Hertz outputFrequency,
00257 SampleFormat outputSampleFormat,
00258 ChannelFormat outputChannel,
00259 ChunkSize outputBufferSize,
00260 ChannelNumber mixingChannelNumber = 16 ) ;
00261
00262
00263
00284 virtual Ceylan::System::Millisecond getObtainedMode(
00285 Ceylan::Maths::Hertz & actualOutputFrequency,
00286 SampleFormat & actualOutputSampleFormat,
00287 ChannelNumber & actualOutputChannelNumber ) ;
00288
00289
00290
00299 virtual void unsetMode() ;
00300
00301
00302
00320 virtual void setPanning(
00321 Ceylan::Maths::Percentage leftPercentage ) ;
00322
00323
00324
00332 virtual void unsetPanning() ;
00333
00334
00335
00350 virtual void setReverseStereo( bool reverse = true ) ;
00351
00352
00353
00372 virtual void setDistanceAttenuation(
00373 ListenerDistance distance ) ;
00374
00375
00376
00385 virtual void unsetDistanceAttenuation() ;
00386
00387
00388
00410 virtual void setPositionAttenuation( ListenerDistance distance,
00411 ListenerAngle angle ) ;
00412
00413
00414
00423 virtual void unsetPositionAttenuation() ;
00424
00425
00426
00427
00433 virtual bool isGUIEnabled() const ;
00434
00435
00436
00444 virtual void setGUIEnableStatus( bool newStatus ) ;
00445
00446
00447
00448
00449
00450
00451
00452
00459 virtual ChannelNumber getMixingChannelCount() const ;
00460
00461
00462
00472 virtual AudioChannel & getMixingChannelAt( ChannelNumber index )
00473 const ;
00474
00475
00476
00485 virtual void setVolumeForAllMixingChannels( Volume newVolume ) ;
00486
00487
00488
00497 virtual ChannelNumber getPlayingChannelCount() const ;
00498
00499
00500
00509 virtual ChannelNumber getPausedChannelCount() const ;
00510
00511
00512
00522 virtual void pauseAllChannels() ;
00523
00524
00525
00533 virtual void resumeAllChannels() ;
00534
00535
00536
00547 virtual void haltAllChannels() ;
00548
00549
00550
00565 virtual ChannelNumber expireAllChannelsIn(
00566 Ceylan::System::Millisecond expireDuration ) ;
00567
00568
00569
00584 virtual ChannelNumber fadeOutAllChannelsDuring(
00585 Ceylan::System::Millisecond fadeOutDuration ) ;
00586
00587
00588
00589
00590
00591
00592
00593
00594
00603 virtual MusicType getTypeOfCurrentMusic() const ;
00604
00605
00606
00616 virtual bool isMusicPlaying() const ;
00617
00618
00619
00630 virtual bool isMusicPaused() const ;
00631
00632
00633
00644 virtual FadingStatus getMusicFadingStatus() const ;
00645
00646
00647
00659 virtual std::string getDriverName() const ;
00660
00661
00662
00675 virtual const std::string toString(
00676 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00697 static std::string AudioPathEnvironmentVariable ;
00698
00699
00700
00710 static Ceylan::System::FileLocator AudioFileLocator ;
00711
00712
00713
00723 static std::string DescribeEnvironmentVariables() ;
00724
00725
00726
00738 static bool IsAudioInitialized() ;
00739
00740
00741
00753 static std::string GetDriverName() ;
00754
00755
00756
00758 static const Ceylan::Uint16 DriverNameMaximumLength ;
00759
00760
00761
00762
00763 protected:
00764
00765
00766
00768 bool _mixerInitialized ;
00769
00770
00772 ChunkSize _chunkSize ;
00773
00774
00780 bool _controlMusicManager ;
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790 #pragma warning( push )
00791 #pragma warning( disable: 4251 )
00792
00793
00795 std::vector<AudioChannel *> _inputChannels ;
00796
00797 #pragma warning( pop )
00798
00799
00804 bool _isGuiEnabled ;
00805
00806
00822 virtual void onMusicPlaybackFinished() ;
00823
00824
00825
00838 static ChannelNumber GetChannelCountFor( ChannelFormat format );
00839
00840
00841
00854 static ChunkSize GetSampleSizeFor( SampleFormat format ) ;
00855
00856
00857
00866 static bool _AudioInitialized ;
00867
00868
00869
00870
00871 private:
00872
00873
00874
00881 static void HandleMusicPlaybackFinishedCallback() ;
00882
00883
00884
00893 AudioModule() ;
00894
00895
00896
00898 virtual ~AudioModule() throw() ;
00899
00900
00901
00910 explicit AudioModule( const AudioModule & source ) ;
00911
00912
00913
00922 AudioModule & operator = ( const AudioModule & source ) ;
00923
00924
00925
00926
00932 static const std::string SDLEnvironmentVariables[] ;
00933
00934
00935
00936 friend class CommonModule ;
00937
00938
00939
00940 } ;
00941
00942
00943
00944
00960 OSDL_DLL AudioModule & getExistingAudioModule() ;
00961
00962
00963
00964 }
00965
00966
00967 }
00968
00969
00970
00971 #endif // OSDL_AUDIO_H_
00972