-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMenuAMP.cpp
80 lines (75 loc) · 2.31 KB
/
MenuAMP.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
/*
MINI VIRTUAL ANALOG SYNTHESIZER
Copyright 2014 Kenneth D. Miller III
Amplifier Menu
*/
#include "StdAfx.h"
#include "MenuAMP.h"
#include "Console.h"
#include "Math.h"
#include "Amplifier.h"
namespace Menu
{
AMP menu_amp({ 41, page_pos.Y + 7, 41 + 18, page_pos.Y + 7 + AMP::COUNT }, "AMP", AMP::COUNT);
void AMP::Update(int index, int sign, DWORD modifiers)
{
switch (index)
{
case TITLE:
amp_env_config.enable = sign > 0;
break;
case LEVEL_ENV:
UpdatePercentageProperty(amp_config.level_env, sign, modifiers, 0, 1);
break;
case LEVEL_ENV_VEL:
UpdatePercentageProperty(amp_config.level_env_vel, sign, modifiers, 0, 1);
break;
case ENV_ATTACK:
UpdateTimeProperty(amp_env_config.attack_time, sign, modifiers, 0, 10);
amp_env_config.attack_rate = 1.0f / (amp_env_config.attack_time + FLT_MIN);
break;
case ENV_DECAY:
UpdateTimeProperty(amp_env_config.decay_time, sign, modifiers, 0, 10);
amp_env_config.decay_rate = 1.0f / (amp_env_config.decay_time + FLT_MIN);
break;
case ENV_SUSTAIN:
UpdatePercentageProperty(amp_env_config.sustain_level, sign, modifiers, 0, 1);
break;
case ENV_RELEASE:
UpdateTimeProperty(amp_env_config.release_time, sign, modifiers, 0, 10);
amp_env_config.release_rate = 1.0f / (amp_env_config.release_time + FLT_MIN);
break;
default:
__assume(0);
}
}
void AMP::Print(int index, HANDLE hOut, COORD pos, DWORD flags)
{
switch (index)
{
case TITLE:
PrintTitle(hOut, amp_env_config.enable, flags, " ON", "OFF");
break;
case LEVEL_ENV:
PrintItemFloat(hOut, pos, flags, "Level ENV: %5.1f%%", amp_config.level_env * 100.0f);
break;
case LEVEL_ENV_VEL:
PrintItemFloat(hOut, pos, flags, "Level VEL: %5.1f%%", amp_config.level_env_vel * 100.0f);
break;
case ENV_ATTACK:
PrintItemFloat(hOut, pos, flags, "Attack: %7.3fs", amp_env_config.attack_time);
break;
case ENV_DECAY:
PrintItemFloat(hOut, pos, flags, "Decay: %7.3fs", amp_env_config.decay_time);
break;
case ENV_SUSTAIN:
PrintItemFloat(hOut, pos, flags, "Sustain: %5.1f%%", amp_env_config.sustain_level * 100.0f);
break;
case ENV_RELEASE:
PrintItemFloat(hOut, pos, flags, "Release: %7.3fs", amp_env_config.release_time);
break;
default:
__assume(0);
}
}
}