1 #include "SoundBuffer.hpp"
2 #include "SoundFile.hpp"
3 #include <mof/ConsoleIO.hpp>
5 mof::SoundBuffer::SoundBuffer
7 std::shared_ptr<mof::sound::DirectSoundDevice> pDevice,
8 LPDIRECTSOUNDBUFFER8 pBuffer,
11 : m_pBuffer(pBuffer), m_pResource(pResouce), pDevice_(pDevice)
14 pBuffer->GetFrequency(&default_frequency_);
17 mof::SoundBuffer::~SoundBuffer(void){
23 void mof::SoundBuffer::update()
25 volume_stream_.update();
26 frequency_stream_.update();
28 mof::real volume = volume_stream_.value();
29 if (volume > 1) volume = 1;
30 else if (volume < 0) volume = 0;
31 int converted_volume = (1.0f - volume) * DSBVOLUME_MIN;
32 converted_volume = converted_volume < DSBVOLUME_MIN
34 : converted_volume > DSBVOLUME_MAX
38 getSoundBuffer()->GetVolume(&prev_volume);
39 if (converted_volume != prev_volume) {
40 getSoundBuffer()->SetVolume(converted_volume);// 必要ない場合は変更を行わない
43 mof::real frequency = frequency_stream_.value();
44 int converted_frequency = default_frequency_ * frequency;
45 converted_frequency = converted_frequency < DSBFREQUENCY_MIN
47 : converted_frequency > DSBFREQUENCY_MAX
49 : converted_frequency;
51 getSoundBuffer()->GetFrequency(&prev_frequency);
52 if (converted_frequency != prev_frequency) {
53 getSoundBuffer()->SetFrequency(converted_frequency);// 必要ない場合は変更を行わない