| 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace WebCore { | 33 namespace WebCore { |
| 34 | 34 |
| 35 class AudioBus; | 35 class AudioBus; |
| 36 class FFTFrame; | 36 class FFTFrame; |
| 37 | 37 |
| 38 class RealtimeAnalyser { | 38 class RealtimeAnalyser { |
| 39 WTF_MAKE_NONCOPYABLE(RealtimeAnalyser); | 39 WTF_MAKE_NONCOPYABLE(RealtimeAnalyser); |
| 40 public: | 40 public: |
| 41 RealtimeAnalyser(); | 41 RealtimeAnalyser(); |
| 42 virtual ~RealtimeAnalyser(); | 42 virtual ~RealtimeAnalyser(); |
| 43 | 43 |
| 44 void reset(); | 44 void reset(); |
| 45 | 45 |
| 46 size_t fftSize() const { return m_fftSize; } | 46 size_t fftSize() const { return m_fftSize; } |
| 47 bool setFftSize(size_t); | 47 bool setFftSize(size_t); |
| 48 | 48 |
| 49 unsigned frequencyBinCount() const { return m_fftSize / 2; } | 49 unsigned frequencyBinCount() const { return m_fftSize / 2; } |
| 50 | 50 |
| 51 void setMinDecibels(float k) { m_minDecibels = k; } | 51 void setMinDecibels(float k) { m_minDecibels = k; } |
| 52 float minDecibels() const { return static_cast<float>(m_minDecibels); } | 52 float minDecibels() const { return static_cast<float>(m_minDecibels); } |
| 53 | 53 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 static const unsigned DefaultFFTSize; | 71 static const unsigned DefaultFFTSize; |
| 72 static const unsigned MinFFTSize; | 72 static const unsigned MinFFTSize; |
| 73 static const unsigned MaxFFTSize; | 73 static const unsigned MaxFFTSize; |
| 74 static const unsigned InputBufferSize; | 74 static const unsigned InputBufferSize; |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 // The audio thread writes the input audio here. | 77 // The audio thread writes the input audio here. |
| 78 AudioFloatArray m_inputBuffer; | 78 AudioFloatArray m_inputBuffer; |
| 79 unsigned m_writeIndex; | 79 unsigned m_writeIndex; |
| 80 | 80 |
| 81 size_t m_fftSize; | 81 size_t m_fftSize; |
| 82 OwnPtr<FFTFrame> m_analysisFrame; | 82 OwnPtr<FFTFrame> m_analysisFrame; |
| 83 void doFFTAnalysis(); | 83 void doFFTAnalysis(); |
| 84 | 84 |
| 85 // doFFTAnalysis() stores the floating-point magnitude analysis data here. | 85 // doFFTAnalysis() stores the floating-point magnitude analysis data here. |
| 86 AudioFloatArray m_magnitudeBuffer; | 86 AudioFloatArray m_magnitudeBuffer; |
| 87 AudioFloatArray& magnitudeBuffer() { return m_magnitudeBuffer; } | 87 AudioFloatArray& magnitudeBuffer() { return m_magnitudeBuffer; } |
| 88 | 88 |
| 89 // A value between 0 and 1 which averages the previous version of m_magnitud
eBuffer with the current analysis magnitude data. | 89 // A value between 0 and 1 which averages the previous version of m_magnitud
eBuffer with the current analysis magnitude data. |
| 90 double m_smoothingTimeConstant; | 90 double m_smoothingTimeConstant; |
| 91 | 91 |
| 92 // The range used when converting when using getByteFrequencyData(). | 92 // The range used when converting when using getByteFrequencyData(). |
| 93 double m_minDecibels; | 93 double m_minDecibels; |
| 94 double m_maxDecibels; | 94 double m_maxDecibels; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace WebCore | 97 } // namespace WebCore |
| 98 | 98 |
| 99 #endif // RealtimeAnalyser_h | 99 #endif // RealtimeAnalyser_h |
| OLD | NEW |