2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 15:55:06 +01:00
|
|
|
#include "std.hpp"
|
|
|
|
|
#include "gxmusic.hpp"
|
|
|
|
|
#include <fmod.h>
|
2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
gxMusic::gxMusic( gxAudio *a,FMUSIC_MODULE *m,FSOUND_STREAM *s ):
|
|
|
|
|
audio(a),module(m),stream(s),stream_channel(-1){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gxMusic::~gxMusic(){
|
|
|
|
|
if( module ) FMUSIC_FreeSong( module );
|
|
|
|
|
else FSOUND_Stream_Close( stream );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gxMusic::play(){
|
|
|
|
|
if( module ){
|
|
|
|
|
FMUSIC_PlaySong( module );
|
|
|
|
|
}else{
|
|
|
|
|
stream_channel=FSOUND_Stream_Play( FSOUND_FREE,stream );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gxMusic::stop(){
|
|
|
|
|
if( module ){
|
|
|
|
|
FMUSIC_StopSong( module );
|
|
|
|
|
}else{
|
|
|
|
|
FSOUND_Stream_Stop( stream );
|
|
|
|
|
stream_channel=-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gxMusic::setVolume( float volume ){
|
|
|
|
|
if( module ){
|
|
|
|
|
FMUSIC_SetMasterVolume( module,volume*255.0f );
|
|
|
|
|
}else{
|
|
|
|
|
FSOUND_SetVolume( stream_channel,volume*255.0f );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gxMusic::setPaused( bool paused){
|
|
|
|
|
if( module ){
|
|
|
|
|
FMUSIC_SetPaused( module,paused );
|
|
|
|
|
}else{
|
|
|
|
|
FSOUND_SetPaused( stream_channel,paused );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool gxMusic::isPlaying()const{
|
|
|
|
|
if( module ){
|
|
|
|
|
return FMUSIC_IsPlaying( module ) ? true : false;
|
|
|
|
|
}else{
|
|
|
|
|
return FSOUND_IsPlaying( stream_channel ) ? true : false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|