1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_TEST_AUDIO_UTILITY_H_
6 #define MEDIA_CAST_TEST_AUDIO_UTILITY_H_
8 #include "media/audio/simple_sources.h"
23 // Produces AudioBuses of varying duration where each successive output contains
24 // the continuation of a single sine wave.
25 class TestAudioBusFactory {
27 TestAudioBusFactory(int num_channels, int sample_rate,
28 float sine_wave_frequency, float volume);
29 ~TestAudioBusFactory();
31 // Creates a new AudioBus of the given |duration|, filled with the next batch
32 // of sine wave samples.
33 scoped_ptr<AudioBus> NextAudioBus(const base::TimeDelta& duration);
35 // A reasonable test tone.
36 static const int kMiddleANoteFreq = 440;
39 const int num_channels_;
40 const int sample_rate_;
42 SineWaveAudioSource source_;
44 DISALLOW_COPY_AND_ASSIGN(TestAudioBusFactory);
47 // Convenience function to convert an |audio_bus| to its equivalent
49 // TODO(miu): Remove this once all code has migrated to use AudioBus. See
50 // comment in media/cast/cast_config.h.
51 scoped_ptr<PcmAudioFrame> ToPcmAudioFrame(const AudioBus& audio_bus,
54 // Assuming |samples| contains a single-frequency sine wave (and maybe some
55 // low-amplitude noise), count the number of times the sine wave crosses
57 int CountZeroCrossings(const std::vector<int16>& samples);
62 #endif // MEDIA_CAST_TEST_AUDIO_UTILITY_H_