comparison audioio/ContinuousSynth.h @ 313:58582119c92a tonioni

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