Rename audio_engine to audio

This commit is contained in:
andrey.zhirnov
2019-06-07 10:18:25 +03:00
parent 421bee4ea8
commit 68091d00e3
8 changed files with 47 additions and 47 deletions

View File

@@ -18,4 +18,4 @@
#include "render.inl"
#include "vfs.hpp"
#include "window.hpp"
#include "audio_engine.hpp"
#include "audio.hpp"

View File

@@ -71,13 +71,13 @@ namespace e2d
};
//
// audio_engine
// audio
//
class audio_engine final : public module<audio_engine> {
class audio final : public module<audio> {
public:
audio_engine(debug& d);
~audio_engine() noexcept;
audio(debug& d);
~audio() noexcept;
void volume(float value) noexcept;
[[nodiscard]] float volume() const noexcept;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <enduro2d/core/audio_engine.hpp>
#include <enduro2d/core/audio.hpp>
#define E2D_AUDIO_MODE_NONE 1
#define E2D_AUDIO_MODE_FMOD 2

View File

@@ -103,10 +103,10 @@ namespace e2d
}
//
// audio_engine
// audio
//
audio_engine::audio_engine(debug& d)
audio::audio(debug& d)
: state_(std::make_unique<internal_state>(d)) {
if ( !BASS_Init(-1, 44100, BASS_DEVICE_3D, nullptr, nullptr) ) {
state_->dbg().error("AUDIO: Initialization failed");
@@ -114,11 +114,11 @@ namespace e2d
}
}
audio_engine::~audio_engine() noexcept {
audio::~audio() noexcept {
BASS_Free();
}
sound_stream_ptr audio_engine::create_stream(
sound_stream_ptr audio::create_stream(
buffer_view sound_data) {
if (sound_data.empty()) {
state_->dbg().error("AUDIO: Sound data is empty");
@@ -133,7 +133,7 @@ namespace e2d
std::make_unique<sound_stream::internal_state>(state_->dbg(), sample));
}
sound_stream_ptr audio_engine::create_stream(
sound_stream_ptr audio::create_stream(
const input_stream_uptr& file_stream) {
buffer file_data;
if (!streams::try_read_tail(file_data, file_stream)) {
@@ -143,7 +143,7 @@ namespace e2d
return create_stream(buffer_view(file_data));
}
sound_source_ptr audio_engine::create_source(
sound_source_ptr audio::create_source(
const sound_stream_ptr &stream) {
if (!stream) {
state_->dbg().error("AUDIO: stream is null");
@@ -158,47 +158,47 @@ namespace e2d
std::make_unique<sound_source::internal_state>(state_->dbg(), channel));
}
void audio_engine::volume(float value) noexcept {
void audio::volume(float value) noexcept {
BASS_SetVolume(value);
}
float audio_engine::volume() const noexcept {
float audio::volume() const noexcept {
return BASS_GetVolume();
}
void audio_engine::resume() noexcept {
void audio::resume() noexcept {
if ( !BASS_Start() )
state_->dbg().error("AUDIO: Failed to resume audio output");
}
void audio_engine::pause() noexcept {
void audio::pause() noexcept {
if ( !BASS_Pause() )
state_->dbg().error("AUDIO: Failed to resume audio output");
}
void audio_engine::listener_position(const v3f &value) noexcept {
void audio::listener_position(const v3f &value) noexcept {
BASS_3DVECTOR pos = {value.x, value.y, value.z};
BASS_Set3DPosition(&pos, nullptr, nullptr, nullptr);
}
v3f audio_engine::listener_position() const noexcept {
v3f audio::listener_position() const noexcept {
BASS_3DVECTOR pos = {};
BASS_Get3DPosition(&pos, nullptr, nullptr, nullptr);
return v3f{pos.x, pos.y, pos.z};
}
void audio_engine::listener_velocity(const v3f &value) noexcept {
void audio::listener_velocity(const v3f &value) noexcept {
BASS_3DVECTOR vel = {value.x, value.y, value.z};
BASS_Set3DPosition(nullptr, &vel, nullptr, nullptr);
}
v3f audio_engine::listener_velocity() const noexcept {
v3f audio::listener_velocity() const noexcept {
BASS_3DVECTOR vel = {};
BASS_Get3DPosition(nullptr, &vel, nullptr, nullptr);
return v3f{vel.x, vel.y, vel.z};
}
void audio_engine::apply3d() noexcept {
void audio::apply3d() noexcept {
BASS_Apply3D();
}
}

View File

@@ -47,14 +47,14 @@ namespace e2d
}
//
// audio_engine::internal_state
// audio::internal_state
//
audio_engine::internal_state::internal_state(debug& debug)
audio::internal_state::internal_state(debug& debug)
: debug_(debug) {
}
debug& audio_engine::internal_state::dbg() const noexcept {
debug& audio::internal_state::dbg() const noexcept {
return debug_;
}
}

View File

@@ -1,6 +1,6 @@
#pragma once
#include "audio_engine.hpp"
#include "audio.hpp"
#include <3rdparty/bass/bass.h>
#if defined(E2D_AUDIO_MODE) && E2D_AUDIO_MODE == E2D_AUDIO_MODE_BASS
@@ -45,10 +45,10 @@ namespace e2d
};
//
// audio_engine::internal_state
// audio::internal_state
//
class audio_engine::internal_state final : private e2d::noncopyable {
class audio::internal_state final : private e2d::noncopyable {
public:
internal_state(debug& debug);
~internal_state() noexcept = default;

View File

@@ -1,4 +1,4 @@
#include "audio_engine.hpp"
#include "audio.hpp"
#if defined(E2D_AUDIO_MODE) && E2D_AUDIO_MODE == E2D_AUDIO_MODE_NONE
@@ -26,10 +26,10 @@ namespace e2d
};
//
// audio_engine::internal_state
// audio::internal_state
//
class audio_engine::internal_state final : private e2d::noncopyable {
class audio::internal_state final : private e2d::noncopyable {
public:
internal_state() noexcept = default;
~internal_state() noexcept = default;
@@ -115,66 +115,66 @@ namespace e2d
}
//
// audio_engine
// audio
//
audio_engine::audio_engine(debug& d)
audio::audio(debug& d)
: state_(std::make_unique<internal_state>()) {
E2D_UNUSED(d);
}
audio_engine::~audio_engine() noexcept {
audio::audio() noexcept {
}
sound_stream_ptr audio_engine::create_stream(
sound_stream_ptr audio::create_stream(
buffer_view sound_data) {
E2D_UNUSED(sound_data);
return nullptr;
}
sound_stream_ptr audio_engine::create_stream(
sound_stream_ptr audio::create_stream(
const input_stream_uptr& file_stream) {
E2D_UNUSED(file_stream);
return nullptr;
}
sound_source_ptr audio_engine::create_source(
sound_source_ptr audio::create_source(
const sound_stream_ptr &stream) {
E2D_UNUSED(stream);
return nullptr;
}
void audio_engine::volume(float value) noexcept {
void audio::volume(float value) noexcept {
E2D_UNUSED(value);
}
float audio_engine::volume() const noexcept {
float audio::volume() const noexcept {
return 1.0f;
}
void audio_engine::resume() noexcept {
void audio::resume() noexcept {
}
void audio_engine::pause() noexcept {
void audio::pause() noexcept {
}
void audio_engine::listener_position(const v3f &value) noexcept {
void audio::listener_position(const v3f &value) noexcept {
E2D_UNUSED(value);
}
v3f audio_engine::listener_position() const noexcept {
v3f audio::listener_position() const noexcept {
return {};
}
void audio_engine::listener_velocity(const v3f &value) noexcept {
void audio::listener_velocity(const v3f &value) noexcept {
E2D_UNUSED(value);
}
v3f audio_engine::listener_velocity() const noexcept {
v3f audio::listener_velocity() const noexcept {
return {};
}
void audio_engine::apply3d() noexcept {
void audio::apply3d() noexcept {
}
}

View File

@@ -14,7 +14,7 @@
#include <enduro2d/core/render.hpp>
#include <enduro2d/core/vfs.hpp>
#include <enduro2d/core/window.hpp>
#include <enduro2d/core/audio_engine.hpp>
#include <enduro2d/core/audio.hpp>
namespace
{
@@ -423,7 +423,7 @@ namespace e2d
if ( !params.without_sound() )
{
safe_module_initialize<audio_engine>(
safe_module_initialize<audio>(
the<debug>());
}
}