mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-16 22:16:53 +07:00
Rename audio_engine to audio
This commit is contained in:
@@ -18,4 +18,4 @@
|
|||||||
#include "render.inl"
|
#include "render.inl"
|
||||||
#include "vfs.hpp"
|
#include "vfs.hpp"
|
||||||
#include "window.hpp"
|
#include "window.hpp"
|
||||||
#include "audio_engine.hpp"
|
#include "audio.hpp"
|
||||||
|
|||||||
@@ -71,13 +71,13 @@ namespace e2d
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// audio_engine
|
// audio
|
||||||
//
|
//
|
||||||
|
|
||||||
class audio_engine final : public module<audio_engine> {
|
class audio final : public module<audio> {
|
||||||
public:
|
public:
|
||||||
audio_engine(debug& d);
|
audio(debug& d);
|
||||||
~audio_engine() noexcept;
|
~audio() noexcept;
|
||||||
|
|
||||||
void volume(float value) noexcept;
|
void volume(float value) noexcept;
|
||||||
[[nodiscard]] float volume() const noexcept;
|
[[nodiscard]] float volume() const noexcept;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <enduro2d/core/audio_engine.hpp>
|
#include <enduro2d/core/audio.hpp>
|
||||||
|
|
||||||
#define E2D_AUDIO_MODE_NONE 1
|
#define E2D_AUDIO_MODE_NONE 1
|
||||||
#define E2D_AUDIO_MODE_FMOD 2
|
#define E2D_AUDIO_MODE_FMOD 2
|
||||||
@@ -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)) {
|
: state_(std::make_unique<internal_state>(d)) {
|
||||||
if ( !BASS_Init(-1, 44100, BASS_DEVICE_3D, nullptr, nullptr) ) {
|
if ( !BASS_Init(-1, 44100, BASS_DEVICE_3D, nullptr, nullptr) ) {
|
||||||
state_->dbg().error("AUDIO: Initialization failed");
|
state_->dbg().error("AUDIO: Initialization failed");
|
||||||
@@ -114,11 +114,11 @@ namespace e2d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_engine::~audio_engine() noexcept {
|
audio::~audio() noexcept {
|
||||||
BASS_Free();
|
BASS_Free();
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_stream_ptr audio_engine::create_stream(
|
sound_stream_ptr audio::create_stream(
|
||||||
buffer_view sound_data) {
|
buffer_view sound_data) {
|
||||||
if (sound_data.empty()) {
|
if (sound_data.empty()) {
|
||||||
state_->dbg().error("AUDIO: Sound data is 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));
|
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) {
|
const input_stream_uptr& file_stream) {
|
||||||
buffer file_data;
|
buffer file_data;
|
||||||
if (!streams::try_read_tail(file_data, file_stream)) {
|
if (!streams::try_read_tail(file_data, file_stream)) {
|
||||||
@@ -143,7 +143,7 @@ namespace e2d
|
|||||||
return create_stream(buffer_view(file_data));
|
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) {
|
const sound_stream_ptr &stream) {
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
state_->dbg().error("AUDIO: stream is null");
|
state_->dbg().error("AUDIO: stream is null");
|
||||||
@@ -158,47 +158,47 @@ namespace e2d
|
|||||||
std::make_unique<sound_source::internal_state>(state_->dbg(), channel));
|
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);
|
BASS_SetVolume(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
float audio_engine::volume() const noexcept {
|
float audio::volume() const noexcept {
|
||||||
return BASS_GetVolume();
|
return BASS_GetVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_engine::resume() noexcept {
|
void audio::resume() noexcept {
|
||||||
if ( !BASS_Start() )
|
if ( !BASS_Start() )
|
||||||
state_->dbg().error("AUDIO: Failed to resume audio output");
|
state_->dbg().error("AUDIO: Failed to resume audio output");
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_engine::pause() noexcept {
|
void audio::pause() noexcept {
|
||||||
if ( !BASS_Pause() )
|
if ( !BASS_Pause() )
|
||||||
state_->dbg().error("AUDIO: Failed to resume audio output");
|
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_3DVECTOR pos = {value.x, value.y, value.z};
|
||||||
BASS_Set3DPosition(&pos, nullptr, nullptr, nullptr);
|
BASS_Set3DPosition(&pos, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
v3f audio_engine::listener_position() const noexcept {
|
v3f audio::listener_position() const noexcept {
|
||||||
BASS_3DVECTOR pos = {};
|
BASS_3DVECTOR pos = {};
|
||||||
BASS_Get3DPosition(&pos, nullptr, nullptr, nullptr);
|
BASS_Get3DPosition(&pos, nullptr, nullptr, nullptr);
|
||||||
return v3f{pos.x, pos.y, pos.z};
|
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_3DVECTOR vel = {value.x, value.y, value.z};
|
||||||
BASS_Set3DPosition(nullptr, &vel, nullptr, nullptr);
|
BASS_Set3DPosition(nullptr, &vel, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
v3f audio_engine::listener_velocity() const noexcept {
|
v3f audio::listener_velocity() const noexcept {
|
||||||
BASS_3DVECTOR vel = {};
|
BASS_3DVECTOR vel = {};
|
||||||
BASS_Get3DPosition(nullptr, &vel, nullptr, nullptr);
|
BASS_Get3DPosition(nullptr, &vel, nullptr, nullptr);
|
||||||
return v3f{vel.x, vel.y, vel.z};
|
return v3f{vel.x, vel.y, vel.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_engine::apply3d() noexcept {
|
void audio::apply3d() noexcept {
|
||||||
BASS_Apply3D();
|
BASS_Apply3D();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_(debug) {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug& audio_engine::internal_state::dbg() const noexcept {
|
debug& audio::internal_state::dbg() const noexcept {
|
||||||
return debug_;
|
return debug_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "audio_engine.hpp"
|
#include "audio.hpp"
|
||||||
#include <3rdparty/bass/bass.h>
|
#include <3rdparty/bass/bass.h>
|
||||||
|
|
||||||
#if defined(E2D_AUDIO_MODE) && E2D_AUDIO_MODE == E2D_AUDIO_MODE_BASS
|
#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:
|
public:
|
||||||
internal_state(debug& debug);
|
internal_state(debug& debug);
|
||||||
~internal_state() noexcept = default;
|
~internal_state() noexcept = default;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "audio_engine.hpp"
|
#include "audio.hpp"
|
||||||
|
|
||||||
#if defined(E2D_AUDIO_MODE) && E2D_AUDIO_MODE == E2D_AUDIO_MODE_NONE
|
#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:
|
public:
|
||||||
internal_state() noexcept = default;
|
internal_state() noexcept = default;
|
||||||
~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>()) {
|
: state_(std::make_unique<internal_state>()) {
|
||||||
E2D_UNUSED(d);
|
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) {
|
buffer_view sound_data) {
|
||||||
E2D_UNUSED(sound_data);
|
E2D_UNUSED(sound_data);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_stream_ptr audio_engine::create_stream(
|
sound_stream_ptr audio::create_stream(
|
||||||
const input_stream_uptr& file_stream) {
|
const input_stream_uptr& file_stream) {
|
||||||
E2D_UNUSED(file_stream);
|
E2D_UNUSED(file_stream);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_source_ptr audio_engine::create_source(
|
sound_source_ptr audio::create_source(
|
||||||
const sound_stream_ptr &stream) {
|
const sound_stream_ptr &stream) {
|
||||||
E2D_UNUSED(stream);
|
E2D_UNUSED(stream);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_engine::volume(float value) noexcept {
|
void audio::volume(float value) noexcept {
|
||||||
E2D_UNUSED(value);
|
E2D_UNUSED(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
float audio_engine::volume() const noexcept {
|
float audio::volume() const noexcept {
|
||||||
return 1.0f;
|
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);
|
E2D_UNUSED(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
v3f audio_engine::listener_position() const noexcept {
|
v3f audio::listener_position() const noexcept {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_engine::listener_velocity(const v3f &value) noexcept {
|
void audio::listener_velocity(const v3f &value) noexcept {
|
||||||
E2D_UNUSED(value);
|
E2D_UNUSED(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
v3f audio_engine::listener_velocity() const noexcept {
|
v3f audio::listener_velocity() const noexcept {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_engine::apply3d() noexcept {
|
void audio::apply3d() noexcept {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <enduro2d/core/render.hpp>
|
#include <enduro2d/core/render.hpp>
|
||||||
#include <enduro2d/core/vfs.hpp>
|
#include <enduro2d/core/vfs.hpp>
|
||||||
#include <enduro2d/core/window.hpp>
|
#include <enduro2d/core/window.hpp>
|
||||||
#include <enduro2d/core/audio_engine.hpp>
|
#include <enduro2d/core/audio.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -423,7 +423,7 @@ namespace e2d
|
|||||||
|
|
||||||
if ( !params.without_sound() )
|
if ( !params.without_sound() )
|
||||||
{
|
{
|
||||||
safe_module_initialize<audio_engine>(
|
safe_module_initialize<audio>(
|
||||||
the<debug>());
|
the<debug>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user