Files
FluidSimCpp/include/FluidSim/SoundEngine.hpp

33 lines
887 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;
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