mirror of
https://github.com/dwhinham/mt32-pi.git
synced 2026-10-26 22:11:05 +00:00
1 parent
3202586c61
commit
b0db927221
4 files changed
+31
-4
No files matched your search
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Ability to reverse global left and right audio channels (new configuration file option) to work around broken hardware (issue #307).
|
||||
|
||||
### Changed
|
||||
|
||||
- Update to libmt32emu v2.7.0.
|
||||
|
||||
@@ -53,6 +53,7 @@ BEGIN_SECTION(audio)
|
||||
CFG(output_device, TAudioOutputDevice, AudioOutputDevice, TAudioOutputDevice::PWM )
|
||||
CFG(sample_rate, int, AudioSampleRate, 48000 )
|
||||
CFG(chunk_size, int, AudioChunkSize, 256 )
|
||||
CFG(reversed_stereo, bool, AudioReversedStereo, false )
|
||||
END_SECTION
|
||||
|
||||
BEGIN_SECTION(control)
|
||||
|
||||
@@ -147,6 +147,13 @@ sample_rate = 48000
|
||||
# Values: 2-2048 (256*)
|
||||
chunk_size = 256
|
||||
|
||||
# Set whether the stereo channels should be swapped or not.
|
||||
#
|
||||
# Use this option to work around wrongly-wired audio hardware.
|
||||
#
|
||||
# Values: on, off*
|
||||
reversed_stereo = off
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Control options
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
+19
-4
@@ -562,6 +562,7 @@ void CMT32Pi::AudioTask()
|
||||
|
||||
// Circle's "fast path" for I2S 24-bit really expects 32-bit samples
|
||||
const bool bI2S = m_pConfig->AudioOutputDevice == CConfig::TAudioOutputDevice::I2S;
|
||||
const bool bReversedStereo = m_pConfig->AudioReversedStereo;
|
||||
const u8 nBytesPerSample = bI2S ? sizeof(s32) : (sizeof(s8) * 3);
|
||||
const u8 nBytesPerFrame = 2 * nBytesPerSample;
|
||||
|
||||
@@ -578,11 +579,25 @@ void CMT32Pi::AudioTask()
|
||||
|
||||
m_pCurrentSynth->Render(FloatBuffer, nFrames);
|
||||
|
||||
// Convert to signed 24-bit integers
|
||||
for (size_t i = 0; i < nFrames * nChannels; ++i)
|
||||
if (bReversedStereo)
|
||||
{
|
||||
s32* const pSample = reinterpret_cast<s32*>(IntBuffer + i * nBytesPerSample);
|
||||
*pSample = FloatBuffer[i] * Sample24BitMax;
|
||||
// Convert to signed 24-bit integers with channel swap
|
||||
for (size_t i = 0; i < nFrames * nChannels; i += nChannels)
|
||||
{
|
||||
s32* const pLeftSample = reinterpret_cast<s32*>(IntBuffer + i * nBytesPerSample);
|
||||
s32* const pRightSample = reinterpret_cast<s32*>(IntBuffer + (i + 1) * nBytesPerSample);
|
||||
*pLeftSample = FloatBuffer[i + 1] * Sample24BitMax;
|
||||
*pRightSample = FloatBuffer[i] * Sample24BitMax;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert to signed 24-bit integers
|
||||
for (size_t i = 0; i < nFrames * nChannels; ++i)
|
||||
{
|
||||
s32* const pSample = reinterpret_cast<s32*>(IntBuffer + i * nBytesPerSample);
|
||||
*pSample = FloatBuffer[i] * Sample24BitMax;
|
||||
}
|
||||
}
|
||||
|
||||
const int nResult = m_pSound->Write(IntBuffer, nWriteBytes);
|
||||
|
||||
Reference in new issue
Block a user