jan.skoglund@webrtc.org | c3d13d3 | 2014-03-10 22:50:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
henrik.lundin@webrtc.org | 9c55f0f | 2014-06-09 08:10:28 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_ |
jan.skoglund@webrtc.org | c3d13d3 | 2014-03-10 22:50:19 +0000 | [diff] [blame] | 13 | |
jan.skoglund@webrtc.org | c3d13d3 | 2014-03-10 22:50:19 +0000 | [diff] [blame] | 14 | extern "C" { |
sprang@webrtc.org | cf6f46d | 2014-03-14 16:22:18 +0000 | [diff] [blame] | 15 | #include "celt.h" |
| 16 | #include "analysis.h" |
| 17 | #include "opus_private.h" |
jan.skoglund@webrtc.org | c3d13d3 | 2014-03-10 22:50:19 +0000 | [diff] [blame] | 18 | } |
jan.skoglund@webrtc.org | c3d13d3 | 2014-03-10 22:50:19 +0000 | [diff] [blame] | 19 | |
| 20 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 21 | #include "webrtc/typedefs.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | // This class provides a speech/music classification and is a wrapper over the |
| 26 | // Opus classifier. It currently only supports 48 kHz mono or stereo with a |
| 27 | // frame size of 20 ms. |
| 28 | |
| 29 | class AudioClassifier { |
| 30 | public: |
| 31 | AudioClassifier(); |
| 32 | virtual ~AudioClassifier(); |
| 33 | |
| 34 | // Classifies one frame of audio data in input, |
| 35 | // input_length : must be channels * 960; |
| 36 | // channels : must be 1 (mono) or 2 (stereo). |
| 37 | bool Analysis(const int16_t* input, int input_length, int channels); |
| 38 | |
| 39 | // Gets the current classification : true = music, false = speech. |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 40 | virtual bool is_music() const { return is_music_; } |
jan.skoglund@webrtc.org | c3d13d3 | 2014-03-10 22:50:19 +0000 | [diff] [blame] | 41 | |
| 42 | // Gets the current music probability. |
| 43 | float music_probability() const { return music_probability_; } |
| 44 | |
| 45 | private: |
| 46 | AnalysisInfo analysis_info_; |
| 47 | bool is_music_; |
| 48 | float music_probability_; |
| 49 | const CELTMode* celt_mode_; |
| 50 | TonalityAnalysisState analysis_state_; |
| 51 | }; |
| 52 | |
| 53 | } // namespace webrtc |
| 54 | |
henrik.lundin@webrtc.org | 9c55f0f | 2014-06-09 08:10:28 +0000 | [diff] [blame] | 55 | #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_ |