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:
@@ -1,87 +1,88 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
// Copyright (c) 2007 Cooleyes
|
||||
// Copyright (c) 2007 Mr.Cheese
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _JAUDIO_H_
|
||||
#define _JAUDIO_H_
|
||||
|
||||
|
||||
#include <pspiofilemgr.h>
|
||||
#include <pspaudiolib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
#define PW_REPLAY 0x00000001 //
|
||||
#define PW_DELAY 0x00000010 //
|
||||
#define PW_FAST 0x00000100 //
|
||||
#define PW_PAUSE 0x00001000 //
|
||||
|
||||
#define NUMBER_WAV_CHANNELS 3
|
||||
|
||||
typedef struct _WAVDATA
|
||||
{
|
||||
char fullName[256]; // filename
|
||||
unsigned long fileSize; // size of file
|
||||
short headSize; // size of head
|
||||
unsigned short format; //
|
||||
unsigned short channelCount; //
|
||||
unsigned long samplePerSecond; //
|
||||
unsigned long bytePerSecond; //
|
||||
unsigned short bytePerSample; //
|
||||
unsigned long soundSize; //
|
||||
char* buffer; // sound data
|
||||
SceUID fd; // file id for streaming
|
||||
unsigned long bytePosition; // current read position
|
||||
char nSample; // progress rate
|
||||
unsigned long sizeStep; //
|
||||
unsigned long flag; // playback flag
|
||||
unsigned long delayTime; // delay time in (us)
|
||||
|
||||
} WAVDATA;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad);
|
||||
void releaseWaveData(WAVDATA* p_wav);
|
||||
void audioOutCallback(int channel, void* buf, unsigned int length);
|
||||
void audioOutCallback_0(void* buf, unsigned int length, void *userdata);
|
||||
void audioOutCallback_1(void* buf, unsigned int length, void *userdata);
|
||||
void audioOutCallback_2(void* buf, unsigned int length, void *userdata);
|
||||
//void audioOutCallback_3(void* buf, unsigned int length, void *userdata);
|
||||
char playWaveFile(int channel, char* fullName, unsigned long flag);
|
||||
void stopWaveFile(int channel);
|
||||
int playWaveMem(WAVDATA* p_wav, unsigned long flag);
|
||||
void stopWaveMem(int channel);
|
||||
void audioInit();
|
||||
void audioDestroy();
|
||||
void setChannelFlag(int channel, int flag);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define DECODING_BUFFER_COUNT 2
|
||||
#define SAMPLE_PER_FRAME 1152
|
||||
#define MAX_MP3_FILE 2
|
||||
|
||||
class JMP3;
|
||||
|
||||
void PlayMP3(JMP3 *mp3, bool looping = false);
|
||||
void StopMP3();
|
||||
void ResumeMP3(JMP3 *mp3);
|
||||
|
||||
void ReleaseMP3Decoder();
|
||||
void MP3AudioOutCallback(void* buf, unsigned int length, void *userdata);
|
||||
int decodeThread2(SceSize args, void *argp);
|
||||
extern bool g_MP3DecoderOK;
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
// Copyright (c) 2007 Cooleyes
|
||||
// Copyright (c) 2007 Mr.Cheese
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _JAUDIO_H_
|
||||
#define _JAUDIO_H_
|
||||
|
||||
|
||||
#include <pspiofilemgr.h>
|
||||
#include <pspaudiolib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
#define PW_REPLAY 0x00000001 //
|
||||
#define PW_DELAY 0x00000010 //
|
||||
#define PW_FAST 0x00000100 //
|
||||
#define PW_PAUSE 0x00001000 //
|
||||
|
||||
#define NUMBER_WAV_CHANNELS 3
|
||||
|
||||
typedef struct _WAVDATA
|
||||
{
|
||||
char fullName[256]; // filename
|
||||
unsigned long fileSize; // size of file
|
||||
short headSize; // size of head
|
||||
unsigned short format; //
|
||||
unsigned short channelCount; //
|
||||
unsigned long samplePerSecond; //
|
||||
unsigned long bytePerSecond; //
|
||||
unsigned short bytePerSample; //
|
||||
unsigned long soundSize; //
|
||||
char* buffer; // sound data
|
||||
SceUID fd; // file id for streaming
|
||||
unsigned long bytePosition; // current read position
|
||||
char nSample; // progress rate
|
||||
unsigned long sizeStep; //
|
||||
unsigned long flag; // playback flag
|
||||
unsigned long delayTime; // delay time in (us)
|
||||
|
||||
} WAVDATA;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad);
|
||||
void releaseWaveData(WAVDATA* p_wav);
|
||||
void audioOutCallback(int channel, void* buf, unsigned int length);
|
||||
void audioOutCallback_0(void* buf, unsigned int length, void *userdata);
|
||||
void audioOutCallback_1(void* buf, unsigned int length, void *userdata);
|
||||
void audioOutCallback_2(void* buf, unsigned int length, void *userdata);
|
||||
//void audioOutCallback_3(void* buf, unsigned int length, void *userdata);
|
||||
char playWaveFile(int channel, char* fullName, unsigned long flag);
|
||||
void stopWaveFile(int channel);
|
||||
int playWaveMem(WAVDATA* p_wav, unsigned long flag);
|
||||
void stopWaveMem(int channel);
|
||||
void audioInit();
|
||||
void audioDestroy();
|
||||
void setChannelFlag(int channel, int flag);
|
||||
void setPspVolume(int volume);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define DECODING_BUFFER_COUNT 2
|
||||
#define SAMPLE_PER_FRAME 1152
|
||||
#define MAX_MP3_FILE 2
|
||||
|
||||
class JMP3;
|
||||
|
||||
void PlayMP3(JMP3 *mp3, bool looping = false);
|
||||
void StopMP3();
|
||||
void ResumeMP3(JMP3 *mp3);
|
||||
|
||||
void ReleaseMP3Decoder();
|
||||
void MP3AudioOutCallback(void* buf, unsigned int length, void *userdata);
|
||||
int decodeThread2(SceSize args, void *argp);
|
||||
extern bool g_MP3DecoderOK;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,200 +1,205 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _JSOUNDSYSTEM_H_
|
||||
#define _JSOUNDSYSTEM_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "JTypes.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#elif defined (LINUX)
|
||||
#else
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspkernel.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspctrl.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <pspaudiolib.h>
|
||||
#include <psprtc.h>
|
||||
|
||||
#include "JAudio.h"
|
||||
#include "JMP3.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
class JMusic
|
||||
{
|
||||
public:
|
||||
JMusic();
|
||||
~JMusic();
|
||||
void Update();
|
||||
int getPlayTime();
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
|
||||
#else
|
||||
JMP3* mTrack;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
class JSample
|
||||
{
|
||||
public:
|
||||
JSample();
|
||||
~JSample();
|
||||
|
||||
int mVoice;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
FSOUND_SAMPLE *mSample;
|
||||
#else
|
||||
WAVDATA *mSample;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Sound engine for playing sound effects (WAV) and background
|
||||
/// music (MP3).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JSoundSystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get the singleton instance
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static JSoundSystem* GetInstance();
|
||||
|
||||
static void Destroy();
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load music.
|
||||
///
|
||||
/// @note MP3 is the only supported format for the moment.
|
||||
///
|
||||
/// @param filename - Name of the music file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JMusic *LoadMusic(const char *fileName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Delete music from memory.
|
||||
///
|
||||
/// @param music - Music to be deleted.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//void FreeMusic(JMusic *music);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Play music.
|
||||
///
|
||||
/// @param music - Music to be played.
|
||||
/// @param looping - Play the music in a loop.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PlayMusic(JMusic *music, bool looping = false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop playing.
|
||||
///
|
||||
/// @param music - Music to be stopped.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopMusic(JMusic *music);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Resume playing.
|
||||
///
|
||||
/// @param music - Music to be resumed.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResumeMusic(JMusic *music);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load sound effect.
|
||||
///
|
||||
/// @note WAV sound effect only.
|
||||
///
|
||||
/// @param fileName - Sound effect for loading.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JSample *LoadSample(const char *fileName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Delete sound effect from memory.
|
||||
///
|
||||
/// @param sample - Sound to be deleted.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//void FreeSample(JSample *sample);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Play sound effect.
|
||||
///
|
||||
/// @param sample - Sound for playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PlaySample(JSample *sample);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set volume for audio playback.
|
||||
///
|
||||
/// @param volume - New volume.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetVolume(int volume);
|
||||
|
||||
int mChannel;
|
||||
protected:
|
||||
JSoundSystem();
|
||||
~JSoundSystem();
|
||||
|
||||
void InitSoundSystem();
|
||||
void DestroySoundSystem();
|
||||
|
||||
private:
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
JMusic *mCurrentMusic;
|
||||
|
||||
#endif
|
||||
|
||||
int mVolume;
|
||||
|
||||
|
||||
static JSoundSystem* mInstance;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _JSOUNDSYSTEM_H_
|
||||
#define _JSOUNDSYSTEM_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "JTypes.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#elif defined (LINUX)
|
||||
#else
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspkernel.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspctrl.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <pspaudiolib.h>
|
||||
#include <psprtc.h>
|
||||
|
||||
#include "JAudio.h"
|
||||
#include "JMP3.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
class JMusic
|
||||
{
|
||||
public:
|
||||
JMusic();
|
||||
~JMusic();
|
||||
void Update();
|
||||
int getPlayTime();
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
|
||||
#else
|
||||
JMP3* mTrack;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
class JSample
|
||||
{
|
||||
public:
|
||||
JSample();
|
||||
~JSample();
|
||||
|
||||
int mVoice;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
FSOUND_SAMPLE *mSample;
|
||||
#else
|
||||
WAVDATA *mSample;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Sound engine for playing sound effects (WAV) and background
|
||||
/// music (MP3).
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class JSoundSystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Get the singleton instance
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static JSoundSystem* GetInstance();
|
||||
|
||||
static void Destroy();
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load music.
|
||||
///
|
||||
/// @note MP3 is the only supported format for the moment.
|
||||
///
|
||||
/// @param filename - Name of the music file.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JMusic *LoadMusic(const char *fileName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Delete music from memory.
|
||||
///
|
||||
/// @param music - Music to be deleted.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//void FreeMusic(JMusic *music);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Play music.
|
||||
///
|
||||
/// @param music - Music to be played.
|
||||
/// @param looping - Play the music in a loop.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PlayMusic(JMusic *music, bool looping = false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Stop playing.
|
||||
///
|
||||
/// @param music - Music to be stopped.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopMusic(JMusic *music);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Resume playing.
|
||||
///
|
||||
/// @param music - Music to be resumed.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResumeMusic(JMusic *music);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Load sound effect.
|
||||
///
|
||||
/// @note WAV sound effect only.
|
||||
///
|
||||
/// @param fileName - Sound effect for loading.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JSample *LoadSample(const char *fileName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Delete sound effect from memory.
|
||||
///
|
||||
/// @param sample - Sound to be deleted.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//void FreeSample(JSample *sample);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Play sound effect.
|
||||
///
|
||||
/// @param sample - Sound for playing.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PlaySample(JSample *sample);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Set volume for audio playback.
|
||||
///
|
||||
/// @param volume - New volume.
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetVolume(int volume);
|
||||
|
||||
void SetMusicVolume(int volume);
|
||||
|
||||
void SetSfxVolume(int volume);
|
||||
|
||||
int mChannel;
|
||||
protected:
|
||||
JSoundSystem();
|
||||
~JSoundSystem();
|
||||
|
||||
void InitSoundSystem();
|
||||
void DestroySoundSystem();
|
||||
|
||||
private:
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
JMusic *mCurrentMusic;
|
||||
|
||||
#endif
|
||||
|
||||
int mVolume;
|
||||
int mMusicVolume;
|
||||
|
||||
|
||||
static JSoundSystem* mInstance;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
|
||||
@@ -145,9 +145,11 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
|
||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
{
|
||||
|
||||
if (music->mTrack)
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
if (mp3) mp3->setVolume(volume);
|
||||
if (mp3) mp3->setVolume((mMusicVolume * .01) *0x8000);
|
||||
}
|
||||
|
||||
void JSoundSystem::SetSfxVolume(int volume)
|
||||
{
|
||||
setPspVolume((volume * .01) *0x8000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -129,23 +129,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
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)
|
||||
{
|
||||
// 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);
|
||||
|
||||
mVolume = volume;
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::SetSfxVolume(int volume){
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
|
||||
@@ -136,22 +136,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
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)
|
||||
{
|
||||
@@ -171,22 +155,27 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
|
||||
void JSoundSystem::StopMusic(JMusic *music)
|
||||
{
|
||||
// if (music && music->mTrack)
|
||||
// FMUSIC_StopSong(music->mTrack);
|
||||
|
||||
FSOUND_StopSound(mChannel);
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::SetVolume(int volume)
|
||||
{
|
||||
SetMusicVolume(volume);
|
||||
SetSfxVolume(volume);
|
||||
}
|
||||
|
||||
void JSoundSystem::SetMusicVolume(int volume)
|
||||
{
|
||||
//TODO This function needs to be redone
|
||||
FSOUND_SetSFXMasterVolume(volume);
|
||||
|
||||
mVolume = volume;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JSoundSystem::SetSfxVolume(int volume){
|
||||
//TODO
|
||||
}
|
||||
|
||||
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){
|
||||
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;
|
||||
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];
|
||||
sprintf(buf, "size of MTGCard : %i\n" , sizeof(MTGCard));
|
||||
@@ -246,7 +248,7 @@ void GameApp::Update()
|
||||
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)){
|
||||
JRenderer::Destroy();
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ void GameStateDuel::Update(float dt)
|
||||
|
||||
if (MusicExist(musictrack)){
|
||||
GameApp::music = resources.ssLoadMusic(musictrack.c_str());
|
||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
||||
}
|
||||
}
|
||||
//end of music code
|
||||
|
||||
@@ -195,6 +195,9 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
switch (controlId){
|
||||
case 1:
|
||||
optionsTabs->save();
|
||||
//Set Audio volume
|
||||
JSoundSystem::GetInstance()->SetSfxVolume(options[Options::SFXVOLUME].number);
|
||||
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
|
||||
case 2:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
break;
|
||||
|
||||
@@ -1090,31 +1090,6 @@ void WGuiMenu::Add(WGuiBase * 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){
|
||||
@@ -1238,7 +1213,7 @@ void WGuiTabMenu::Render(){
|
||||
|
||||
void WGuiTabMenu::save(){
|
||||
confirmChange(true);
|
||||
setData();
|
||||
setData();
|
||||
::options.save();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user