stuff-from-scratch/src/audio/AudioDevice.cpp

72 lines
1 KiB
C++
Raw Normal View History

2020-05-02 07:31:03 +00:00
#include "AudioDevice.h"
AudioDevice::AudioDevice()
2021-03-29 20:31:24 +00:00
: mName("plughw:1,0"),
mSampleRate(44100),
mNumChannels(2),
mPeriod(2),
mBufferSize()
2020-05-02 07:31:03 +00:00
{
}
AudioDevice::~AudioDevice()
{
}
2021-03-29 20:31:24 +00:00
std::unique_ptr<AudioDevice> AudioDevice::Create()
2020-05-02 07:31:03 +00:00
{
2021-03-29 20:31:24 +00:00
return std::make_unique<AudioDevice>();
2020-05-02 07:31:03 +00:00
}
void AudioDevice::SetNumChannels(unsigned numChannels)
{
2021-03-29 20:31:24 +00:00
mNumChannels = numChannels;
2020-05-02 07:31:03 +00:00
}
void AudioDevice::SetPeriod(unsigned period)
{
2021-03-29 20:31:24 +00:00
mPeriod = period;
2020-05-02 07:31:03 +00:00
}
void AudioDevice::SetBufferSize(std::size_t bufferSize)
{
2021-03-29 20:31:24 +00:00
mBufferSize = bufferSize;
2020-05-02 07:31:03 +00:00
}
2021-03-29 20:31:24 +00:00
unsigned AudioDevice::GetNumChannels() const
2020-05-02 07:31:03 +00:00
{
2021-03-29 20:31:24 +00:00
return mNumChannels;
2020-05-02 07:31:03 +00:00
}
2021-03-29 20:31:24 +00:00
unsigned AudioDevice::GetPeriod() const
2020-05-02 07:31:03 +00:00
{
2021-03-29 20:31:24 +00:00
return mPeriod;
2020-05-02 07:31:03 +00:00
}
2021-03-29 20:31:24 +00:00
std::size_t AudioDevice::GetBufferSize() const
2020-05-02 07:31:03 +00:00
{
2021-03-29 20:31:24 +00:00
return mBufferSize;
2020-05-02 07:31:03 +00:00
}
void AudioDevice::SetSampleRate(unsigned rate)
{
2021-03-29 20:31:24 +00:00
mSampleRate = rate;
2020-05-02 07:31:03 +00:00
}
2021-03-29 20:31:24 +00:00
unsigned AudioDevice::GetSampleRate() const
2020-05-02 07:31:03 +00:00
{
2021-03-29 20:31:24 +00:00
return mSampleRate;
2020-05-02 07:31:03 +00:00
}
void AudioDevice::SetName(const std::string& name)
{
2021-03-29 20:31:24 +00:00
mName = name;
2020-05-02 07:31:03 +00:00
}
2021-03-29 20:31:24 +00:00
std::string AudioDevice::GetName() const
2020-05-02 07:31:03 +00:00
{
2021-03-29 20:31:24 +00:00
return mName;
2020-05-02 07:31:03 +00:00
}