blob: 653b275724b69528b9c8728b15a5f790a825001a [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
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000014extern "C" {
sprang@webrtc.orgcf6f46d2014-03-14 16:22:18 +000015#include "celt.h"
16#include "analysis.h"
17#include "opus_private.h"
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000018}
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000019
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000020#include "webrtc/typedefs.h"
21
22namespace webrtc {
23
24// This class provides a speech/music classification and is a wrapper over the
25// Opus classifier. It currently only supports 48 kHz mono or stereo with a
26// frame size of 20 ms.
27
28class AudioClassifier {
29 public:
30 AudioClassifier();
31 virtual ~AudioClassifier();
32
33 // Classifies one frame of audio data in input,
34 // input_length : must be channels * 960;
35 // channels : must be 1 (mono) or 2 (stereo).
36 bool Analysis(const int16_t* input, int input_length, int channels);
37
38 // Gets the current classification : true = music, false = speech.
Karl Wiberg7f6c4d42015-04-09 15:44:22 +020039 virtual bool is_music() const;
jan.skoglund@webrtc.orgc3d13d32014-03-10 22:50:19 +000040
41 // Gets the current music probability.
42 float music_probability() const { return music_probability_; }
43
44 private:
45 AnalysisInfo analysis_info_;
46 bool is_music_;
47 float music_probability_;
48 const CELTMode* celt_mode_;
49 TonalityAnalysisState analysis_state_;
50};
51
52} // namespace webrtc
53
henrik.lundin@webrtc.org9c55f0f2014-06-09 08:10:28 +000054#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_CLASSIFIER_H_