blob: e7b7807dbed1dc1e034e102fc01a0bd056ec9810 [file] [log] [blame]
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +00001/*
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.org9c55f0f2014-06-09 08:10:28 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_
12#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000013
14#if defined(__cplusplus)
15extern "C" {
16#endif
sprang@webrtc.orgcf6f46d2014-03-14 16:22:18 +000017#include "celt.h"
18#include "analysis.h"
19#include "opus_private.h"
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000020#if defined(__cplusplus)
21}
22#endif
23
24#include "webrtc/system_wrappers/interface/scoped_ptr.h"
25#include "webrtc/typedefs.h"
26
27namespace webrtc {
28
29// This class provides a speech/music classification and is a wrapper over the
30// Opus classifier. It currently only supports 48 kHz mono or stereo with a
31// frame size of 20 ms.
32
33class AudioClassifier {
34 public:
35 AudioClassifier();
36 virtual ~AudioClassifier();
37
38 // Classifies one frame of audio data in input,
39 // input_length : must be channels * 960;
40 // channels : must be 1 (mono) or 2 (stereo).
41 bool Analysis(const int16_t* input, int input_length, int channels);
42
43 // Gets the current classification : true = music, false = speech.
turaj@webrtc.org8d1cdaa2014-04-11 18:47:55 +000044 virtual bool is_music() const { return is_music_; }
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000045
46 // Gets the current music probability.
47 float music_probability() const { return music_probability_; }
48
49 private:
50 AnalysisInfo analysis_info_;
51 bool is_music_;
52 float music_probability_;
53 const CELTMode* celt_mode_;
54 TonalityAnalysisState analysis_state_;
55};
56
57} // namespace webrtc
58
henrik.lundin@webrtc.org9c55f0f2014-06-09 08:10:28 +000059#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_