Skip to content

Commit 567082d

Browse files
committed
Renamed variable for consistency
1 parent 30bec8d commit 567082d

File tree

4 files changed

+81
-81
lines changed

4 files changed

+81
-81
lines changed

src/Options.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Options::Options() :
7070
auto_amplitude_scale_(false),
7171
amplitude_scale_(1.0),
7272
png_compression_level_(-1), // default
73-
raw_samplerate_(0),
73+
raw_sample_rate_(0),
7474
raw_channels_(0)
7575
{
7676
}
@@ -253,7 +253,7 @@ bool Options::parseCommandLine(int argc, const char* const* argv)
253253
"PNG compression level: 0 (none) to 9 (best), or -1 (default)"
254254
)(
255255
"raw-samplerate",
256-
po::value<int>(&raw_samplerate_),
256+
po::value<int>(&raw_sample_rate_),
257257
"sample rate for raw audio input (Hz)"
258258
)(
259259
"raw-channels",
@@ -311,9 +311,9 @@ bool Options::parseCommandLine(int argc, const char* const* argv)
311311
has_input_format_ = hasOptionValue(variables_map, "input-format");
312312
has_output_format_ = hasOptionValue(variables_map, "output-format");
313313

314-
bool has_raw_samplerate = hasOptionValue(variables_map, "raw-samplerate");
315-
bool has_raw_channels = hasOptionValue(variables_map, "raw-channels");
316-
bool has_raw_format = hasOptionValue(variables_map, "raw-format");
314+
bool has_raw_sample_rate = hasOptionValue(variables_map, "raw-samplerate");
315+
bool has_raw_channels = hasOptionValue(variables_map, "raw-channels");
316+
bool has_raw_format = hasOptionValue(variables_map, "raw-format");
317317

318318
if (input_filename_.empty() && !has_input_format_) {
319319
reportError("Must specify either input filename or input format");
@@ -347,7 +347,7 @@ bool Options::parseCommandLine(int argc, const char* const* argv)
347347
}
348348

349349
if (input_format_ == FileFormat::Raw) {
350-
if (!has_raw_samplerate) {
350+
if (!has_raw_sample_rate) {
351351
reportError("Missing --raw-samplerate option");
352352
return false;
353353
}

src/Options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Options
111111
int getBarGap() const { return bar_gap_; }
112112
const std::string& getBarStyle() const { return bar_style_; }
113113

114-
int getRawAudioSampleRate() const { return raw_samplerate_; }
114+
int getRawAudioSampleRate() const { return raw_sample_rate_; }
115115
int getRawAudioChannels() const { return raw_channels_; }
116116
const std::string& getRawAudioFormat() const { return raw_format_; }
117117

@@ -195,7 +195,7 @@ class Options
195195

196196
int png_compression_level_;
197197

198-
int raw_samplerate_;
198+
int raw_sample_rate_;
199199
int raw_channels_;
200200
std::string raw_format_;
201201
};

src/SndFileAudioFileReader.cpp

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,77 @@ SndFileAudioFileReader::~SndFileAudioFileReader()
6363

6464
//------------------------------------------------------------------------------
6565

66+
void SndFileAudioFileReader::configure(int channels, int sample_rate, const std::string& format)
67+
{
68+
if (channels <= 0) {
69+
throwError("Invalid number of input channels: must be greater than zero");
70+
}
71+
72+
if (sample_rate <= 0) {
73+
throwError("Invalid input sample rate: must be greater than zero");
74+
}
75+
76+
info_.seekable = 0;
77+
info_.frames = 0;
78+
info_.sections = 0;
79+
80+
info_.channels = channels;
81+
info_.format = SF_FORMAT_RAW;
82+
info_.samplerate = sample_rate;
83+
84+
if (format == "s8") {
85+
info_.format |= SF_FORMAT_PCM_S8;
86+
}
87+
else if (format == "u8") {
88+
info_.format |= SF_FORMAT_PCM_U8;
89+
}
90+
else if (format == "s16le") {
91+
info_.format |= SF_FORMAT_PCM_16;
92+
info_.format |= SF_ENDIAN_LITTLE;
93+
}
94+
else if (format == "s16be") {
95+
info_.format |= SF_FORMAT_PCM_16;
96+
info_.format |= SF_ENDIAN_BIG;
97+
}
98+
else if (format == "s24le") {
99+
info_.format |= SF_FORMAT_PCM_24;
100+
info_.format |= SF_ENDIAN_LITTLE;
101+
}
102+
else if (format == "s24be") {
103+
info_.format |= SF_FORMAT_PCM_24;
104+
info_.format |= SF_ENDIAN_BIG;
105+
}
106+
else if (format == "s32le") {
107+
info_.format |= SF_FORMAT_PCM_32;
108+
info_.format |= SF_ENDIAN_LITTLE;
109+
}
110+
else if (format == "s32be") {
111+
info_.format |= SF_FORMAT_PCM_32;
112+
info_.format |= SF_ENDIAN_BIG;
113+
}
114+
else if (format == "f32le") {
115+
info_.format |= SF_FORMAT_FLOAT;
116+
info_.format |= SF_ENDIAN_LITTLE;
117+
}
118+
else if (format == "f32be") {
119+
info_.format |= SF_FORMAT_FLOAT;
120+
info_.format |= SF_ENDIAN_BIG;
121+
}
122+
else if (format == "f64le") {
123+
info_.format |= SF_FORMAT_DOUBLE;
124+
info_.format |= SF_ENDIAN_LITTLE;
125+
}
126+
else if (format == "f64be") {
127+
info_.format |= SF_FORMAT_DOUBLE;
128+
info_.format |= SF_ENDIAN_BIG;
129+
}
130+
else {
131+
throwError("Unsupported format: %1%", format);
132+
}
133+
}
134+
135+
//------------------------------------------------------------------------------
136+
66137
bool SndFileAudioFileReader::open(const char* input_filename, bool show_info)
67138
{
68139
assert(input_file_ == nullptr);
@@ -188,74 +259,3 @@ bool SndFileAudioFileReader::run(AudioProcessor& processor)
188259

189260
return success;
190261
}
191-
192-
//------------------------------------------------------------------------------
193-
194-
void SndFileAudioFileReader::configure(int channels, int samplerate, const std::string& format)
195-
{
196-
if (channels <= 0) {
197-
throwError("Invalid number of input channels: must be greater than zero");
198-
}
199-
200-
if (samplerate <= 0) {
201-
throwError("Invalid input sample rate: must be greater than zero");
202-
}
203-
204-
info_.seekable = 0;
205-
info_.frames = 0;
206-
info_.sections = 0;
207-
208-
info_.channels = channels;
209-
info_.format = SF_FORMAT_RAW;
210-
info_.samplerate = samplerate;
211-
212-
if (format == "s8") {
213-
info_.format |= SF_FORMAT_PCM_S8;
214-
}
215-
else if (format == "u8") {
216-
info_.format |= SF_FORMAT_PCM_U8;
217-
}
218-
else if (format == "s16le") {
219-
info_.format |= SF_FORMAT_PCM_16;
220-
info_.format |= SF_ENDIAN_LITTLE;
221-
}
222-
else if (format == "s16be") {
223-
info_.format |= SF_FORMAT_PCM_16;
224-
info_.format |= SF_ENDIAN_BIG;
225-
}
226-
else if (format == "s24le") {
227-
info_.format |= SF_FORMAT_PCM_24;
228-
info_.format |= SF_ENDIAN_LITTLE;
229-
}
230-
else if (format == "s24be") {
231-
info_.format |= SF_FORMAT_PCM_24;
232-
info_.format |= SF_ENDIAN_BIG;
233-
}
234-
else if (format == "s32le") {
235-
info_.format |= SF_FORMAT_PCM_32;
236-
info_.format |= SF_ENDIAN_LITTLE;
237-
}
238-
else if (format == "s32be") {
239-
info_.format |= SF_FORMAT_PCM_32;
240-
info_.format |= SF_ENDIAN_BIG;
241-
}
242-
else if (format == "f32le") {
243-
info_.format |= SF_FORMAT_FLOAT;
244-
info_.format |= SF_ENDIAN_LITTLE;
245-
}
246-
else if (format == "f32be") {
247-
info_.format |= SF_FORMAT_FLOAT;
248-
info_.format |= SF_ENDIAN_BIG;
249-
}
250-
else if (format == "f64le") {
251-
info_.format |= SF_FORMAT_DOUBLE;
252-
info_.format |= SF_ENDIAN_LITTLE;
253-
}
254-
else if (format == "f64be") {
255-
info_.format |= SF_FORMAT_DOUBLE;
256-
info_.format |= SF_ENDIAN_BIG;
257-
}
258-
else {
259-
throwError("Unsupported format: %1%", format);
260-
}
261-
}

src/SndFileAudioFileReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class SndFileAudioFileReader : public AudioFileReader
4444
SndFileAudioFileReader& operator=(const SndFileAudioFileReader&) = delete;
4545

4646
public:
47+
void configure(int channels, int sample_rate, const std::string& format);
48+
4749
virtual bool open(const char* input_filename, bool show_info = true);
4850

4951
virtual bool run(AudioProcessor& processor);
5052

51-
void configure(int channels, int samplerate, const std::string& format);
52-
5353
private:
5454
void close();
5555

0 commit comments

Comments
 (0)