aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SoundContext.cpp
blob: b1f8cb39db93c4d2d25ec4a856bea1e0f9475877 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "../util/Log.h"

#include "SoundContext.h"

using namespace crepe;

SoundContext::SoundContext() {
	dbg_trace();
	this->engine.init();
	this->engine.setMaxActiveVoiceCount(this->config.audio.voices);
}

SoundContext::~SoundContext() {
	dbg_trace();
	this->engine.deinit();
}

SoundHandle SoundContext::play(Sound & resource) {
	SoLoud::handle real_handle = this->engine.play(resource.sample, 1.0f);
	SoundHandle handle = this->next_handle;
	this->registry[handle] = real_handle;
	this->next_handle++;
	return handle;
}

void SoundContext::stop(const SoundHandle & handle) {
	this->engine.stop(this->registry[handle]);
}

void SoundContext::set_volume(const SoundHandle & handle, float volume) {
	this->engine.setVolume(this->registry[handle], volume);
}

void SoundContext::set_loop(const SoundHandle & handle, bool loop) {
	this->engine.setLooping(this->registry[handle], loop);
}