aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/dialog_newsong.fl
blob: 3974649cc9ddde1b7c39159955fbf832cc8ebbbe (plain)
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# data file for the Fltk User Interface Designer (fluid)
version 1.0107 
header_name {.h} 
code_name {.cxx}
decl {\#include <hd24fs.h>} {public
} 

decl {\#include <convertlib.h>} {public
} 

class dialog_newsong {open
} {
  decl {int buttonclicked;} {public
  }
  decl {char songname[65];} {public
  }
  decl {unsigned long songlength_in_samples;} {public
  }
  decl {__uint32 samplerate;} {public
  }
  decl {__uint32 trackcount;} {public
  }
  decl {int mode;} {public
  }
  decl {int useasrange;} {public
  }
  decl {int locnum;} {}
  decl {int subsecmax;} {}
  Function {make_window()} {open
  } {
    Fl_Window {} {
      label {New song} open
      xywh {212 241 500 180} type Double color 52
      code0 {buttonclicked=0; mode=2; songname[0]='\\0';}
      code1 {subsecmax=29; samplerate=44100; trackcount=24;}
      code2 {setuiloc(0);} modal visible
    } {
      Fl_Button button_ok {
        label OK
        callback {buttonclicked=1; //OK
strncpy(songname,currname->value(),64);
songlength_in_samples=getsonglen();
Fl_Window * x = Fl::first_window();
x->~Fl_Window();}
        xywh {345 155 70 20} labelsize 12
      }
      Fl_Button button_cancel {
        label Cancel
        callback {buttonclicked=2; //Cancel
useasrange=0; 
Fl_Window * x = Fl::first_window();
x->~Fl_Window();}
        xywh {420 155 70 20} labelsize 12
      }
      Fl_Input hr {
        label {Length: }
        callback {setuiloc(getsonglen());}
        xywh {100 130 50 20} type Int labelsize 12 textsize 12
        code0 {o->maximum_size(2);}
      }
      Fl_Input min {
        label {:}
        callback {setuiloc(getsonglen());}
        xywh {160 130 45 20} type Int labelfont 1 labelsize 12 textsize 12
        code0 {o->maximum_size(2);}
      }
      Fl_Input sec {
        label {:}
        callback {setuiloc(getsonglen());}
        xywh {215 130 45 20} type Int labelfont 1 labelsize 12 textsize 12
        code0 {o->maximum_size(2);}
      }
      Fl_Input subsec {
        label {.}
        callback {setuiloc(getsonglen());}
        xywh {270 130 60 20} type Int labelfont 1 labelsize 12 textsize 12
        code0 {o->maximum_size(5);}
      }
      Fl_Button button_mode {
        label Frames
        callback {setplchan();

mode=(mode+1)%3;
switch(mode) {
	case 0:
	{
		o->label("Sec/100"); 
		subsecmax=99;
		break;
	}
	case 1:
	{		

		if ((pchan /lchan)==2) {
			o->label("2*Sams"); 		
		} else { 
			o->label("Samples"); 		
		}
		subsecmax=samplerate/(pchan/lchan);
		break;
	}
	case 2: 
	{
		o->label("Frames"); 
		subsecmax=29;
		break;
	}
}
setuiloc(songlength_in_samples);}
        xywh {270 110 60 20} labelsize 12 align 18
      }
      Fl_Box {} {
        label Hr
        xywh {100 113 50 17} labelsize 12
      }
      Fl_Box {} {
        label Min
        xywh {160 113 45 17} labelsize 12
      }
      Fl_Box {} {
        label Sec
        xywh {215 113 45 17} labelsize 12
      }
      Fl_Input currname {
        label {Song name:}
        callback {char filteredname[65];
int x=strlen(o->value());
if (x>64) { x=64; }
int src=0;
int filtered=0;
for (int i=0;i<x;i++) {
 	if (
 	   (o->value()[i]=='\\\\') 
 	|| (o->value()[i]=='/') 
 	|| (o->value()[i]==':') 
 	|| (o->value()[i]=='*') 
 	|| (o->value()[i]=='?') 
 	|| (o->value()[i]=='"') 
 	|| (o->value()[i]=='<') 
 	|| (o->value()[i]=='>') 
 	|| (o->value()[i]=='\\\\') 
 	|| (o->value()[i]=='|'))
 	{
 		filtered=1;
 		continue; 	
 	}
	filteredname[src]=o->value()[i];
	src++;
}
filteredname[src]='\\0';
if (filtered==1) {
 	int pos=o->position()-1;
 	if (pos<0) pos=0;
	o->value(filteredname);
	o->position(pos,pos);
}}
        xywh {100 35 390 20} labelsize 12 when 1 textsize 12
        code0 {o->maximum_size(64);}
        code1 {o->value("Song Name"); o->take_focus();}
      }
      Fl_Choice ratechoice {
        label {Sample rate:} open
        xywh {100 60 145 20} down_box BORDER_BOX labelsize 12 textsize 12
        code0 {o->value(0);}
      } {
        MenuItem {} {
          label {44100 Hz}
          callback {samplerate=44100; setuiloc(getsonglen());}
          xywh {35 35 36 21} labelsize 12
        }
        MenuItem {} {
          label {48000 Hz}
          callback {samplerate=48000;setuiloc(getsonglen());}
          xywh {45 45 36 21} labelsize 12
        }
        MenuItem {} {
          label {88200 Hz}
          callback {samplerate=88200; setuiloc(getsonglen());
if (numtracks->value()>7)
{
    numtracks->value(7);
    trackcount=12;
}}
          xywh {55 55 36 21} labelsize 12
        }
        MenuItem {} {
          label {96000 Hz}
          callback {samplerate=96000; setuiloc(getsonglen());
if (numtracks->value()>7)
{
    numtracks->value(7);
    trackcount=12;
}}
          xywh {65 65 36 21} labelsize 12
        }
      }
      Fl_Choice numtracks {
        label {\# of Tracks:} open
        xywh {100 85 145 20} down_box BORDER_BOX labelsize 12 textsize 12
        code0 {o->value(10);}
      } {
        MenuItem {} {
          label 1
          callback {trackcount=1;}
          xywh {45 45 36 21} labelsize 12
        }
        MenuItem {} {
          label 2
          callback {trackcount=2;}
          xywh {55 55 36 21} labelsize 12
        }
        MenuItem {} {
          label 3
          callback {trackcount=3;}
          xywh {65 65 36 21} labelsize 12
        }
        MenuItem {} {
          label 4
          callback {trackcount=4;}
          xywh {75 75 36 21} labelsize 12
        }
        MenuItem {} {
          label 6
          callback {trackcount=6;}
          xywh {85 85 36 21} labelsize 12
        }
        MenuItem {} {
          label 8
          callback {trackcount=8;}
          xywh {95 95 36 21} labelsize 12
        }
        MenuItem {} {
          label 9
          callback {trackcount=9;}
          xywh {105 105 36 21} labelsize 12
        }
        MenuItem {} {
          label 12
          callback {trackcount=12;}
          xywh {105 105 36 21} labelsize 12
        }
        MenuItem {} {
          label 16
          callback {trackcount=16;
if (samplerate>=88200)
{
    trackcount=12;
    numtracks->value(7);
}}
          xywh {115 115 36 21} labelsize 12
        }
        MenuItem {} {
          label 18
          callback {trackcount=18;
if (samplerate>=88200)
{
    trackcount=12;
    numtracks->value(7);
}}
          xywh {125 125 36 21} labelsize 12
        }
        MenuItem {} {
          label 24
          callback {trackcount=24;
if (samplerate>=88200)
{
    trackcount=12;
    numtracks->value(7);
}}
          xywh {135 135 36 21} labelsize 12
        }
      }
      Fl_Box {} {
        label {Please specify the parameters for the new song below:}
        xywh {5 8 485 19} labelfont 1 labelsize 12 align 20
      }
    }
  }
  Function {setuiloc(__uint32 offset)} {open return_type void
  } {
    code {setplchan();
unsigned int chmult=(pchan/lchan);
unsigned long realrate=samplerate/chmult;

string* strhr=Convert::int2str(hd24song::display_hours(offset,realrate));
hr->value(strhr->c_str());
delete strhr;

string* strmin=Convert::int2str(hd24song::display_minutes(offset,realrate));
min->value(strmin->c_str());
delete strmin;

string* strsec=Convert::int2str(hd24song::display_seconds(offset,realrate));
sec->value(strsec->c_str());
delete strsec;

string* strsubsec;

long subseconds=hd24song::display_subseconds(offset,realrate);
long subsecval;
setplchan();

switch(mode) {
   case 0: subsecval=((subseconds*100)/ realrate ); break;
   case 1: subsecval=(subseconds); break;
   case 2: subsecval=((subseconds*30)/realrate  ); break;
   default: subsecval=0;
}
strsubsec=Convert::int2str(subsecval);
subsec->value(strsubsec->c_str());
delete strsubsec;} {}
  }
  Function {setplchan()} {open
  } {
    code {lchan = trackcount;
if (this->samplerate>=88200) {
	pchan=lchan*2;
} else {
	pchan=lchan;
}} {}
  }
  decl {int pchan;} {}
  decl {int lchan;} {}
  Function {getsonglen()} {open return_type __uint32
  } {
    code {setplchan();
unsigned int chmult=(pchan/lchan);
unsigned long realrate=samplerate/chmult;

long frames=0;
switch(mode) {
   case 0: frames=100; break;
   case 1: frames=realrate; break;
   case 2: frames=30; break;
}

__uint64 mylocpoint=((__uint64)3600* (__uint64)strtol( hr->value(),0,10) )
	           +((__uint64)  60* (__uint64)strtol(min->value(),0,10) )
	           +((__uint64)   1* (__uint64)strtol(sec->value(),0,10) )
	           ;
	
mylocpoint=(__uint64)((__uint64)realrate*(__uint64)mylocpoint);

mylocpoint+=(__uint64)(strtol(subsec->value(),0,10)*samplerate/(frames*chmult));

if (mylocpoint>0xFFFFFFFF) {
	mylocpoint=0xFFFFFFFF;	
}	
return (__uint32)mylocpoint;} {selected
    }
  }
}