Skip to content

Commit

Permalink
Add global dither option
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertymodo committed Mar 14, 2017
1 parent d7b91ae commit 5080661
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions msupcm++/GlobalConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ std::string GlobalConfig::m_artist = "";
std::string GlobalConfig::m_url = "";
std::string GlobalConfig::m_output_prefix = "";
double GlobalConfig::m_normalization = 0.0;
bool GlobalConfig::m_dither = true;
unsigned int GlobalConfig::m_verbosity = 1;
bool GlobalConfig::m_keep_temps = false;

Expand Down Expand Up @@ -47,6 +48,12 @@ double& GlobalConfig::normalization()
}


bool& GlobalConfig::dither()
{
return m_dither;
}


unsigned int& GlobalConfig::verbosity()
{
return m_verbosity;
Expand Down
2 changes: 2 additions & 0 deletions msupcm++/GlobalConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace msu
static std::string& url();
static std::string& output_prefix();
static double& normalization();
static bool& dither();
static unsigned int& verbosity();
static bool& keep_temps();

Expand All @@ -22,6 +23,7 @@ namespace msu
static std::string m_url;
static std::string m_output_prefix;
static double m_normalization;
static bool m_dither;
static unsigned int m_verbosity;
static bool m_keep_temps;
} config;
Expand Down
10 changes: 10 additions & 0 deletions msupcm++/SoxWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ bool SoxWrapper::normalize(double level)

bool SoxWrapper::finalize()
{
if (GlobalConfig::dither())
{
char* dither_args[1];

dither_args[0] = new char[3]{ '-','s','\0' };
addEffect("dither", 1, (char**)dither_args);

delete dither_args[0];
}

addOutput(m_output);

sox_format_handler_t const * handler =
Expand Down
6 changes: 5 additions & 1 deletion msupcm++/TrackParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace msu {
{ "pad_start", a.padStart() },
{ "pad_end", a.padEnd() },
{ "tempo", a.tempo() },
{ "normalization", a.normalization() }
{ "normalization", a.normalization() },
};
}

Expand Down Expand Up @@ -83,6 +83,7 @@ namespace msu {
{ "url", config.url() },
{ "output_prefix", config.output_prefix() },
{ "normalization", config.normalization() },
{ "dither", config.dither() },
{ "verbosity", config.verbosity() },
{ "keep_temps", config.keep_temps() }
};
Expand Down Expand Up @@ -224,6 +225,9 @@ namespace msu {
if (j.find("normalization") != j.end())
config.normalization() = j["normalization"].get<int>();

if (j.find("dither") != j.end())
config.dither() = j["dither"].get<bool>();

if (j.find("verbosity") != j.end())
config.verbosity() = j["verbosity"].get<unsigned int>();

Expand Down

0 comments on commit 5080661

Please sign in to comment.