mirror of
https://github.com/AxioDL/boo.git
synced 2025-07-04 12:15:52 +00:00
ALSA and AQS use floating-point audio output now
This commit is contained in:
parent
f4dc3626e5
commit
befa1a11a2
@ -135,7 +135,13 @@ struct ALSAAudioVoiceEngine : BaseAudioVoiceEngine
|
|||||||
snd_pcm_hw_params_any(m_pcm, hwParams);
|
snd_pcm_hw_params_any(m_pcm, hwParams);
|
||||||
|
|
||||||
snd_pcm_format_t bestFmt;
|
snd_pcm_format_t bestFmt;
|
||||||
if (!snd_pcm_hw_params_test_format(m_pcm, hwParams, SND_PCM_FORMAT_S32))
|
if (!snd_pcm_hw_params_test_format(m_pcm, hwParams, SND_PCM_FORMAT_FLOAT))
|
||||||
|
{
|
||||||
|
bestFmt = SND_PCM_FORMAT_FLOAT;
|
||||||
|
m_mixInfo.m_sampleFormat = SOXR_FLOAT32_I;
|
||||||
|
m_mixInfo.m_bitsPerSample = 32;
|
||||||
|
}
|
||||||
|
else if (!snd_pcm_hw_params_test_format(m_pcm, hwParams, SND_PCM_FORMAT_S32))
|
||||||
{
|
{
|
||||||
bestFmt = SND_PCM_FORMAT_S32;
|
bestFmt = SND_PCM_FORMAT_S32;
|
||||||
m_mixInfo.m_sampleFormat = SOXR_INT32_I;
|
m_mixInfo.m_sampleFormat = SOXR_INT32_I;
|
||||||
|
@ -56,7 +56,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||||||
engine->m_engineEnterCv.wait(lk);
|
engine->m_engineEnterCv.wait(lk);
|
||||||
engine->m_cbWaiting = false;
|
engine->m_cbWaiting = false;
|
||||||
|
|
||||||
engine->_pumpAndMixVoices(engine->m_mixInfo.m_periodFrames, reinterpret_cast<int32_t*>(inBuffer->mAudioData));
|
engine->_pumpAndMixVoices(engine->m_mixInfo.m_periodFrames, reinterpret_cast<float*>(inBuffer->mAudioData));
|
||||||
inBuffer->mAudioDataByteSize = engine->m_frameBytes;
|
inBuffer->mAudioDataByteSize = engine->m_frameBytes;
|
||||||
AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, nullptr);
|
AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, nullptr);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||||||
AudioStreamBasicDescription desc = {};
|
AudioStreamBasicDescription desc = {};
|
||||||
desc.mSampleRate = 96000;
|
desc.mSampleRate = 96000;
|
||||||
desc.mFormatID = kAudioFormatLinearPCM;
|
desc.mFormatID = kAudioFormatLinearPCM;
|
||||||
desc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
|
desc.mFormatFlags = kLinearPCMFormatFlagIsFloat;
|
||||||
desc.mBytesPerPacket = chCount * 4;
|
desc.mBytesPerPacket = chCount * 4;
|
||||||
desc.mFramesPerPacket = 1;
|
desc.mFramesPerPacket = 1;
|
||||||
desc.mBytesPerFrame = chCount * 4;
|
desc.mBytesPerFrame = chCount * 4;
|
||||||
@ -545,7 +545,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||||||
AudioStreamBasicDescription desc = {};
|
AudioStreamBasicDescription desc = {};
|
||||||
desc.mSampleRate = 96000;
|
desc.mSampleRate = 96000;
|
||||||
desc.mFormatID = kAudioFormatLinearPCM;
|
desc.mFormatID = kAudioFormatLinearPCM;
|
||||||
desc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
|
desc.mFormatFlags = kLinearPCMFormatFlagIsFloat;
|
||||||
desc.mBytesPerPacket = chCount * 4;
|
desc.mBytesPerPacket = chCount * 4;
|
||||||
desc.mFramesPerPacket = 1;
|
desc.mFramesPerPacket = 1;
|
||||||
desc.mBytesPerFrame = chCount * 4;
|
desc.mBytesPerFrame = chCount * 4;
|
||||||
@ -579,7 +579,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mixInfo.m_sampleRate = actualSampleRate;
|
m_mixInfo.m_sampleRate = actualSampleRate;
|
||||||
m_mixInfo.m_sampleFormat = SOXR_INT32_I;
|
m_mixInfo.m_sampleFormat = SOXR_FLOAT32_I;
|
||||||
m_mixInfo.m_bitsPerSample = 32;
|
m_mixInfo.m_bitsPerSample = 32;
|
||||||
m_5msFrames = actualSampleRate * 5 / 1000;
|
m_5msFrames = actualSampleRate * 5 / 1000;
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||||||
|
|
||||||
for (unsigned i=0 ; i<3 ; ++i)
|
for (unsigned i=0 ; i<3 ; ++i)
|
||||||
{
|
{
|
||||||
_pumpAndMixVoices(m_mixInfo.m_periodFrames, reinterpret_cast<int32_t*>(m_buffers[i]->mAudioData));
|
_pumpAndMixVoices(m_mixInfo.m_periodFrames, reinterpret_cast<float*>(m_buffers[i]->mAudioData));
|
||||||
m_buffers[i]->mAudioDataByteSize = m_frameBytes;
|
m_buffers[i]->mAudioDataByteSize = m_frameBytes;
|
||||||
AudioQueueEnqueueBuffer(m_queue, m_buffers[i], 0, nullptr);
|
AudioQueueEnqueueBuffer(m_queue, m_buffers[i], 0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ void AudioVoiceMono::_resetSampleRate(double sampleRate)
|
|||||||
{
|
{
|
||||||
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
||||||
if (scratchFlt.size() < m_root.m_5msFrames)
|
if (scratchFlt.size() < m_root.m_5msFrames)
|
||||||
scratchFlt.resize(m_root.m_5msFrames);
|
scratchFlt.resize(m_root.m_5msFrames + 2);
|
||||||
soxr_output(m_src, scratchFlt.data(), m_root.m_5msFrames);
|
soxr_output(m_src, scratchFlt.data(), m_root.m_5msFrames);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ size_t AudioVoiceMono::pumpAndMix(const AudioVoiceEngineMixInfo& mixInfo,
|
|||||||
{
|
{
|
||||||
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
||||||
if (scratchFlt.size() < frames)
|
if (scratchFlt.size() < frames)
|
||||||
scratchFlt.resize(frames);
|
scratchFlt.resize(frames + 2);
|
||||||
|
|
||||||
size_t oDone = soxr_output(m_src, scratchFlt.data(), frames);
|
size_t oDone = soxr_output(m_src, scratchFlt.data(), frames);
|
||||||
_midUpdate();
|
_midUpdate();
|
||||||
@ -316,7 +316,7 @@ void AudioVoiceStereo::_resetSampleRate(double sampleRate)
|
|||||||
{
|
{
|
||||||
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
||||||
if (scratchFlt.size() < m_root.m_5msFrames * 2)
|
if (scratchFlt.size() < m_root.m_5msFrames * 2)
|
||||||
scratchFlt.resize(m_root.m_5msFrames * 2);
|
scratchFlt.resize(m_root.m_5msFrames * 2 + 2);
|
||||||
soxr_output(m_src, scratchFlt.data(), m_root.m_5msFrames);
|
soxr_output(m_src, scratchFlt.data(), m_root.m_5msFrames);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ size_t AudioVoiceStereo::pumpAndMix(const AudioVoiceEngineMixInfo& mixInfo,
|
|||||||
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
std::vector<float>& scratchFlt = m_root.m_scratchFlt;
|
||||||
size_t samples = frames * 2;
|
size_t samples = frames * 2;
|
||||||
if (scratchFlt.size() < samples)
|
if (scratchFlt.size() < samples)
|
||||||
scratchFlt.resize(samples);
|
scratchFlt.resize(samples + 4);
|
||||||
|
|
||||||
size_t oDone = soxr_output(m_src, scratchFlt.data(), frames);
|
size_t oDone = soxr_output(m_src, scratchFlt.data(), frames);
|
||||||
_midUpdate();
|
_midUpdate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user