OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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. | |
4 | |
5 #include "components/copresence/test/audio_test_support.h" | |
6 | |
7 #include <cstdlib> | |
8 | |
9 #include "media/base/audio_bus.h" | |
10 | |
11 namespace { | |
12 | |
13 const int kFixedRandomSeed = 0x1337; | |
14 | |
15 } // namespace | |
16 | |
17 namespace copresence { | |
18 | |
19 void PopulateSamples(int random_seed, size_t size, float* samples) { | |
20 srand(random_seed); | |
21 for (size_t i = 0; i < size; ++i) | |
22 samples[i] = (2.0 * rand() / RAND_MAX) - 1; | |
23 } | |
24 | |
25 scoped_ptr<media::AudioBus> CreateRandomAudio(int channels, int samples) { | |
26 scoped_ptr<media::AudioBus> bus = media::AudioBus::Create(channels, samples); | |
27 for (int ch = 0; ch < channels; ++ch) | |
28 PopulateSamples(kFixedRandomSeed, samples, bus->channel(ch)); | |
Daniel Erat
2014/07/31 22:31:16
it seems strange that one of the methods in this f
rkc
2014/08/01 21:08:57
Changed to allow passed in seeds for all three.
Do
| |
29 return bus.Pass(); | |
30 } | |
31 | |
32 scoped_refptr<media::AudioBusRefCounted> CreateRandomAudioRefCounted( | |
33 int channels, int samples) { | |
34 scoped_refptr<media::AudioBusRefCounted> bus = | |
35 media::AudioBusRefCounted::Create(channels, samples); | |
36 for (int ch = 0; ch < channels; ++ch) | |
37 PopulateSamples(kFixedRandomSeed, samples, bus->channel(ch)); | |
38 return bus; | |
39 } | |
40 | |
41 } // namespace copresence | |
OLD | NEW |