| 112 | } |
| 113 | |
| 114 | void 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 | |
| 133 | int ToneGenerator::get_max_frequency() { |
| 134 | return _frequency_high; |
nothing calls this directly
no test coverage detected