-
-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathsilence_remover.h
53 lines (40 loc) · 962 Bytes
/
silence_remover.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2016 Lukas Lalinsky
// Distributed under the MIT license, see the LICENSE file for details.
#ifndef CHROMAPRINT_SILENCE_REMOVER_H_
#define CHROMAPRINT_SILENCE_REMOVER_H_
#include "utils.h"
#include "audio_consumer.h"
#include "moving_average.h"
namespace chromaprint {
class SilenceRemover : public AudioConsumer
{
public:
SilenceRemover(AudioConsumer *consumer, int threshold = 0);
AudioConsumer *consumer() const
{
return m_consumer;
}
void set_consumer(AudioConsumer *consumer)
{
m_consumer = consumer;
}
bool Reset(int sample_rate, int num_channels);
void Consume(const int16_t *input, int length) override;
void Flush();
int threshold()
{
return m_threshold;
}
void set_threshold(int value)
{
m_threshold = value;
}
private:
CHROMAPRINT_DISABLE_COPY(SilenceRemover);
bool m_start;
int m_threshold;
MovingAverage<int16_t> m_average;
AudioConsumer *m_consumer;
};
}; // namespace chromaprint
#endif