OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 }; | 59 }; |
60 | 60 |
61 enum ChannelInterpretation { | 61 enum ChannelInterpretation { |
62 Speakers, | 62 Speakers, |
63 Discrete, | 63 Discrete, |
64 }; | 64 }; |
65 | 65 |
66 // allocate indicates whether or not to initially have the AudioChannels cre
ated with managed storage. | 66 // allocate indicates whether or not to initially have the AudioChannels cre
ated with managed storage. |
67 // Normal usage is to pass true here, in which case the AudioChannels will m
emory-manage their own storage. | 67 // Normal usage is to pass true here, in which case the AudioChannels will m
emory-manage their own storage. |
68 // If allocate is false then setChannelMemory() has to be called later on fo
r each channel before the AudioBus is useable... | 68 // If allocate is false then setChannelMemory() has to be called later on fo
r each channel before the AudioBus is useable... |
69 AudioBus(unsigned numberOfChannels, size_t length, bool allocate = true); | 69 static PassRefPtr<AudioBus> create(unsigned numberOfChannels, size_t length,
bool allocate = true); |
70 | 70 |
71 // Tells the given channel to use an externally allocated buffer. | 71 // Tells the given channel to use an externally allocated buffer. |
72 void setChannelMemory(unsigned channelIndex, float* storage, size_t length); | 72 void setChannelMemory(unsigned channelIndex, float* storage, size_t length); |
73 | 73 |
74 // Channels | 74 // Channels |
75 unsigned numberOfChannels() const { return m_channels.size(); } | 75 unsigned numberOfChannels() const { return m_channels.size(); } |
76 | 76 |
77 AudioChannel* channel(unsigned channel) { return m_channels[channel].get();
} | 77 AudioChannel* channel(unsigned channel) { return m_channels[channel].get();
} |
78 const AudioChannel* channel(unsigned channel) const { return const_cast<Audi
oBus*>(this)->m_channels[channel].get(); } | 78 const AudioChannel* channel(unsigned channel) const { return const_cast<Audi
oBus*>(this)->m_channels[channel].get(); } |
79 AudioChannel* channelByType(unsigned type); | 79 AudioChannel* channelByType(unsigned type); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 float maxAbsValue() const; | 142 float maxAbsValue() const; |
143 | 143 |
144 // Makes maximum absolute value == 1.0 (if possible). | 144 // Makes maximum absolute value == 1.0 (if possible). |
145 void normalize(); | 145 void normalize(); |
146 | 146 |
147 static PassRefPtr<AudioBus> loadPlatformResource(const char* name, float sam
pleRate); | 147 static PassRefPtr<AudioBus> loadPlatformResource(const char* name, float sam
pleRate); |
148 | 148 |
149 protected: | 149 protected: |
150 AudioBus() { }; | 150 AudioBus() { }; |
151 | 151 |
| 152 AudioBus(unsigned numberOfChannels, size_t length, bool allocate); |
| 153 |
152 void speakersCopyFrom(const AudioBus&); | 154 void speakersCopyFrom(const AudioBus&); |
153 void discreteCopyFrom(const AudioBus&); | 155 void discreteCopyFrom(const AudioBus&); |
154 void speakersSumFrom(const AudioBus&); | 156 void speakersSumFrom(const AudioBus&); |
155 void discreteSumFrom(const AudioBus&); | 157 void discreteSumFrom(const AudioBus&); |
156 void speakersSumFrom5_1_ToMono(const AudioBus&); | 158 void speakersSumFrom5_1_ToMono(const AudioBus&); |
157 | 159 |
158 size_t m_length; | 160 size_t m_length; |
159 Vector<OwnPtr<AudioChannel> > m_channels; | 161 Vector<OwnPtr<AudioChannel> > m_channels; |
160 int m_layout; | 162 int m_layout; |
161 float m_busGain; | 163 float m_busGain; |
162 OwnPtr<AudioFloatArray> m_dezipperGainValues; | 164 OwnPtr<AudioFloatArray> m_dezipperGainValues; |
163 bool m_isFirstTime; | 165 bool m_isFirstTime; |
164 float m_sampleRate; // 0.0 if unknown or N/A | 166 float m_sampleRate; // 0.0 if unknown or N/A |
165 }; | 167 }; |
166 | 168 |
167 } // WebCore | 169 } // WebCore |
168 | 170 |
169 #endif // AudioBus_h | 171 #endif // AudioBus_h |
OLD | NEW |