forked from yokemura/Magical8bitPlug2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cpp
79 lines (65 loc) · 1.77 KB
/
Settings.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
/*
==============================================================================
Settings.cpp
Created: 23 May 2019 11:54:44am
Author: 除村 武志
==============================================================================
*/
#include "Settings.h"
#include "FrameSequenceParser.h"
bool SettingRefs::setSequenceWithString (const String& type, const String& input, ParseError* error)
{
FrameSequenceParser parser;
if (type == "volume")
{
FrameSequence res = parser.parse (input, 0, 15, error);
if (*error > kParseErrorLevelFatal)
{
return false;
}
volumeSequence = res;
volumeSequenceString = input;
return true;
}
else if (type == "pitch")
{
FrameSequence res = parser.parse (input, -64, 63, error);
if (*error > kParseErrorLevelFatal)
{
return false;
}
pitchSequence = res;
pitchSequenceString = input;
return true;
}
else if (type == "duty")
{
FrameSequence res = parser.parse (input, 0, 2, error);
if (*error > kParseErrorLevelFatal)
{
return false;
}
dutySequence = res;
dutySequenceString = input;
return true;
}
printf ("*** parameter type invalid!\n");
return false;
}
String& SettingRefs::getSequenceString (const String& type)
{
if (type == "volume")
{
return volumeSequenceString;
}
else if (type == "pitch")
{
return pitchSequenceString;
}
else if (type == "duty")
{
return dutySequenceString;
}
printf ("*** parameter type invalid!\n");
return volumeSequenceString;
}