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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
#include <string>
#include <fstream>
#include <cstdlib>
#include <sys/types.h>
#include <dirent.h>
#include "util.h"
#include "globals.h"
using namespace std;
void add_dir(string directory, bool complain=true)
{
DIR *dir;
dir=opendir(directory.c_str());
if (dir)
{
string n, snum;
int num;
dirent *entry=NULL;
while ( (entry=readdir(dir)) != NULL )
{
n=entry->d_name;
if (fileext(n)=="prog")
{
snum=n.substr(0,3);
if (isnum(snum))
{
num=atoi(snum.c_str());
if ((num>=0) && (num<=127))
{
if (programfile[num]=="")
programfile[num]=n;
else
output_verbose ("NOTE: found two or more .prog files with same number. ignoring '"+n+"'");
}
else
{
output_note ("NOTE: found .prog file with invalid number, ignoring it... ('"+n+"')");
}
}
else
{
output_note ("NOTE: found .prog file which does not start with a number, ignoring it... ('"+n+"')");
}
}
}
closedir(dir);
}
else
{
if (complain)
output_warning("WARNING: could not open directory '"+directory+"'!\n"
" this is not fatal, ignoring and proceeding...");
}
}
void read_config(const char *cfg, bool complain=true)
{
char buf[2000];
ifstream f;
f.open(cfg);
if (f.good())
{
string line;
while (!f.eof())
{
f.getline(buf,sizeof(buf)/sizeof(*buf)-1);
line=buf;
line=trim_spaces(line);
if ((line!="") && (line[0]!='#')) //ignore comments and empty lines
{
if (line.substr(0,string("include ").length())=="include ")
{
add_dir(trim_spaces(line.substr(string("include ").length())));
}
else
{
string var,val;
var=trim_spaces(extract_var(line));
val=trim_spaces(extract_val(line));
if (isnum(var)) //programmzuweisung
{
int num=atoi(var.c_str());
if ((num>=0) && (num<=127))
{
if (programfile[num]=="")
programfile[num]=val;
else
output_verbose ("NOTE: program #"+IntToStr(num)+" has already been defined. ignoring it...");
}
else
{
output_warning("WARNING: number out of range (0..127) in program assignment. ignoring it...");
}
}
else
{
float valf=atof(val.c_str());
if (var=="frameskip")
{
if (valf<0)
output_warning("WARNING: invalid value for '"+var+"' ("+val+"). ignoring it...");
if (frameskip==-1)
frameskip=valf;
else
output_verbose("NOTE: ignoring value for frameskip, another setting overrides this.");
}
else
{
if (valf<=0)
output_warning("WARNING: invalid value for '"+var+"' ("+val+"). ignoring it...");
if ((var=="snh_freq") || (var=="sample_and_hold_freq"))
{
if (snh_freq_hz==0)
snh_freq_hz=valf;
else
output_verbose("NOTE: ignoring value for sample_and_hold_freq, another setting overrides this.");
}
if (var=="lfo0_freq") //FINDLFO
{
if (lfo_freq_hz[0]==0)
lfo_freq_hz[0]=valf;
else
output_verbose("NOTE: ignoring value for "+var+", another setting overrides this.");
}
if (var=="lfo1_freq")
{
if (lfo_freq_hz[1]==0)
lfo_freq_hz[1]=valf;
else
output_verbose("NOTE: ignoring value for "+var+", another setting overrides this.");
}
if (var=="lfo2_freq")
{
if (lfo_freq_hz[2]==0)
lfo_freq_hz[2]=valf;
else
output_verbose("NOTE: ignoring value for "+var+", another setting overrides this.");
}
else if ((var=="cleanup-interval") || (var=="clean"))
{
if (cleanup_interval_sec==0)
cleanup_interval_sec=valf;
else
output_verbose("NOTE: ignoring value for cleanup-interval, another setting overrides this.");
}
else if ((var=="max_port") || (var=="max_port_time") || (var=="max_portamento_time"))
{
if (max_port_time_sec==0)
max_port_time_sec=valf;
else
output_verbose("NOTE: ignoring value for max-portamento-time, another setting overrides this.");
}
else if (var=="lfo_update_freq")
{
if (lfo_update_freq_hz==0)
lfo_update_freq_hz=valf;
else
output_verbose("NOTE: ignoring value for lfo_update_freq, another setting overrides this.");
}
else if (var=="filter_update_freq")
{
if (filter_update_freq_hz==0)
filter_update_freq_hz=valf;
else
output_verbose("NOTE: ignoring value for filter_update_freq, another setting overrides this.");
}
else
output_warning("WARNING: unknown variable '"+var+"'. ignoring it...");
}
}
}
}
}
}
else
{
output_warning("WARNING: could not open config file '"+string(cfg)+"'.\nignoring this file...");
}
}
|