andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | // Commandline tool to unpack audioproc debug files. |
| 12 | // |
| 13 | // The debug files are dumped as protobuf blobs. For analysis, it's necessary |
| 14 | // to unpack the file into its component parts: audio and other data. |
| 15 | |
| 16 | #include <stdio.h> |
| 17 | |
pbos@webrtc.org | 7fad4b8 | 2013-05-28 08:11:59 +0000 | [diff] [blame] | 18 | #include "gflags/gflags.h" |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 19 | #include "webrtc/audio_processing/debug.pb.h" |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 20 | #include "webrtc/base/scoped_ptr.h" |
Andrew MacDonald | cb05b72 | 2015-05-07 22:17:51 -0700 | [diff] [blame] | 21 | #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 22 | #include "webrtc/modules/audio_processing/test/test_utils.h" |
pbos@webrtc.org | 7fad4b8 | 2013-05-28 08:11:59 +0000 | [diff] [blame] | 23 | #include "webrtc/typedefs.h" |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 24 | |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 25 | // TODO(andrew): unpack more of the data. |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 26 | DEFINE_string(input_file, "input", "The name of the input stream file."); |
| 27 | DEFINE_string(output_file, "ref_out", |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 28 | "The name of the reference output stream file."); |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 29 | DEFINE_string(reverse_file, "reverse", |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 30 | "The name of the reverse input stream file."); |
| 31 | DEFINE_string(delay_file, "delay.int32", "The name of the delay file."); |
| 32 | DEFINE_string(drift_file, "drift.int32", "The name of the drift file."); |
| 33 | DEFINE_string(level_file, "level.int32", "The name of the level file."); |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 34 | DEFINE_string(keypress_file, "keypress.bool", "The name of the keypress file."); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 35 | DEFINE_string(settings_file, "settings.txt", "The name of the settings file."); |
| 36 | DEFINE_bool(full, false, |
| 37 | "Unpack the full set of files (normally not needed)."); |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 38 | DEFINE_bool(raw, false, "Write raw data instead of a WAV file."); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 39 | DEFINE_bool(text, |
| 40 | false, |
| 41 | "Write non-audio files as text files instead of binary files."); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 42 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 43 | namespace webrtc { |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 44 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 45 | using audioproc::Event; |
| 46 | using audioproc::ReverseStream; |
| 47 | using audioproc::Stream; |
| 48 | using audioproc::Init; |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 49 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 50 | void WriteData(const void* data, size_t size, FILE* file, |
| 51 | const std::string& filename) { |
| 52 | if (fwrite(data, size, 1, file) != 1) { |
| 53 | printf("Error when writing to %s\n", filename.c_str()); |
| 54 | exit(1); |
| 55 | } |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 56 | } |
| 57 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 58 | int do_main(int argc, char* argv[]) { |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 59 | std::string program_name = argv[0]; |
| 60 | std::string usage = "Commandline tool to unpack audioproc debug files.\n" |
| 61 | "Example usage:\n" + program_name + " debug_dump.pb\n"; |
| 62 | google::SetUsageMessage(usage); |
| 63 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 64 | |
| 65 | if (argc < 2) { |
| 66 | printf("%s", google::ProgramUsage()); |
| 67 | return 1; |
| 68 | } |
| 69 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 70 | FILE* debug_file = OpenFile(argv[1], "rb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 71 | |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 72 | Event event_msg; |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 73 | int frame_count = 0; |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 74 | int reverse_samples_per_channel = 0; |
| 75 | int input_samples_per_channel = 0; |
| 76 | int output_samples_per_channel = 0; |
| 77 | int num_reverse_channels = 0; |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 78 | int num_input_channels = 0; |
| 79 | int num_output_channels = 0; |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 80 | rtc::scoped_ptr<WavWriter> reverse_wav_file; |
| 81 | rtc::scoped_ptr<WavWriter> input_wav_file; |
| 82 | rtc::scoped_ptr<WavWriter> output_wav_file; |
| 83 | rtc::scoped_ptr<RawFile> reverse_raw_file; |
| 84 | rtc::scoped_ptr<RawFile> input_raw_file; |
| 85 | rtc::scoped_ptr<RawFile> output_raw_file; |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 86 | while (ReadMessageFromFile(debug_file, &event_msg)) { |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 87 | if (event_msg.type() == Event::REVERSE_STREAM) { |
| 88 | if (!event_msg.has_reverse_stream()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 89 | printf("Corrupt input file: ReverseStream missing.\n"); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 90 | return 1; |
| 91 | } |
| 92 | |
| 93 | const ReverseStream msg = event_msg.reverse_stream(); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 94 | if (msg.has_data()) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 95 | if (FLAGS_raw && !reverse_raw_file) { |
| 96 | reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".pcm")); |
| 97 | } |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 98 | // TODO(aluebs): Replace "num_reverse_channels * |
| 99 | // reverse_samples_per_channel" with "msg.data().size() / |
| 100 | // sizeof(int16_t)" and so on when this fix in audio_processing has made |
| 101 | // it into stable: https://webrtc-codereview.appspot.com/15299004/ |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 102 | WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 103 | num_reverse_channels * reverse_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 104 | reverse_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 105 | reverse_raw_file.get()); |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 106 | } else if (msg.channel_size() > 0) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 107 | if (FLAGS_raw && !reverse_raw_file) { |
| 108 | reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float")); |
| 109 | } |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 110 | rtc::scoped_ptr<const float* []> data( |
| 111 | new const float* [num_reverse_channels]); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 112 | for (int i = 0; i < num_reverse_channels; ++i) { |
| 113 | data[i] = reinterpret_cast<const float*>(msg.channel(i).data()); |
| 114 | } |
| 115 | WriteFloatData(data.get(), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 116 | reverse_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 117 | num_reverse_channels, |
| 118 | reverse_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 119 | reverse_raw_file.get()); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 120 | } |
| 121 | } else if (event_msg.type() == Event::STREAM) { |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 122 | frame_count++; |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 123 | if (!event_msg.has_stream()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 124 | printf("Corrupt input file: Stream missing.\n"); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 125 | return 1; |
| 126 | } |
| 127 | |
| 128 | const Stream msg = event_msg.stream(); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 129 | if (msg.has_input_data()) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 130 | if (FLAGS_raw && !input_raw_file) { |
| 131 | input_raw_file.reset(new RawFile(FLAGS_input_file + ".pcm")); |
| 132 | } |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 133 | WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 134 | num_input_channels * input_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 135 | input_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 136 | input_raw_file.get()); |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 137 | } else if (msg.input_channel_size() > 0) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 138 | if (FLAGS_raw && !input_raw_file) { |
| 139 | input_raw_file.reset(new RawFile(FLAGS_input_file + ".float")); |
| 140 | } |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 141 | rtc::scoped_ptr<const float* []> data( |
| 142 | new const float* [num_input_channels]); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 143 | for (int i = 0; i < num_input_channels; ++i) { |
| 144 | data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data()); |
| 145 | } |
| 146 | WriteFloatData(data.get(), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 147 | input_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 148 | num_input_channels, |
| 149 | input_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 150 | input_raw_file.get()); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 151 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 152 | |
| 153 | if (msg.has_output_data()) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 154 | if (FLAGS_raw && !output_raw_file) { |
| 155 | output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm")); |
| 156 | } |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 157 | WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 158 | num_output_channels * output_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 159 | output_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 160 | output_raw_file.get()); |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 161 | } else if (msg.output_channel_size() > 0) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 162 | if (FLAGS_raw && !output_raw_file) { |
| 163 | output_raw_file.reset(new RawFile(FLAGS_output_file + ".float")); |
| 164 | } |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 165 | rtc::scoped_ptr<const float* []> data( |
| 166 | new const float* [num_output_channels]); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 167 | for (int i = 0; i < num_output_channels; ++i) { |
| 168 | data[i] = |
| 169 | reinterpret_cast<const float*>(msg.output_channel(i).data()); |
| 170 | } |
| 171 | WriteFloatData(data.get(), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 172 | output_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 173 | num_output_channels, |
| 174 | output_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 175 | output_raw_file.get()); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | if (FLAGS_full) { |
| 179 | if (msg.has_delay()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 180 | static FILE* delay_file = OpenFile(FLAGS_delay_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 181 | int32_t delay = msg.delay(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 182 | if (FLAGS_text) { |
| 183 | fprintf(delay_file, "%d\n", delay); |
| 184 | } else { |
| 185 | WriteData(&delay, sizeof(delay), delay_file, FLAGS_delay_file); |
| 186 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | if (msg.has_drift()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 190 | static FILE* drift_file = OpenFile(FLAGS_drift_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 191 | int32_t drift = msg.drift(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 192 | if (FLAGS_text) { |
| 193 | fprintf(drift_file, "%d\n", drift); |
| 194 | } else { |
| 195 | WriteData(&drift, sizeof(drift), drift_file, FLAGS_drift_file); |
| 196 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | if (msg.has_level()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 200 | static FILE* level_file = OpenFile(FLAGS_level_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 201 | int32_t level = msg.level(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 202 | if (FLAGS_text) { |
| 203 | fprintf(level_file, "%d\n", level); |
| 204 | } else { |
| 205 | WriteData(&level, sizeof(level), level_file, FLAGS_level_file); |
| 206 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 207 | } |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 208 | |
| 209 | if (msg.has_keypress()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 210 | static FILE* keypress_file = OpenFile(FLAGS_keypress_file, "wb"); |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 211 | bool keypress = msg.keypress(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 212 | if (FLAGS_text) { |
| 213 | fprintf(keypress_file, "%d\n", keypress); |
| 214 | } else { |
| 215 | WriteData(&keypress, sizeof(keypress), keypress_file, |
| 216 | FLAGS_keypress_file); |
| 217 | } |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 218 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 219 | } |
| 220 | } else if (event_msg.type() == Event::INIT) { |
| 221 | if (!event_msg.has_init()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 222 | printf("Corrupt input file: Init missing.\n"); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 223 | return 1; |
| 224 | } |
| 225 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 226 | static FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 227 | const Init msg = event_msg.init(); |
| 228 | // These should print out zeros if they're missing. |
| 229 | fprintf(settings_file, "Init at frame: %d\n", frame_count); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 230 | int input_sample_rate = msg.sample_rate(); |
| 231 | fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate); |
| 232 | int output_sample_rate = msg.output_sample_rate(); |
| 233 | fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); |
| 234 | int reverse_sample_rate = msg.reverse_sample_rate(); |
| 235 | fprintf(settings_file, |
| 236 | " Reverse sample rate: %d\n", |
| 237 | reverse_sample_rate); |
| 238 | num_input_channels = msg.num_input_channels(); |
| 239 | fprintf(settings_file, " Input channels: %d\n", num_input_channels); |
| 240 | num_output_channels = msg.num_output_channels(); |
| 241 | fprintf(settings_file, " Output channels: %d\n", num_output_channels); |
| 242 | num_reverse_channels = msg.num_reverse_channels(); |
| 243 | fprintf(settings_file, " Reverse channels: %d\n", num_reverse_channels); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 244 | |
| 245 | fprintf(settings_file, "\n"); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 246 | |
| 247 | if (reverse_sample_rate == 0) { |
| 248 | reverse_sample_rate = input_sample_rate; |
| 249 | } |
| 250 | if (output_sample_rate == 0) { |
| 251 | output_sample_rate = input_sample_rate; |
| 252 | } |
| 253 | |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 254 | reverse_samples_per_channel = reverse_sample_rate / 100; |
| 255 | input_samples_per_channel = input_sample_rate / 100; |
| 256 | output_samples_per_channel = output_sample_rate / 100; |
| 257 | |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 258 | if (!FLAGS_raw) { |
| 259 | // The WAV files need to be reset every time, because they cant change |
| 260 | // their sample rate or number of channels. |
andrew@webrtc.org | a3ed713 | 2014-10-31 21:51:03 +0000 | [diff] [blame] | 261 | reverse_wav_file.reset(new WavWriter(FLAGS_reverse_file + ".wav", |
| 262 | reverse_sample_rate, |
| 263 | num_reverse_channels)); |
| 264 | input_wav_file.reset(new WavWriter(FLAGS_input_file + ".wav", |
| 265 | input_sample_rate, |
| 266 | num_input_channels)); |
| 267 | output_wav_file.reset(new WavWriter(FLAGS_output_file + ".wav", |
| 268 | output_sample_rate, |
| 269 | num_output_channels)); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 270 | } |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
| 274 | return 0; |
| 275 | } |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 276 | |
| 277 | } // namespace webrtc |
| 278 | |
| 279 | int main(int argc, char* argv[]) { |
| 280 | return webrtc::do_main(argc, argv); |
| 281 | } |