MCPcopy Create free account
hub / github.com/OpenEarable/open-earable / update

Method update

src/audio_play/ToneGenerator.cpp:114–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void ToneGenerator::update() {
115 if (!_available) return;
116 //if ((*stream)->ready() < 2) return;
117
118 int16_t * ptr = (int16_t*)((*stream)->buffer.getWritePointer());
119
120 for (int i = 0; i < _block_size / sizeof(int16_t); i ++) {
121 ptr[i] = MAX_INT16 * (_tone.amplitude * wave(_delta * _t));
122 _t += _tone.frequency;
123 _t = _t >= _sample_rate ? _t - _sample_rate : _t;
124 if (_modulation && ++t_call >= call_every) {
125 _tone = _modulation();
126 t_call -= call_every;
127 }
128 }
129
130 (*stream)->provide(1);
131}
132
133int ToneGenerator::get_max_frequency() {
134 return _frequency_high;

Callers

nothing calls this directly

Calls 2

getWritePointerMethod · 0.80
provideMethod · 0.45

Tested by

no test coverage detected