-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
92 lines (73 loc) · 2.34 KB
/
main.cpp
File metadata and controls
92 lines (73 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "modsynth.h"
#include "modules/vco.hpp"
#include "modules/vcf.hpp"
#include "modules/envelope.hpp"
#include "modules/delay.hpp"
#include "modules/sequencer.hpp"
#include "modules/keyboard.hpp"
#include "modules/mixer.hpp"
#include "midiInput.h"
#include <iostream>
using namespace ModSynth;
int main() {
// Initialize Midi control
MidiInput midiIn;
// Keyboard control
Keyboard keys;
// Sequencer unit
VCO clock{250}; // BPM input
std::vector<Note> notes = {
{std::string("C4"), 3, 0},
{std::string("E4"), 2, 0},
{std::string("G4"), 2, 0},
{std::string("-"), 1, 0},
{std::string("B4"), 3, 0},
};
Sequencer sequencer{notes};
// Voice 1
VCO vco1{WaveShape::SAW};
VCF vcf1{0.4, 0.2, LOWPASS, FOUR_POLE};
VCA vca1{2000};
// Voice 2
VCO vco2{WaveShape::SQUARE};
VCF vcf2{0.4, 0.2, LOWPASS, FOUR_POLE};
VCA vca2{2000};
vco2.octaveShift = -0.0005;
// Envelopes
Envelope envelope1{0.1, 0.2, 0.2};
Envelope envelope2{0.1, 0.5, 0.5};
// Effects
Delay delay{0.5f, 0.5f, 0.5f, DelayMode::PING_PONG};
delay.stereo_ratio = 0.666f;
// Output
Mixer mixer({0.7f, 0.3f});
Speaker speaker;
// Two oscilator monosynth with effects
Wire wires[]{
// Voice 1 wiring
{envelope1.gate_in, keys.gate_out},
{vco1.frequency, keys.frequency_out},
{vcf1.audio_in, vco1.audio_out},
{vcf1.contour, envelope1.amplitude_out},
{vca1.audio_in, vcf1.audio_out},
{vca1.amplitude, envelope1.amplitude_out},
// Voice 2 wiring
{envelope2.gate_in, keys.gate_out},
{vco2.frequency, keys.frequency_out},
{vcf2.audio_in, vco2.audio_out},
{vcf2.contour, envelope2.amplitude_out},
{vca2.audio_in, vcf2.audio_out},
{vca2.amplitude, envelope2.amplitude_out},
// Output section wiring
{mixer.audio_ins[0], vca1.audio_out},
{mixer.audio_ins[1], vca2.audio_out},
{delay.audio_in_left, mixer.audio_out},
{delay.audio_in_right, mixer.audio_out},
{speaker.left_in, delay.audio_out_left},
{speaker.right_in, delay.audio_out_right},
};
fprintf(stderr, "Press q to quit\n");
while(!keys.quit);
SDL_Quit();
return 0;
}