32 [[nodiscard]]
const std::string&
getName()
const {
return name; }
37 [[nodiscard]] std::string_view
getDescription()
const {
return description; }
73 return {f * softwareVolumeLeft, f * softwareVolumeRight};
107 [[nodiscard]] std::span<const float>
getLastBuffer(
unsigned channel);
120 return inputSampleRate / 7;
136 unsigned numChannels,
unsigned inputRate,
bool stereo);
166 void setInputRate(
unsigned sampleRate) { inputSampleRate = sampleRate; }
167 [[nodiscard]]
unsigned getInputRate()
const {
return inputSampleRate; }
196 EmuTime::param time) = 0;
207 static void addFill(
float*& buffer,
float value,
unsigned num);
236 [[nodiscard]]
bool mixChannels(
float* dataOut,
size_t samples);
244 const std::string name;
247 std::array<std::optional<Wav16Writer>,
MAX_CHANNELS> writer;
249 float softwareVolumeLeft = 1.0f;
250 float softwareVolumeRight = 1.0f;
251 unsigned inputSampleRate;
252 const unsigned numChannels;
253 const unsigned stereo;
254 unsigned numRecordChannels = 0;
255 std::array<int, MAX_CHANNELS> channelBalance;
256 std::array<bool, MAX_CHANNELS> channelMuted;
257 bool balanceCenter =
true;
262 struct PerChannelBuffer {
263 std::vector<float> buffer;
264 unsigned stopIdx = 0;
265 unsigned requestCounter = 0;
266 unsigned silent = 999999;
268 std::array<PerChannelBuffer, MAX_CHANNELS> channelBuffers = {};
Represents a clock with a variable frequency.
This class represents a filename.
double getEffectiveSpeed() const
SoundDevice & operator=(const SoundDevice &)=delete
std::string_view getDescription() const
Gets a description of this sound device, to be presented to the user.
virtual bool updateBuffer(size_t length, float *buffer, EmuTime::param time)=0
Generate sample data.
unsigned getNumChannels() const
How many channels does this device have?
void recordChannel(unsigned channel, const Filename &filename)
bool hasStereoChannels() const
Are the individual channels of this device stereo?
void updateStream(EmuTime::param time)
unsigned getInputRate() const
SoundDevice & operator=(SoundDevice &&)=delete
unsigned getLastBufferSize() const
AmplificationFactors getAmplificationFactor() const
const std::string & getName() const
Get the unique name that identifies this sound device.
float getNativeSampleRate() const
The samples returned by 'getLastBuffer()' have this sample rate.
static void addFill(float *&buffer, float value, unsigned num)
Adds a number of samples that all have the same value.
const DynamicClock & getHostSampleClock() const
See MSXMixer::getHostSampleClock().
SoundDevice(SoundDevice &&)=delete
void setInputRate(unsigned sampleRate)
virtual void setOutputRate(unsigned hostSampleRate, double speed)=0
When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through th...
void setSoftwareVolume(float volume, EmuTime::param time)
Change the 'software volume' of this sound device.
bool mixChannels(float *dataOut, size_t samples)
Calls generateChannels() and combines the output to a single channel.
static constexpr unsigned MAX_CHANNELS
void unregisterSound()
Unregisters this sound device with the Mixer.
unsigned getLastMonoBufferSize() const
getLastBuffer() with return buffers containing this many samples.
SoundDevice(const SoundDevice &)=delete
bool isStereo() const
Is the full output of this device stereo?
virtual void generateChannels(std::span< float * > buffers, unsigned num)=0
Abstract method to generate the actual sound data.
void registerSound(const DeviceConfig &config)
Registers this sound device with the Mixer.
std::span< const float > getLastBuffer(unsigned channel)
Query the last generated audio signal for a specific channel.
void muteChannel(unsigned channel, bool muted)
virtual float getAmplificationFactorImpl() const
Get amplification/attenuation factor for this device.
This file implemented 3 utility functions:
Gets this device its 'amplification factor'.