Lifecycle
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <sonus/config.hpp>
|
||||
#include <sonus/detail/errors.hpp>
|
||||
#include <sonus/engine.hpp>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <modulus/types.hpp>
|
||||
|
||||
namespace sonus {
|
||||
|
||||
enum class performance_profile : std::uint8_t {
|
||||
LOW_LATENCY,
|
||||
CONSERVATIVE,
|
||||
};
|
||||
|
||||
struct audio_config {
|
||||
std::uint32_t sample_rate{48000};
|
||||
std::uint32_t channels{2};
|
||||
std::float32_t master_volume{0.70F};
|
||||
std::bool_t no_device{false};
|
||||
std::string playback_device_name{};
|
||||
std::uint32_t period_size_frames{0};
|
||||
std::uint32_t period_size_milliseconds{0};
|
||||
std::uint32_t period_count{0};
|
||||
sonus::performance_profile performance{sonus::performance_profile::LOW_LATENCY};
|
||||
};
|
||||
|
||||
struct metronome_config {
|
||||
std::uint32_t bpm{120};
|
||||
std::uint32_t beats_per_bar{4};
|
||||
std::float32_t volume{0.45F};
|
||||
std::float32_t beat_frequency_hz{1320.0F};
|
||||
std::float32_t downbeat_frequency_hz{1760.0F};
|
||||
std::chrono::milliseconds click_duration{35};
|
||||
};
|
||||
|
||||
struct playback_options {
|
||||
std::bool_t loop{false};
|
||||
std::float32_t volume{1.0F};
|
||||
std::bool_t stream{true};
|
||||
};
|
||||
|
||||
using sound_handle = std::uint64_t;
|
||||
|
||||
}
|
||||
@@ -1,40 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
|
||||
#include <modulus.hpp>
|
||||
#include <modulus/types.hpp>
|
||||
#include <sonus/config.hpp>
|
||||
|
||||
namespace sonus {
|
||||
|
||||
struct audio_config {
|
||||
std::uint32_t sample_rate{48000};
|
||||
std::uint32_t channels{2};
|
||||
std::float32_t master_volume{0.70F};
|
||||
std::bool_t no_device{false};
|
||||
};
|
||||
|
||||
struct metronome_config {
|
||||
std::uint32_t bpm{120};
|
||||
std::uint32_t beats_per_bar{4};
|
||||
std::float32_t volume{0.45F};
|
||||
std::float32_t beat_frequency_hz{1320.0F};
|
||||
std::float32_t downbeat_frequency_hz{1760.0F};
|
||||
std::chrono::milliseconds click_duration{35};
|
||||
};
|
||||
|
||||
struct playback_options {
|
||||
std::bool_t loop{false};
|
||||
std::float32_t volume{1.0F};
|
||||
std::bool_t stream{true};
|
||||
};
|
||||
|
||||
using sound_handle = std::uint64_t;
|
||||
|
||||
auto validate(sonus::audio_config const& config) -> std::expected<void, modulus::error>;
|
||||
auto validate(sonus::metronome_config const& config) -> std::expected<void, modulus::error>;
|
||||
auto validate(sonus::playback_options const& options) -> std::expected<void, modulus::error>;
|
||||
@@ -59,6 +34,9 @@ public:
|
||||
auto play_file(std::filesystem::path const& path, sonus::playback_options options = {}) -> std::expected<sonus::sound_handle, modulus::error>;
|
||||
auto stop(sonus::sound_handle handle) -> std::expected<void, modulus::error>;
|
||||
auto stop_all() -> void;
|
||||
auto is_playing(sonus::sound_handle handle) -> std::expected<std::bool_t, modulus::error>;
|
||||
auto collect_finished() -> std::uint64_t;
|
||||
auto active_sound_count() -> std::uint64_t;
|
||||
|
||||
auto start_metronome(sonus::metronome_config config = {}) -> std::expected<void, modulus::error>;
|
||||
auto update_metronome(sonus::metronome_config config) -> std::expected<void, modulus::error>;
|
||||
|
||||
Reference in New Issue
Block a user