1#ifndef NANOMMO_CLIENT_AUDIO_H_
2#define NANOMMO_CLIENT_AUDIO_H_
15#include "absl/status/statusor.h"
27std::optional<std::pair<Samples, Samples>>
LoadStereo(
const std::string& path);
30std::optional<Samples>
LoadMono(
const std::string& path);
45 static absl::StatusOr<std::unique_ptr<AudioDevice>>
Create();
60 static absl::StatusOr<std::unique_ptr<Track>>
Load(
const AudioDevice& device,
61 const std::string& path);
83 explicit Track(Music music) : music_(music) {}
93 const Samples& samples,
int voices);
102 void Play(
float volume,
float pan,
float pitch);
105 explicit Clip(Sound sound) : sound_(sound) {}
109 std::vector<Sound> voices_;
110 std::size_t next_ = 0;
126 const std::function<
void(std::span<float>, std::span<float>)>& fill);
132 explicit Stream(AudioStream stream) : stream_(stream) {}
135 std::vector<float> left_;
136 std::vector<float> right_;
137 std::vector<float> both_;
static absl::StatusOr< std::unique_ptr< AudioDevice > > Create()
AudioDevice & operator=(const AudioDevice &)=delete
AudioDevice(const AudioDevice &)=delete
static std::unique_ptr< Clip > Load(const AudioDevice &device, const Samples &samples, int voices)
void Play(float volume, float pan, float pitch)
Clip(const Clip &)=delete
Clip & operator=(const Clip &)=delete
Stream(const Stream &)=delete
Stream & operator=(const Stream &)=delete
static std::unique_ptr< Stream > Open(const AudioDevice &device)
void SetVolume(float volume)
From nothing to full.
void Feed(const std::function< void(std::span< float >, std::span< float >)> &fill)
static absl::StatusOr< std::unique_ptr< Track > > Load(const AudioDevice &device, const std::string &path)
Loading needs the device, so it takes one, even though it doesn't use it.
Track(const Track &)=delete
void SetVolume(float volume)
From nothing to the file's own loudness.
void Play()
From the start.
Track & operator=(const Track &)=delete
std::vector< float > Samples
One channel of sound, at kRate.
std::optional< std::pair< Samples, Samples > > LoadStereo(const std::string &path)
void UseRecordings(Ambience &ambience)
std::string SoundsFolder()
Where the recorded sounds are, beside the music.
std::optional< Samples > LoadMono(const std::string &path)
The same, with its two channels as one.
std::string MusicFolder()