58 , sampleRate_(sampleRate)
59 , tone_(
"", sampleRate, sampleFormat)
65 toneBuffers_[
i] = fillToneBuffer(
i);
75 if (code >=
'0' and code <=
'9')
76 state.sample = toneBuffers_[code -
'0'].get();
77 else if (code >=
'A' and code <=
'D')
78 state.sample = toneBuffers_[code -
'A' + 10].get();
82 state.sample = toneBuffers_[
NUM_TONES - 2].get();
86 state.sample = toneBuffers_[
NUM_TONES - 1].get();
100 frame->ch_layout.nb_channels,
102 state.offset =
frame->nb_samples % sampleRate_;
112 if (state.sample == 0)
120 frame->ch_layout.nb_channels,
122 state.offset = (state.offset +
frame->nb_samples) % sampleRate_;
126DTMFGenerator::fillToneBuffer(
unsigned index)
130 ptr->nb_samples = sampleRate_;
132 ptr->sample_rate = sampleRate_;
AudioFormat getFormat() const
void getNextSamples(AVFrame *frame)
DTMFGenerator(unsigned int sampleRate, AVSampleFormat sampleFormat)
DTMF Generator contains frequency of each keys and can build one DTMF.
void getSamples(AVFrame *frame, unsigned char code)
static void genSin(AVFrame *buffer, size_t outPos, unsigned nb_samples, unsigned frequency1, unsigned frequency2)
Add a simple or double sin to the buffer, it double the sin in stereo.
void emitSignal(Args... args)
constexpr DTMFTone TONES[]
std::unique_ptr< AVFrame, AVFrame_deleter > FrameBuffer
unsigned higher
Lower frequency.
unsigned lower
Code of the tone.