Chris@313: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@313: Chris@313: /* Chris@313: Sonic Visualiser Chris@313: An audio file viewer and annotation editor. Chris@313: Centre for Digital Music, Queen Mary, University of London. Chris@313: Chris@313: This program is free software; you can redistribute it and/or Chris@313: modify it under the terms of the GNU General Public License as Chris@313: published by the Free Software Foundation; either version 2 of the Chris@313: License, or (at your option) any later version. See the file Chris@313: COPYING included with this distribution for more information. Chris@313: */ Chris@313: Chris@313: #ifndef CONTINUOUS_SYNTH_H Chris@313: #define CONTINUOUS_SYNTH_H Chris@313: Chris@313: /** Chris@313: * Mix into a target buffer a signal synthesised so as to sound at a Chris@313: * specific frequency. The frequency may change with each processing Chris@313: * block, or may be switched on or off. Chris@313: */ Chris@313: Chris@313: class ContinuousSynth Chris@313: { Chris@313: public: rmb456@323: ContinuousSynth(int channels, int sampleRate, int blockSize, int waveType); Chris@313: ~ContinuousSynth(); Chris@313: Chris@313: void setChannelCount(int channels); Chris@313: Chris@313: void reset(); Chris@313: Chris@313: /** Chris@313: * Mix in a signal to be heard at the given fundamental Chris@313: * frequency. Any oscillator state will be maintained between Chris@313: * process calls so as to provide a continuous sound. The f0 value Chris@313: * may vary between calls. Chris@313: * Chris@313: * Supply f0 equal to 0 if you want to maintain the f0 from the Chris@313: * previous block (without having to remember what it was). Chris@313: * Chris@313: * Supply f0 less than 0 for silence. You should continue to call Chris@313: * this even when the signal is silent if you want to ensure the Chris@313: * sound switches on and off cleanly. Chris@313: */ Chris@313: void mix(float **toBuffers, justin@327: float gain, justin@327: float pan, justin@327: float f0); Chris@313: Chris@313: private: Chris@313: int m_channels; Chris@313: int m_sampleRate; Chris@313: int m_blockSize; Chris@313: Chris@313: double m_prevF0; Chris@313: double m_phase; rmb456@323: rmb456@323: int m_wavetype; Chris@313: }; Chris@313: Chris@313: #endif