Skip to content

Commit

Permalink
* outputting empty son-array, if the requested channel cannot be gene…
Browse files Browse the repository at this point in the history
…rated (because there are not enough channels). This is done, so that client-side javascript code does not break.
  • Loading branch information
beschulz committed Feb 25, 2015
1 parent a4303ef commit 1c8e6a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/test1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"_generator":"wav2json version 0.4 on Darwin (http://goo.gl/af7wg)",
"right":[],
"mid":[],
"side":[],
"min":[],
"max":[],
"left": [0,0.5,0.87,1,0.87,0.5,0,0.5,0.87,0,0.87,0.5],
"duration":0.000250
}
3 changes: 2 additions & 1 deletion src/wav2json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void compute_waveform(

// filter out channels, that require more channels than the wav file has
channels.erase(
std::remove_if(channels.begin(), channels.end(), [&wav](Options::Channel channel){
std::remove_if(channels.begin(), channels.end(), [&wav, &output_stream](Options::Channel channel){
if ((channel == Options::MID ||
channel == Options::SIDE ||
channel == Options::RIGHT||
Expand All @@ -122,6 +122,7 @@ void compute_waveform(
wav.channels() == 1
)
{
output_stream << " \"" << channel << "\":[]," << endl; // output empty array, so that existing client-code does not break
std::cerr << "Warning: your trying to generate output for channel '" << channel << "', but the input has only one channel. removing requested channel." << std::endl;
return true;
}
Expand Down

0 comments on commit 1c8e6a8

Please sign in to comment.