mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
added 3d audio support, updated make
This commit is contained in:
@@ -150,6 +150,20 @@ target_compile_definitions(${PROJECT_NAME}
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_SCL_SECURE_NO_WARNINGS>)
|
||||
|
||||
#
|
||||
# bass
|
||||
#
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
||||
link_directories( "sources/3rdparty/bass/ios" )
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC "bass")
|
||||
endif()
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
link_directories( "sources/3rdparty/bass/mac" )
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC "bass.dylib")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# subdirectories
|
||||
#
|
||||
|
||||
@@ -60,6 +60,12 @@ namespace e2d
|
||||
[[nodiscard]] seconds<float> position() const noexcept;
|
||||
[[nodiscard]] seconds<float> duration() const noexcept;
|
||||
|
||||
void position3d(const v3f &value) noexcept;
|
||||
[[nodiscard]] v3f position3d() const noexcept;
|
||||
|
||||
void velocity(const v3f &value) noexcept;
|
||||
[[nodiscard]] v3f velocity() const noexcept;
|
||||
|
||||
private:
|
||||
internal_state_uptr state_;
|
||||
};
|
||||
@@ -88,6 +94,15 @@ namespace e2d
|
||||
void resume() noexcept;
|
||||
void pause() noexcept;
|
||||
|
||||
// Applies changes made to the 3D system.
|
||||
void apply3d() noexcept;
|
||||
|
||||
void listener_position(const v3f &value) noexcept;
|
||||
[[nodiscard]] v3f listener_position() const noexcept;
|
||||
|
||||
void listener_velocity(const v3f &value) noexcept;
|
||||
[[nodiscard]] v3f listener_velocity() const noexcept;
|
||||
|
||||
private:
|
||||
class internal_state;
|
||||
std::unique_ptr<internal_state> state_;
|
||||
|
||||
@@ -80,6 +80,28 @@ namespace e2d
|
||||
return seconds<float>{float(BASS_ChannelBytes2Seconds(state().channel(), byte_len))};
|
||||
}
|
||||
|
||||
void sound_source::position3d(const v3f &value) noexcept {
|
||||
BASS_3DVECTOR pos = {value.x, value.y, value.z};
|
||||
BASS_ChannelGet3DPosition(state().channel(), &pos, nullptr, nullptr);
|
||||
}
|
||||
|
||||
v3f sound_source::position3d() const noexcept {
|
||||
BASS_3DVECTOR pos = {};
|
||||
BASS_ChannelSet3DPosition(state().channel(), &pos, nullptr, nullptr);
|
||||
return v3f(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
void sound_source::velocity(const v3f &value) noexcept {
|
||||
BASS_3DVECTOR vel = {value.x, value.y, value.z};
|
||||
BASS_ChannelGet3DPosition(state().channel(), nullptr, nullptr, &vel);
|
||||
}
|
||||
|
||||
v3f sound_source::velocity() const noexcept {
|
||||
BASS_3DVECTOR vel = {};
|
||||
BASS_ChannelSet3DPosition(state().channel(), nullptr, nullptr, &vel);
|
||||
return v3f(vel.x, vel.y, vel.z);
|
||||
}
|
||||
|
||||
//
|
||||
// audio_engine
|
||||
//
|
||||
@@ -153,6 +175,32 @@ namespace e2d
|
||||
if ( !BASS_Pause() )
|
||||
state_->dbg().error("AUDIO: Failed to resume audio output");
|
||||
}
|
||||
|
||||
void audio_engine::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 {
|
||||
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 {
|
||||
BASS_3DVECTOR vel = {value.x, value.y, value.z};
|
||||
BASS_Set3DPosition(nullptr, &vel, nullptr, nullptr);
|
||||
}
|
||||
|
||||
v3f audio_engine::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 {
|
||||
BASS_Apply3D();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#define E2D_AUDIO_MODE_NONE 1
|
||||
#define E2D_AUDIO_MODE_FMOD 2
|
||||
#define E2D_AUDIO_MODE_BASS 2
|
||||
#define E2D_AUDIO_MODE_BASS 3
|
||||
|
||||
#ifndef E2D_AUDIO_MODE
|
||||
# if defined(E2D_PLATFORM) && E2D_PLATFORM == E2D_PLATFORM_IOS
|
||||
|
||||
@@ -98,6 +98,22 @@ namespace e2d
|
||||
return {};
|
||||
}
|
||||
|
||||
void sound_source::position3d(const v3f &value) noexcept {
|
||||
E2D_UNUSED(value);
|
||||
}
|
||||
|
||||
v3f sound_source::position3d() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
void sound_source::velocity(const v3f &value) noexcept {
|
||||
E2D_UNUSED(value);
|
||||
}
|
||||
|
||||
v3f sound_source::velocity() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
//
|
||||
// audio_engine
|
||||
//
|
||||
@@ -141,6 +157,25 @@ namespace e2d
|
||||
|
||||
void audio_engine::pause() noexcept {
|
||||
}
|
||||
|
||||
void audio_engine::listener_position(const v3f &value) noexcept {
|
||||
E2D_UNUSED(value);
|
||||
}
|
||||
|
||||
v3f audio_engine::listener_position() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
void audio_engine::listener_velocity(const v3f &value) noexcept {
|
||||
E2D_UNUSED(value);
|
||||
}
|
||||
|
||||
v3f audio_engine::listener_velocity() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
void audio_engine::apply3d() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user