-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMenuOSC.cpp
129 lines (123 loc) · 4.02 KB
/
MenuOSC.cpp
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
MINI VIRTUAL ANALOG SYNTHESIZER
Copyright 2014 Kenneth D. Miller III
Note Oscillator Menu
*/
#include "StdAfx.h"
#include "MenuOsc.h"
#include "Console.h"
#include "OscillatorNote.h"
#include "Voice.h"
namespace Menu
{
static const SHORT x = 1;
static const SHORT width = 18;
static const SHORT stride = 20;
OSC menu_osc[NUM_OSCILLATORS] =
{
OSC(0, { x, page_pos.Y, x + width, page_pos.Y + OSC::COUNT }, "OSC1", OSC::COUNT - 1),
#if NUM_OSCILLATORS >= 2
OSC(1, { x + stride * 1, page_pos.Y, x + stride * 1 + width, page_pos.Y + OSC::COUNT }, "OSC2", OSC::COUNT),
#if NUM_OSCILLATORS >= 3
OSC(2, { x + stride * 2, page_pos.Y, x + stride * 2 + width, page_pos.Y + OSC::COUNT }, "OSC3", OSC::COUNT),
#if NUM_OSCILLATORS >= 4
OSC(3, { x + stride * 3, page_pos.Y, x + stride * 3 + width, page_pos.Y + OSC::COUNT }, "OSC4", OSC::COUNT),
#endif
#endif
#endif
};
// oscillator menus
void OSC::Update(int index, int sign, DWORD modifiers)
{
NoteOscillatorConfig &config = osc_config[osc];
switch (index)
{
case TITLE:
config.enable = sign > 0;
break;
case WAVETYPE:
config.SetWaveType(Wave((config.wavetype + WAVE_COUNT + sign) % WAVE_COUNT));
for (int v = 0; v < VOICES; ++v)
osc_state[v][osc].Reset();
break;
case WAVEPARAM_BASE:
UpdatePercentageProperty(config.waveparam_base, sign, modifiers, 0, 1);
break;
case FREQUENCY_BASE:
UpdatePitchProperty(config.frequency_base, sign, modifiers, -5, 5);
break;
case AMPLITUDE_BASE:
UpdatePercentageProperty(config.amplitude_base, sign, modifiers, -10, 10);
break;
case WAVEPARAM_LFO:
UpdatePercentageProperty(config.waveparam_lfo, sign, modifiers, -10, 10);
break;
case FREQUENCY_LFO:
UpdatePitchProperty(config.frequency_lfo, sign, modifiers, -5, 5);
break;
case AMPLITUDE_LFO:
UpdatePercentageProperty(config.amplitude_lfo, sign, modifiers, -10, 10);
break;
case KEY_FOLLOW:
UpdatePercentageProperty(config.key_follow, sign, modifiers, -2, 2);
break;
case SUB_OSC_MODE:
config.sub_osc_mode = SubOscillatorMode((config.sub_osc_mode + sign + SUBOSC_COUNT) % SUBOSC_COUNT);
break;
case SUB_OSC_AMPLITUDE:
UpdatePercentageProperty(config.sub_osc_amplitude, sign, modifiers, -10, 10);
break;
case HARD_SYNC:
config.sync_enable = sign > 0;
config.sync_phase = 1.0f;
break;
default:
__assume(0);
}
}
void OSC::Print(int index, HANDLE hOut, COORD pos, DWORD flags)
{
NoteOscillatorConfig &config = osc_config[osc];
switch (index)
{
case TITLE:
PrintTitle(hOut, config.enable, flags, NULL, "OFF");
break;
case WAVETYPE:
PrintItemString(hOut, pos, flags, "%-18s", wave_name[config.wavetype]);
break;
case WAVEPARAM_BASE:
PrintItemFloat(hOut, pos, flags, "Width: % 6.1f%%", config.waveparam_base * 100.0f);
break;
case FREQUENCY_BASE:
PrintItemFloat(hOut, pos, flags, "Frequency: %+7.2f", config.frequency_base * 12.0f);
break;
case AMPLITUDE_BASE:
PrintItemFloat(hOut, pos, flags, "Amplitude:% 7.1f%%", config.amplitude_base * 100.0f);
break;
case WAVEPARAM_LFO:
PrintItemFloat(hOut, pos, flags, "Width LFO: %+6.1f%%", config.waveparam_lfo * 100.0f);
break;
case FREQUENCY_LFO:
PrintItemFloat(hOut, pos, flags, "Freq LFO: %+7.2f", config.frequency_lfo * 12.0f);
break;
case AMPLITUDE_LFO:
PrintItemFloat(hOut, pos, flags, "Ampl LFO: %+7.1f%%", config.amplitude_lfo * 100.0f);
break;
case KEY_FOLLOW:
PrintItemFloat(hOut, pos, flags, "Key Follow:% 6.1f%%", config.key_follow * 100.0f);
break;
case SUB_OSC_MODE:
PrintItemString(hOut, pos, flags, "Sub Osc:%10s", sub_osc_name[config.sub_osc_mode]);
break;
case SUB_OSC_AMPLITUDE:
PrintItemFloat(hOut, pos, flags, "Sub Ampl: % 7.1f%%", config.sub_osc_amplitude * 100.0f);
break;
case HARD_SYNC:
PrintItemBool(hOut, pos, rect.Right - rect.Left, flags, "Hard Sync: ", config.sync_enable);
break;
default:
__assume(0);
}
}
}