OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 // Accepts deinterleaved float audio with the range [-1, 1]. Each element | 301 // Accepts deinterleaved float audio with the range [-1, 1]. Each element |
302 // of |src| points to a channel buffer, arranged according to | 302 // of |src| points to a channel buffer, arranged according to |
303 // |input_layout|. At output, the channels will be arranged according to | 303 // |input_layout|. At output, the channels will be arranged according to |
304 // |output_layout| at |output_sample_rate_hz| in |dest|. | 304 // |output_layout| at |output_sample_rate_hz| in |dest|. |
305 // | 305 // |
306 // The output layout must have one channel or as many channels as the input. | 306 // The output layout must have one channel or as many channels as the input. |
307 // |src| and |dest| may use the same memory, if desired. | 307 // |src| and |dest| may use the same memory, if desired. |
308 // | 308 // |
309 // TODO(mgraczyk): Remove once clients are updated to use the new interface. | 309 // TODO(mgraczyk): Remove once clients are updated to use the new interface. |
310 virtual int ProcessStream(const float* const* src, | 310 virtual int ProcessStream(const float* const* src, |
311 int samples_per_channel, | 311 size_t samples_per_channel, |
312 int input_sample_rate_hz, | 312 int input_sample_rate_hz, |
313 ChannelLayout input_layout, | 313 ChannelLayout input_layout, |
314 int output_sample_rate_hz, | 314 int output_sample_rate_hz, |
315 ChannelLayout output_layout, | 315 ChannelLayout output_layout, |
316 float* const* dest) = 0; | 316 float* const* dest) = 0; |
317 | 317 |
318 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of | 318 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of |
319 // |src| points to a channel buffer, arranged according to |input_stream|. At | 319 // |src| points to a channel buffer, arranged according to |input_stream|. At |
320 // output, the channels will be arranged according to |output_stream| in | 320 // output, the channels will be arranged according to |output_stream| in |
321 // |dest|. | 321 // |dest|. |
(...skipping 20 matching lines...) Expand all Loading... | |
342 // |input_sample_rate_hz()| | 342 // |input_sample_rate_hz()| |
343 // | 343 // |
344 // TODO(ajm): add const to input; requires an implementation fix. | 344 // TODO(ajm): add const to input; requires an implementation fix. |
345 virtual int AnalyzeReverseStream(AudioFrame* frame) = 0; | 345 virtual int AnalyzeReverseStream(AudioFrame* frame) = 0; |
346 | 346 |
347 // Accepts deinterleaved float audio with the range [-1, 1]. Each element | 347 // Accepts deinterleaved float audio with the range [-1, 1]. Each element |
348 // of |data| points to a channel buffer, arranged according to |layout|. | 348 // of |data| points to a channel buffer, arranged according to |layout|. |
349 // | 349 // |
350 // TODO(mgraczyk): Remove once clients are updated to use the new interface. | 350 // TODO(mgraczyk): Remove once clients are updated to use the new interface. |
351 virtual int AnalyzeReverseStream(const float* const* data, | 351 virtual int AnalyzeReverseStream(const float* const* data, |
352 int samples_per_channel, | 352 size_t samples_per_channel, |
353 int sample_rate_hz, | 353 int sample_rate_hz, |
354 ChannelLayout layout) = 0; | 354 ChannelLayout layout) = 0; |
355 | 355 |
356 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of | 356 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of |
357 // |data| points to a channel buffer, arranged according to |reverse_config|. | 357 // |data| points to a channel buffer, arranged according to |reverse_config|. |
358 virtual int AnalyzeReverseStream(const float* const* data, | 358 virtual int AnalyzeReverseStream(const float* const* data, |
359 const StreamConfig& reverse_config) = 0; | 359 const StreamConfig& reverse_config) = 0; |
360 | 360 |
361 // This must be called if and only if echo processing is enabled. | 361 // This must be called if and only if echo processing is enabled. |
362 // | 362 // |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 sample_rate_hz_ = value; | 490 sample_rate_hz_ = value; |
491 num_frames_ = calculate_frames(value); | 491 num_frames_ = calculate_frames(value); |
492 } | 492 } |
493 void set_num_channels(int value) { num_channels_ = value; } | 493 void set_num_channels(int value) { num_channels_ = value; } |
494 void set_has_keyboard(bool value) { has_keyboard_ = value; } | 494 void set_has_keyboard(bool value) { has_keyboard_ = value; } |
495 | 495 |
496 int sample_rate_hz() const { return sample_rate_hz_; } | 496 int sample_rate_hz() const { return sample_rate_hz_; } |
497 | 497 |
498 // The number of channels in the stream, not including the keyboard channel if | 498 // The number of channels in the stream, not including the keyboard channel if |
499 // present. | 499 // present. |
500 int num_channels() const { return num_channels_; } | 500 int num_channels() const { return num_channels_; } |
Andrew MacDonald
2015/07/24 04:01:43
size_t
| |
501 | 501 |
502 bool has_keyboard() const { return has_keyboard_; } | 502 bool has_keyboard() const { return has_keyboard_; } |
503 int num_frames() const { return num_frames_; } | 503 size_t num_frames() const { return num_frames_; } |
504 | 504 |
505 bool operator==(const StreamConfig& other) const { | 505 bool operator==(const StreamConfig& other) const { |
506 return sample_rate_hz_ == other.sample_rate_hz_ && | 506 return sample_rate_hz_ == other.sample_rate_hz_ && |
507 num_channels_ == other.num_channels_ && | 507 num_channels_ == other.num_channels_ && |
508 has_keyboard_ == other.has_keyboard_; | 508 has_keyboard_ == other.has_keyboard_; |
509 } | 509 } |
510 | 510 |
511 bool operator!=(const StreamConfig& other) const { return !(*this == other); } | 511 bool operator!=(const StreamConfig& other) const { return !(*this == other); } |
512 | 512 |
513 private: | 513 private: |
514 static int calculate_frames(int sample_rate_hz) { | 514 static size_t calculate_frames(int sample_rate_hz) { |
515 return AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000; | 515 return static_cast<size_t>( |
516 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000); | |
516 } | 517 } |
517 | 518 |
518 int sample_rate_hz_; | 519 int sample_rate_hz_; |
519 int num_channels_; | 520 int num_channels_; |
520 bool has_keyboard_; | 521 bool has_keyboard_; |
521 int num_frames_; | 522 size_t num_frames_; |
522 }; | 523 }; |
523 | 524 |
524 class ProcessingConfig { | 525 class ProcessingConfig { |
525 public: | 526 public: |
526 enum StreamName { | 527 enum StreamName { |
527 kInputStream, | 528 kInputStream, |
528 kOutputStream, | 529 kOutputStream, |
529 kReverseStream, | 530 kReverseStream, |
530 kNumStreamNames, | 531 kNumStreamNames, |
531 }; | 532 }; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 // This does not impact the size of frames passed to |ProcessStream()|. | 916 // This does not impact the size of frames passed to |ProcessStream()|. |
916 virtual int set_frame_size_ms(int size) = 0; | 917 virtual int set_frame_size_ms(int size) = 0; |
917 virtual int frame_size_ms() const = 0; | 918 virtual int frame_size_ms() const = 0; |
918 | 919 |
919 protected: | 920 protected: |
920 virtual ~VoiceDetection() {} | 921 virtual ~VoiceDetection() {} |
921 }; | 922 }; |
922 } // namespace webrtc | 923 } // namespace webrtc |
923 | 924 |
924 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ | 925 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ |
OLD | NEW |