🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

FMOD Caps

Published April 15, 2005
Advertisement
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.
0 likes 2 comments

Comments

Rob Loach
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;
			}
		}

		<span clas
April 15, 2005 01:14 PM
coldacid
This has to do with fmodcaps how?
April 27, 2005 04:18 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement