Erwan
- Fix issue 144 (Sound is either 0 or 100%), for PSP ONLY. The methods are now here for linux/windows, but only the music volume method will work currently, and it sets the volume globally. Patch by Yeshua with some cleanup by myself.
This commit is contained in:
@@ -65,6 +65,7 @@ void stopWaveMem(int channel);
|
|||||||
void audioInit();
|
void audioInit();
|
||||||
void audioDestroy();
|
void audioDestroy();
|
||||||
void setChannelFlag(int channel, int flag);
|
void setChannelFlag(int channel, int flag);
|
||||||
|
void setPspVolume(int volume);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,10 @@ public:
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void SetVolume(int volume);
|
void SetVolume(int volume);
|
||||||
|
|
||||||
|
void SetMusicVolume(int volume);
|
||||||
|
|
||||||
|
void SetSfxVolume(int volume);
|
||||||
|
|
||||||
int mChannel;
|
int mChannel;
|
||||||
protected:
|
protected:
|
||||||
JSoundSystem();
|
JSoundSystem();
|
||||||
@@ -191,6 +195,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int mVolume;
|
int mVolume;
|
||||||
|
int mMusicVolume;
|
||||||
|
|
||||||
|
|
||||||
static JSoundSystem* mInstance;
|
static JSoundSystem* mInstance;
|
||||||
|
|||||||
Binary file not shown.
@@ -38,6 +38,13 @@ WAVDATA currentWav[NUMBER_WAV_CHANNELS]; // 各通道当前的播放
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
void setPspVolume(int volume)
|
||||||
|
{
|
||||||
|
pspAudioSetVolume(0, volume, volume);
|
||||||
|
pspAudioSetVolume(1, volume, volume);
|
||||||
|
pspAudioSetVolume(2, volume, volume);
|
||||||
|
}
|
||||||
|
|
||||||
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载, memLoad-是否加载至内磥E
|
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载, memLoad-是否加载至内磥E
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
+16
-3
@@ -145,9 +145,11 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
|||||||
|
|
||||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (music->mTrack)
|
if (music->mTrack)
|
||||||
PlayMP3(music->mTrack, looping);
|
PlayMP3(music->mTrack, looping);
|
||||||
|
JMP3 * mp3 = JMP3::mInstance;
|
||||||
|
if (mp3) mp3->setVolume((mMusicVolume * .01) *0x8000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,11 +159,22 @@ void JSoundSystem::PlaySample(JSample *sample)
|
|||||||
playWaveMem(sample->mSample, 0);
|
playWaveMem(sample->mSample, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JSoundSystem::SetVolume(int volume){
|
||||||
|
SetMusicVolume(volume);
|
||||||
|
SetSfxVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
void JSoundSystem::SetVolume(int volume)
|
void JSoundSystem::SetMusicVolume(int volume)
|
||||||
{
|
{
|
||||||
|
mMusicVolume = volume;
|
||||||
JMP3 * mp3 = JMP3::mInstance;
|
JMP3 * mp3 = JMP3::mInstance;
|
||||||
if (mp3) mp3->setVolume(volume);
|
if (mp3) mp3->setVolume((mMusicVolume * .01) *0x8000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JSoundSystem::SetSfxVolume(int volume)
|
||||||
|
{
|
||||||
|
setPspVolume((volume * .01) *0x8000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-19
@@ -129,23 +129,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
|||||||
return music;
|
return music;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void JSoundSystem::FreeMusic(JMusic *music)
|
|
||||||
// {
|
|
||||||
// if (music)
|
|
||||||
// {
|
|
||||||
// // if (music->mTrack)
|
|
||||||
// // FMUSIC_FreeSong(music->mTrack);
|
|
||||||
// // delete music;
|
|
||||||
// // music = NULL;
|
|
||||||
//
|
|
||||||
// if (music->mTrack)
|
|
||||||
// FSOUND_Sample_Free(music->mTrack);
|
|
||||||
//
|
|
||||||
// //delete music;
|
|
||||||
// //music = NULL;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||||
{
|
{
|
||||||
// if (music && music->mTrack)
|
// if (music && music->mTrack)
|
||||||
@@ -176,14 +159,22 @@ void JSoundSystem::StopMusic(JMusic *music __attribute__((unused)))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSoundSystem::SetVolume(int volume)
|
void JSoundSystem::SetVolume(int volume){
|
||||||
|
SetMusicVolume(volume);
|
||||||
|
SetSfxVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JSoundSystem::SetMusicVolume(int volume)
|
||||||
{
|
{
|
||||||
|
//TODO Fix to affect only mp3 playback...
|
||||||
FSOUND_SetSFXMasterVolume(volume);
|
FSOUND_SetSFXMasterVolume(volume);
|
||||||
|
|
||||||
mVolume = volume;
|
mVolume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JSoundSystem::SetSfxVolume(int volume){
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||||
|
|||||||
@@ -136,22 +136,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
|||||||
return music;
|
return music;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void JSoundSystem::FreeMusic(JMusic *music)
|
|
||||||
// {
|
|
||||||
// if (music)
|
|
||||||
// {
|
|
||||||
// // if (music->mTrack)
|
|
||||||
// // FMUSIC_FreeSong(music->mTrack);
|
|
||||||
// // delete music;
|
|
||||||
// // music = NULL;
|
|
||||||
//
|
|
||||||
// if (music->mTrack)
|
|
||||||
// FSOUND_Sample_Free(music->mTrack);
|
|
||||||
//
|
|
||||||
// //delete music;
|
|
||||||
// //music = NULL;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||||
{
|
{
|
||||||
@@ -171,22 +155,27 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
|||||||
|
|
||||||
void JSoundSystem::StopMusic(JMusic *music)
|
void JSoundSystem::StopMusic(JMusic *music)
|
||||||
{
|
{
|
||||||
// if (music && music->mTrack)
|
|
||||||
// FMUSIC_StopSong(music->mTrack);
|
|
||||||
|
|
||||||
FSOUND_StopSound(mChannel);
|
FSOUND_StopSound(mChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSoundSystem::SetVolume(int volume)
|
void JSoundSystem::SetVolume(int volume)
|
||||||
{
|
{
|
||||||
|
SetMusicVolume(volume);
|
||||||
|
SetSfxVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JSoundSystem::SetMusicVolume(int volume)
|
||||||
|
{
|
||||||
|
//TODO This function needs to be redone
|
||||||
FSOUND_SetSFXMasterVolume(volume);
|
FSOUND_SetSFXMasterVolume(volume);
|
||||||
|
|
||||||
mVolume = volume;
|
mVolume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JSoundSystem::SetSfxVolume(int volume){
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
|||||||
}
|
}
|
||||||
if (unlocked && options[Options::SFXVOLUME].number > 0){
|
if (unlocked && options[Options::SFXVOLUME].number > 0){
|
||||||
JSample * sample = resources.RetrieveSample("bonus.wav");
|
JSample * sample = resources.RetrieveSample("bonus.wav");
|
||||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
if (sample){
|
||||||
|
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,9 @@ void GameApp::Create()
|
|||||||
mCurrentState = NULL;
|
mCurrentState = NULL;
|
||||||
mNextState = mGameStates[GAME_STATE_MENU];
|
mNextState = mGameStates[GAME_STATE_MENU];
|
||||||
|
|
||||||
// effect = NEW CardEffect();
|
//Set Audio volume
|
||||||
|
JSoundSystem::GetInstance()->SetSfxVolume(options[Options::SFXVOLUME].number);
|
||||||
|
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
|
||||||
|
|
||||||
char buf[512];
|
char buf[512];
|
||||||
sprintf(buf, "size of MTGCard : %i\n" , sizeof(MTGCard));
|
sprintf(buf, "size of MTGCard : %i\n" , sizeof(MTGCard));
|
||||||
@@ -246,7 +248,7 @@ void GameApp::Update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Restart Rendering engine when START and TRIANGLE ARE PRESSED SIMULTANEOUSLY
|
//Restart Rendering engine when START and SQUARE ARE PRESSED SIMULTANEOUSLY
|
||||||
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonState(PSP_CTRL_SQUARE)){
|
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonState(PSP_CTRL_SQUARE)){
|
||||||
JRenderer::Destroy();
|
JRenderer::Destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
|||||||
switch (controlId){
|
switch (controlId){
|
||||||
case 1:
|
case 1:
|
||||||
optionsTabs->save();
|
optionsTabs->save();
|
||||||
|
//Set Audio volume
|
||||||
|
JSoundSystem::GetInstance()->SetSfxVolume(options[Options::SFXVOLUME].number);
|
||||||
|
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
|
||||||
case 2:
|
case 2:
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->SetNextState(GAME_STATE_MENU);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1090,31 +1090,6 @@ void WGuiMenu::Add(WGuiBase * it){
|
|||||||
items.push_back(it);
|
items.push_back(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
//WGuiMenu
|
|
||||||
/*
|
|
||||||
void WGuiMenu::Update(float dt){
|
|
||||||
JGE * mEngine = JGE::GetInstance();
|
|
||||||
|
|
||||||
WGuiBase * c = Current();
|
|
||||||
if(c && !c->isModal()){
|
|
||||||
if (mEngine->GetButtonClick(buttonPrev)){
|
|
||||||
if (currentItem > 0 && c->Leaving(buttonPrev)){
|
|
||||||
currentItem--;
|
|
||||||
c = Current();
|
|
||||||
c->Entering(buttonPrev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (mEngine->GetButtonClick(buttonNext)){
|
|
||||||
if (currentItem < (int)items.size()-1 && c->Leaving(buttonNext)){
|
|
||||||
currentItem++;
|
|
||||||
c = Current();
|
|
||||||
c->Entering(buttonNext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(c)
|
|
||||||
c->Update(dt);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
void WGuiMenu::Update(float dt){
|
void WGuiMenu::Update(float dt){
|
||||||
|
|||||||
Reference in New Issue
Block a user