35 lines
1019 B
C++
35 lines
1019 B
C++
#pragma once
|
|
|
|
#include "FluidSim/AudioOutputStream.hpp"
|
|
|
|
namespace fluidsim::port {
|
|
|
|
// Lifecycle wrapper matching the C# Audio.SoundEngine. The output stream owns
|
|
// the device callback, while this class gives the application one explicit
|
|
// start/stop and playback-control surface.
|
|
class SoundEngine {
|
|
public:
|
|
explicit SoundEngine(SimulationRingBuffer& source_buffer);
|
|
~SoundEngine();
|
|
|
|
SoundEngine(const SoundEngine&) = delete;
|
|
SoundEngine& operator=(const SoundEngine&) = delete;
|
|
|
|
void start();
|
|
void stop();
|
|
void set_speed(double speed);
|
|
double speed() const;
|
|
void set_volume(float volume);
|
|
float volume() const;
|
|
void set_auto_gain(bool enabled) { stream_.set_auto_gain(enabled); }
|
|
bool auto_gain() const { return stream_.auto_gain(); }
|
|
std::uint64_t underrun_blocks() const { return stream_.underrun_blocks(); }
|
|
bool is_playing() const { return is_playing_; }
|
|
|
|
private:
|
|
AudioOutputStream stream_;
|
|
bool is_playing_{};
|
|
};
|
|
|
|
} // namespace fluidsim::port
|