annotate audioio/ContinuousSynth.h @ 323:5c69d40a0e30 tonioni

Added alternate waveforms for sonification. Created parameter m_wavetype in ContinuousSynth.
author Rachel Bittner <rmb456@nyu.edu>
date Sun, 12 Jan 2014 05:12:08 -0500
parents 58582119c92a
children d2c13ec0f148
rev   line source
Chris@313 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@313 2
Chris@313 3 /*
Chris@313 4 Sonic Visualiser
Chris@313 5 An audio file viewer and annotation editor.
Chris@313 6 Centre for Digital Music, Queen Mary, University of London.
Chris@313 7
Chris@313 8 This program is free software; you can redistribute it and/or
Chris@313 9 modify it under the terms of the GNU General Public License as
Chris@313 10 published by the Free Software Foundation; either version 2 of the
Chris@313 11 License, or (at your option) any later version. See the file
Chris@313 12 COPYING included with this distribution for more information.
Chris@313 13 */
Chris@313 14
Chris@313 15 #ifndef CONTINUOUS_SYNTH_H
Chris@313 16 #define CONTINUOUS_SYNTH_H
Chris@313 17
Chris@313 18 /**
Chris@313 19 * Mix into a target buffer a signal synthesised so as to sound at a
Chris@313 20 * specific frequency. The frequency may change with each processing
Chris@313 21 * block, or may be switched on or off.
Chris@313 22 */
Chris@313 23
Chris@313 24 class ContinuousSynth
Chris@313 25 {
Chris@313 26 public:
rmb456@323 27 ContinuousSynth(int channels, int sampleRate, int blockSize, int waveType);
Chris@313 28 ~ContinuousSynth();
Chris@313 29
Chris@313 30 void setChannelCount(int channels);
Chris@313 31
Chris@313 32 void reset();
Chris@313 33
Chris@313 34 /**
Chris@313 35 * Mix in a signal to be heard at the given fundamental
Chris@313 36 * frequency. Any oscillator state will be maintained between
Chris@313 37 * process calls so as to provide a continuous sound. The f0 value
Chris@313 38 * may vary between calls.
Chris@313 39 *
Chris@313 40 * Supply f0 equal to 0 if you want to maintain the f0 from the
Chris@313 41 * previous block (without having to remember what it was).
Chris@313 42 *
Chris@313 43 * Supply f0 less than 0 for silence. You should continue to call
Chris@313 44 * this even when the signal is silent if you want to ensure the
Chris@313 45 * sound switches on and off cleanly.
Chris@313 46 */
Chris@313 47 void mix(float **toBuffers,
Chris@313 48 float gain,
Chris@313 49 float pan,
Chris@313 50 float f0);
Chris@313 51
Chris@313 52 private:
Chris@313 53 int m_channels;
Chris@313 54 int m_sampleRate;
Chris@313 55 int m_blockSize;
Chris@313 56
Chris@313 57 double m_prevF0;
Chris@313 58 double m_phase;
rmb456@323 59
rmb456@323 60 int m_wavetype;
Chris@313 61 };
Chris@313 62
Chris@313 63 #endif