Files
itgmania212121/stepmania/src/RageSoundManager.h
T

85 lines
2.0 KiB
C++
Raw Normal View History

2002-12-13 07:44:34 +00:00
#ifndef RAGE_SOUND_MANAGER_H
#define RAGE_SOUND_MANAGER_H
#include <set>
2002-12-21 02:19:37 +00:00
#include <map>
2002-12-13 07:44:34 +00:00
#include "arch/Sound/RageSoundDriver.h"
#include "RageThreads.h"
class RageSound;
class RageSoundManager
{
/* Set of sounds that we've taken over (and are responsible for deleting
* when they're finished playing): */
set<RageSound *> owned_sounds;
/* Set of sounds that are finished and should be deleted. */
set<RageSound *> sounds_to_delete;
2002-12-22 08:13:33 +00:00
set<RageSound *> playing_sounds;
2002-12-21 02:19:37 +00:00
struct FakeSound {
float begin;
int samples_read;
};
map<RageSound *, FakeSound> fake_sounds;
2002-12-13 07:44:34 +00:00
RageSoundDriver *driver;
/* Prefs: */
float MixVolume;
2003-01-21 02:16:40 +00:00
RageSound *music;
2002-12-13 07:44:34 +00:00
public:
RageMutex lock;
2002-12-13 08:31:39 +00:00
RageSoundManager(CString drivers);
2002-12-13 07:44:34 +00:00
~RageSoundManager();
float GetMixVolume() const { return MixVolume; }
void SetPrefs(float MixVol);
2002-12-13 07:44:34 +00:00
void Update(float delta);
void StartMixing(RageSound *snd); /* used by RageSound */
2002-12-21 02:19:37 +00:00
void StopMixing(RageSound *snd); /* used by RageSound */
2002-12-13 07:44:34 +00:00
int GetPosition(const RageSound *snd) const; /* used by RageSound */
2002-12-21 02:19:37 +00:00
void AddFakeSound(RageSound *snd); /* used by drivers */
2002-12-13 07:44:34 +00:00
float GetPlayLatency() const;
void PlayOnce( CString sPath );
2002-12-22 08:13:33 +00:00
static void PlayOnceFromDir( CString sDir );
2002-12-13 07:44:34 +00:00
2002-12-22 08:13:33 +00:00
RageSound *PlaySound(RageSound &snd);
void StopPlayingSound(RageSound &snd);
void GetCopies(RageSound &snd, vector<RageSound *> &snds);
2002-12-13 07:44:34 +00:00
/* A list of all sounds that currently exist. RageSound adds and removes
* itself to this. */
set<RageSound *> all_sounds;
2002-12-13 08:31:39 +00:00
2003-01-02 07:30:23 +00:00
void PlayMusic(CString file, bool loop = true, float start_sec = -1, float length_sec = -1);
2003-01-21 02:16:40 +00:00
void StopMusic() { PlayMusic(""); }
2002-12-31 01:09:31 +00:00
static void MixAudio(Sint16 *dst, const Sint16 *src, Uint32 len, float volume);
};
/* This inputs and outputs 16-bit 44khz stereo input. */
class SoundMixBuffer
{
basic_string<Sint32> mixbuf;
float vol;
public:
void write(const Sint16 *buf, unsigned size);
void read(Sint16 *buf);
unsigned size() const { return mixbuf.size(); }
void SetVolume(float f);
SoundMixBuffer();
2002-12-13 07:44:34 +00:00
};
extern RageSoundManager *SOUNDMAN;
#endif