Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (61 sloc) 1.85 kB
#ifndef __OGGMIX_H
#define __OGGMIX_H
#include <string>
#include <map>
class Body;
namespace Sound {
enum {
OP_REPEAT = (1<<0),
typedef Uint32 Op;
struct Sample {
Uint16 *buf;
Uint32 buf_len;
Uint32 channels;
int upsample; // 1 = 44100, 2=22050
/* if buf is null, this will be path to an ogg we must stream */
std::string path;
bool isMusic;
class Event {
Event(): eid(0) {}
Event(Uint32 id): eid(id) {}
virtual void Play(const char *fx, const float volume_left, const float volume_right, Op op);
void Play(const char *fx) { Play(fx, 1.0f, 1.0f, 0); }
bool Stop();
bool IsPlaying() const;
Uint32 EventId() { return eid; }
bool SetOp(Op op);
bool VolumeAnimate(const float targetVol1, const float targetVol2, const float dv_dt1, const float dv_dt2);
bool VolumeAnimate(const float targetVols[2], const float dv_dt[2]) {
return VolumeAnimate(targetVols[0], targetVols[1],
dv_dt[0], dv_dt[1]);
bool SetVolume(const float vol_left, const float vol_right);
bool SetVolume(const float vol) {
return SetVolume(vol, vol);
Uint32 eid;
typedef Uint32 eventid;
bool Init ();
void Uninit ();
* Silence all active sound events.
void DestroyAllEvents();
void Pause (int on);
eventid PlaySfx (const char *fx, const float volume_left, const float volume_right, const Op op);
eventid PlayMusic (const char *fx, const float volume_left, const float volume_right, const Op op);
inline static eventid PlaySfx (const char *fx) { return PlaySfx(fx, 1.0f, 1.0f, 0); }
eventid BodyMakeNoise(const Body *b, const char *fx, float vol);
void SetMasterVolume(const float vol);
float GetMasterVolume();
void SetSfxVolume(const float vol);
float GetSfxVolume();
const std::map<std::string, Sample> & GetSamples();
} /* namespace Sound */
#endif /* __OGGMIX_H */
Jump to Line
Something went wrong with that request. Please try again.