Skip to content

Commit

Permalink
Implement 24 bit support for WAV export (#3021)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelgregorius committed Apr 28, 2017
1 parent cea7d7d commit b1df8fd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
1 change: 1 addition & 0 deletions include/ProjectRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ProjectRenderer : public QThread
enum Depths
{
Depth_16Bit,
Depth_24Bit,
Depth_32Bit,
NumDepths
} ;
Expand Down
26 changes: 21 additions & 5 deletions src/core/ProjectRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 13 additions & 4 deletions src/core/audio/AudioFileWave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 )
Expand Down
27 changes: 7 additions & 20 deletions src/gui/dialogs/export_project.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down

0 comments on commit b1df8fd

Please sign in to comment.