-fix issue 144
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-01-07 13:56:57 +00:00
parent feb1d27ebb
commit 6e2e351239
3 changed files with 32 additions and 53 deletions
+1
View File
@@ -196,6 +196,7 @@ private:
int mVolume; int mVolume;
int mMusicVolume; int mMusicVolume;
int mSampleVolume;
static JSoundSystem* mInstance; static JSoundSystem* mInstance;
+16 -36
View File
@@ -74,7 +74,9 @@ void JSoundSystem::Destroy()
JSoundSystem::JSoundSystem() JSoundSystem::JSoundSystem()
{ {
mVolume = 0;
mSampleVolume = 0;
mChannel = FSOUND_FREE;
} }
@@ -106,15 +108,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
if (fileSystem->OpenFile(fileName)) if (fileSystem->OpenFile(fileName))
{ {
// FMUSIC is for MOD...
// int size = fileSystem->GetFileSize();
// char *buffer = new char[size];
// fileSystem->ReadFile(buffer, size);
// music->mTrack = FMUSIC_LoadSongEx(buffer, 0, size, FSOUND_LOADMEMORY, NULL, 0);
//
// delete[] buffer;
// fileSystem->CloseFile();
int size = fileSystem->GetFileSize(); int size = fileSystem->GetFileSize();
char *buffer = new char[size]; char *buffer = new char[size];
fileSystem->ReadFile(buffer, size); fileSystem->ReadFile(buffer, size);
@@ -131,15 +124,12 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
void JSoundSystem::PlayMusic(JMusic *music, bool looping) void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{ {
// if (music && music->mTrack)
// {
// FMUSIC_SetLooping(music->mTrack, (looping?1:0));
// FMUSIC_PlaySong(music->mTrack);
// }
if (music && music->mTrack) if (music && music->mTrack)
{ {
mChannel = FSOUND_PlaySound(FSOUND_FREE, music->mTrack); mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
SetMusicVolume(mVolume);
if (looping) if (looping)
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL); FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
@@ -166,14 +156,16 @@ void JSoundSystem::SetVolume(int volume){
void JSoundSystem::SetMusicVolume(int volume) void JSoundSystem::SetMusicVolume(int volume)
{ {
//TODO Fix to affect only mp3 playback... if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55);
FSOUND_SetSFXMasterVolume(volume);
mVolume = volume; mVolume = volume;
} }
void JSoundSystem::SetSfxVolume(int volume){ void JSoundSystem::SetSfxVolume(int volume){
//TODO //this sets the volume to all channels then reverts back the volume for music..
//that's a bit dirty but it works
FSOUND_SetVolumeAbsolute(FSOUND_ALL,volume * 2.55);
mSampleVolume = volume;
SetMusicVolume(mVolume);
} }
@@ -202,23 +194,11 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
} }
// void JSoundSystem::FreeSample(JSample *sample)
// {
// if (sample)
// {
// if (sample->mSample)
// FSOUND_Sample_Free(sample->mSample);
//
// //delete sample;
// //sample = NULL;
// }
//
// }
void JSoundSystem::PlaySample(JSample *sample) void JSoundSystem::PlaySample(JSample *sample)
{ {
if (sample && sample->mSample) if (sample && sample->mSample){
FSOUND_PlaySound(FSOUND_FREE, sample->mSample); int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55);
}
} }
+15 -17
View File
@@ -81,7 +81,9 @@ void JSoundSystem::Destroy()
JSoundSystem::JSoundSystem() JSoundSystem::JSoundSystem()
{ {
mVolume = 0;
mSampleVolume = 0;
mChannel = FSOUND_FREE;
} }
@@ -113,15 +115,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
if (fileSystem->OpenFile(fileName)) if (fileSystem->OpenFile(fileName))
{ {
// FMUSIC is for MOD...
// int size = fileSystem->GetFileSize();
// char *buffer = new char[size];
// fileSystem->ReadFile(buffer, size);
// music->mTrack = FMUSIC_LoadSongEx(buffer, 0, size, FSOUND_LOADMEMORY, NULL, 0);
//
// delete[] buffer;
// fileSystem->CloseFile();
int size = fileSystem->GetFileSize(); int size = fileSystem->GetFileSize();
char *buffer = new char[size]; char *buffer = new char[size];
fileSystem->ReadFile(buffer, size); fileSystem->ReadFile(buffer, size);
@@ -142,7 +135,8 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
if (music && music->mTrack) if (music && music->mTrack)
{ {
mChannel = FSOUND_PlaySound(FSOUND_FREE, music->mTrack); mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
SetMusicVolume(mVolume);
if (looping) if (looping)
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL); FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
@@ -167,14 +161,16 @@ void JSoundSystem::SetVolume(int volume)
void JSoundSystem::SetMusicVolume(int volume) void JSoundSystem::SetMusicVolume(int volume)
{ {
//TODO This function needs to be redone if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55);
FSOUND_SetSFXMasterVolume(volume);
mVolume = volume; mVolume = volume;
} }
void JSoundSystem::SetSfxVolume(int volume){ void JSoundSystem::SetSfxVolume(int volume){
//TODO //this sets the volume to all channels then reverts back the volume for music..
//that's a bit dirty but it works
FSOUND_SetVolumeAbsolute(FSOUND_ALL,volume * 2.55);
mSampleVolume = volume;
SetMusicVolume(mVolume);
} }
JSample *JSoundSystem::LoadSample(const char *fileName) JSample *JSoundSystem::LoadSample(const char *fileName)
@@ -203,7 +199,9 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
void JSoundSystem::PlaySample(JSample *sample) void JSoundSystem::PlaySample(JSample *sample)
{ {
if (sample && sample->mSample) if (sample && sample->mSample){
FSOUND_PlaySound(FSOUND_FREE, sample->mSample); int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55);
}
} }