Sound.cpp
Go to the documentation of this file.00001 //*** Sound.cpp ** 00002 00003 #include "Sound.h" 00004 #include "StandardLibrary.h" 00005 #include "Asset.h" 00006 #include "AudioFormat.h" 00007 #include "Audio.h" 00008 00009 00010 //*** Constructor *** 00011 00012 Sound::Sound(const Asset& asset): 00013 data_(0), 00014 channels_(0), 00015 frequency_(0), 00016 bitsPerSample_(0), 00017 size_(0) 00018 { 00019 AudioFormat* format=AudioFormat::CreateAudioFormat(asset); 00020 channels_=format->GetChannels(); 00021 frequency_=format->GetFrequency(); 00022 bitsPerSample_=format->GetBitsPerSample(); 00023 size_=format->GetSize(); 00024 data_=Malloc(size_); 00025 00026 // Decode entire file to memory 00027 format->CopySoundChunk(data_,size_); 00028 00029 delete format; 00030 } 00031 00032 00033 //*** Destructor *** 00034 00035 Sound::~Sound() 00036 { 00037 Free(data_); 00038 } 00039 00040 00041 //*** Play *** 00042 00043 void Sound::Play(float priority, bool looping) const 00044 { 00045 siAudio->PlaySound(*this,priority,looping); 00046 } 00047 00048 00049 //*** GetData *** 00050 00051 const void* Sound::GetData() const 00052 { 00053 return data_; 00054 } 00055 00056 00057 //*** GetChannels *** 00058 00059 int Sound::GetChannels() const 00060 { 00061 return channels_; 00062 } 00063 00064 00065 //*** GetFrequency *** 00066 00067 int Sound::GetFrequency() const 00068 { 00069 return frequency_; 00070 } 00071 00072 00073 //*** GetBitsPerSample *** 00074 00075 int Sound::GetBitsPerSample() const 00076 { 00077 return bitsPerSample_; 00078 } 00079 00080 00081 //*** GetSize *** 00082 00083 int Sound::GetSize() const 00084 { 00085 return size_; 00086 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
