Implement 24 bit support for WAV export (#3021)
Add a new value of "24 Bit Float" to the "Depth" combo box in the project export dialog. Add a new enum value to ProjectRenderer::Depth and extend the evaluation of the different enum values in ProjectRenderer. Add the new case of a depth of 24 to AudioFileWave and remove some repetition with regards to SF_FORMAT_WAV in the code. It's only set once now and then the depth is "added" in a switch statement.
This commit is contained in:
@@ -44,6 +44,7 @@ public:
|
||||
enum Depths
|
||||
{
|
||||
Depth_16Bit,
|
||||
Depth_24Bit,
|
||||
Depth_32Bit,
|
||||
NumDepths
|
||||
} ;
|
||||
|
||||
@@ -76,14 +76,30 @@ ProjectRenderer::ProjectRenderer( const Mixer::qualitySettings & _qs,
|
||||
return;
|
||||
}
|
||||
|
||||
bool success_ful = false;
|
||||
int depth;
|
||||
switch (_os.depth)
|
||||
{
|
||||
case Depth_16Bit:
|
||||
depth = 16;
|
||||
break;
|
||||
case Depth_24Bit:
|
||||
depth = 24;
|
||||
break;
|
||||
case Depth_32Bit:
|
||||
depth = 32;
|
||||
break;
|
||||
default:
|
||||
// If this line is reached the enum has been extended without taking care here
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
bool successful = false;
|
||||
m_fileDev = fileEncodeDevices[_file_format].m_getDevInst(
|
||||
_os.samplerate, DEFAULT_CHANNELS, success_ful,
|
||||
_os.samplerate, DEFAULT_CHANNELS, successful,
|
||||
_out_file, _os.vbr,
|
||||
_os.bitrate, _os.bitrate - 64, _os.bitrate + 64,
|
||||
_os.depth == Depth_32Bit ? 32 : 16,
|
||||
Engine::mixer() );
|
||||
if( success_ful == false )
|
||||
depth, Engine::mixer() );
|
||||
if( !successful )
|
||||
{
|
||||
delete m_fileDev;
|
||||
m_fileDev = NULL;
|
||||
|
||||
@@ -64,11 +64,20 @@ bool AudioFileWave::startEncoding()
|
||||
m_si.sections = 1;
|
||||
m_si.seekable = 0;
|
||||
|
||||
m_si.format = SF_FORMAT_WAV;
|
||||
|
||||
switch( depth() )
|
||||
{
|
||||
case 32: m_si.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; break;
|
||||
case 16:
|
||||
default: m_si.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; break;
|
||||
case 32:
|
||||
m_si.format |= SF_FORMAT_FLOAT;
|
||||
break;
|
||||
case 24:
|
||||
m_si.format |= SF_FORMAT_PCM_24;
|
||||
break;
|
||||
case 16:
|
||||
default:
|
||||
m_si.format |= SF_FORMAT_PCM_16;
|
||||
break;
|
||||
}
|
||||
m_sf = sf_open(
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
@@ -88,7 +97,7 @@ void AudioFileWave::writeBuffer( const surroundSampleFrame * _ab,
|
||||
const fpp_t _frames,
|
||||
const float _master_gain )
|
||||
{
|
||||
if( depth() == 32 )
|
||||
if( depth() == 32 || depth() == 24 )
|
||||
{
|
||||
float * buf = new float[_frames*channels()];
|
||||
for( fpp_t frame = 0; frame < _frames; ++frame )
|
||||
|
||||
@@ -86,16 +86,7 @@
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@@ -148,16 +139,7 @@
|
||||
<item>
|
||||
<widget class="QWidget" name="depthWidget" native="true">
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@@ -174,6 +156,11 @@
|
||||
<string>16 Bit Integer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>24 Bit Float</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>32 Bit Float</string>
|
||||
|
||||
Reference in New Issue
Block a user