Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    37
  • comments
    68
  • views
    46936

FMOD Caps

Sign in to follow this  
coldacid

622 views

I've created a little program for checking FMOD capabilities. It's a command-line program, but it works well. Anyway, you can download it here.
Sign in to follow this  


2 Comments


Recommended Comments

OMGOMGOMGOMG

audio.h
#if !defined(_AUDIOSYSTEM_H_INCLUDED_)

#define _AUDIOSYSTEM_H_INCLUDED_

#include <string>
#include <map>

#include <FMOD/fmod.h>
#include <FMOD/fmod_errors.h> // optional




namespace System {

class AudioItem;
class MusicItem;
class SoundItem;

extern MusicItem* currentMusic;

class CAudio {
public:
CAudio();
~CAudio();


void Close(std::string filename);

void Stop();
bool Stop(std::string filename);
void StopMusic();
int MusicVolume(int volume);

bool Load(std::string name, std::string filename, int type = 0);
void Play(std::string filename);
void Pause(std::string filename, bool pause);
bool Pause(std::string filename);
void Looping(std::string filename, bool looping);
bool Looping(std::string filename);

void Volume(int volume);
int Volume();
void Volume(std::string filename, int volume);
int Volume(std::string filename);
};

extern CAudio Audio;


/*****************************************************************/
class AudioItem
{
public:
virtual ~AudioItem() { }
virtual void Play() = 0;
virtual void Stop() = 0;
virtual void Close() = 0;
virtual bool Load(std::string) = 0;

// These functions only exist in Music
virtual void Pause(bool pause){ }
virtual bool Pause(){ return false; }
virtual bool Looping(){ return false; }
virtual void Looping(bool looping){ }

virtual void Volume(int volume) { }
virtual int Volume() { return 100; }

int type;
};


/*****************************************************************/
class SoundItem : public AudioItem
{
public:
SoundItem() : channel(-1), handle(NULL) { }
bool Load(std::string filename){
handle = FSOUND_Sample_Load(
FSOUND_FREE|FSOUND_UNMANAGED,
filename.c_str(), 0, 0, 0);
return handle != NULL;
}
void Stop() { FSOUND_StopSound(channel); }
void Play() {
if(handle)
channel = FSOUND_PlaySound(FSOUND_FREE, handle);
}
void Close() {
if(handle){
Stop();
FSOUND_Sample_Free(handle);
handle = NULL;
}
}
~SoundItem() { Close(); }

FSOUND_SAMPLE* Handle(){ return handle; }
private:
FSOUND_SAMPLE* handle;
int channel;
};


/*****************************************************************/


class MusicItem : public AudioItem
{
public:
MusicItem() : looping(true), handle(NULL) { }
bool Load(std::string filename){
handle = FMUSIC_LoadSong(filename.c_str());
return handle != NULL;
}
void Close(){
Stop();
if(handle){
FMUSIC_FreeSong(handle);
handle = NULL;
}
}
~MusicItem(){ Close(); }
void Play() {
if(handle){
if(currentMusic){
FMUSIC_StopSong(currentMusic->Handle());
}
currentMusic = this;
FMUSIC_PlaySong(handle);
}
}
void Stop() {
if(handle){
FMUSIC_StopSong(handle);
currentMusic = NULL;
}
}
void Pause(bool pause) {
if(handle)
FMUSIC_SetPaused(handle, pause);
}
bool Pause() {
if(handle)
return FMUSIC_GetPaused(handle);
else
return false;
}
bool Looping(){ return looping; }
void Looping(bool looping){
if(handle){
FMUSIC_SetLooping(handle, looping);
this->looping = looping;
}
}

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!