diff options
Diffstat (limited to 'src/frontend/ui_hd24connect.fl')
-rwxr-xr-x | src/frontend/ui_hd24connect.fl | 4597 |
1 files changed, 4597 insertions, 0 deletions
diff --git a/src/frontend/ui_hd24connect.fl b/src/frontend/ui_hd24connect.fl new file mode 100755 index 0000000..eae32ad --- /dev/null +++ b/src/frontend/ui_hd24connect.fl | |||
@@ -0,0 +1,4597 @@ | |||
1 | # data file for the Fltk User Interface Designer (fluid) | ||
2 | version 1.0109 | ||
3 | header_name {.h} | ||
4 | code_name {.cxx} | ||
5 | decl {class HD24TrackChannel;} {public | ||
6 | } | ||
7 | |||
8 | decl {class TrackInfo;} {public | ||
9 | } | ||
10 | |||
11 | decl {class HD24UserInterface;} {public | ||
12 | } | ||
13 | |||
14 | decl {class MixerUI;} {public | ||
15 | } | ||
16 | |||
17 | decl {class RecorderUI;} {public | ||
18 | } | ||
19 | |||
20 | decl {class PortAudioWrapper;} {public | ||
21 | } | ||
22 | |||
23 | decl {class JackWrapper;} {public | ||
24 | } | ||
25 | |||
26 | decl {class hd24transferengine;} {public | ||
27 | } | ||
28 | |||
29 | decl {\#define HD24DEBUG 0} {public | ||
30 | } | ||
31 | |||
32 | decl {\#define BLINKRATE 25} {public | ||
33 | } | ||
34 | |||
35 | decl {\#define PA_FRAMESPERBUF 512} {public | ||
36 | } | ||
37 | |||
38 | decl {\#define MAXCHANNELS 24} {public | ||
39 | } | ||
40 | |||
41 | decl {\#define UIREFRESH 1 /* 1=best, 10=1/10 refresh rate */} {public | ||
42 | } | ||
43 | |||
44 | decl {\#define HD24MODE hd24fs::MODE_RDWR} {public | ||
45 | } | ||
46 | |||
47 | decl {\#define TIMEOUT 0.03} {public | ||
48 | } | ||
49 | |||
50 | decl {\#define SPLITFILESIZE_BYTES ((__uint64)(1024*1024*1024))} {public | ||
51 | } | ||
52 | |||
53 | decl {\#include <config.h>} {public | ||
54 | } | ||
55 | |||
56 | decl {\#include <string>} {public | ||
57 | } | ||
58 | |||
59 | decl {\#include <vector>} {public | ||
60 | } | ||
61 | |||
62 | decl {\#include <portwin.h>} {public | ||
63 | } | ||
64 | |||
65 | decl {\#include <soundlibs.h> /* portaudio, libjack */} {public | ||
66 | } | ||
67 | |||
68 | decl {\#include <iostream>} {public | ||
69 | } | ||
70 | |||
71 | decl {\#include <FL/FLTKstuff.H>} {public | ||
72 | } | ||
73 | |||
74 | decl {\#include <FL/Fl_Menu_Bar.H>} {public | ||
75 | } | ||
76 | |||
77 | decl {\#include <FL/Fl_File_Chooser.H>} {public | ||
78 | } | ||
79 | |||
80 | decl {\#include <FL/filename.H>} {public | ||
81 | } | ||
82 | |||
83 | decl {\#include <xplat_dlfcn.h>} {public | ||
84 | } | ||
85 | |||
86 | decl {\#include <sndfile.h>} {public | ||
87 | } | ||
88 | |||
89 | decl {\#include <convertlib.h>} {public | ||
90 | } | ||
91 | |||
92 | decl {\#include <memutils.h>} {public | ||
93 | } | ||
94 | |||
95 | decl {\#include <hd24fs.h>} {public | ||
96 | } | ||
97 | |||
98 | decl {\#include <hd24utils.h>} {public | ||
99 | } | ||
100 | |||
101 | decl {\#include <hd24transferengine.h>} {public | ||
102 | } | ||
103 | |||
104 | decl {\#include <smpte.h>} {public | ||
105 | } | ||
106 | |||
107 | decl {\#include <WidgetPDial.h>} {public | ||
108 | } | ||
109 | |||
110 | decl {\#include <dialog_newproject.h>} {public | ||
111 | } | ||
112 | |||
113 | decl {\#include <dialog_newsong.h>} {public | ||
114 | } | ||
115 | |||
116 | decl {\#include <dialog_setlocate.h>} {public | ||
117 | } | ||
118 | |||
119 | decl {\#include <dialog_filesize.h>} {public | ||
120 | } | ||
121 | |||
122 | decl {\#include <dialog_setlength.h>} {public | ||
123 | } | ||
124 | |||
125 | decl {\#include <dialog_fromto.h>} {public | ||
126 | } | ||
127 | |||
128 | decl {\#include <dialog_rename.h>} {public | ||
129 | } | ||
130 | |||
131 | decl {\#include <dialog_options.h>} {public | ||
132 | } | ||
133 | |||
134 | decl {\#include <dialog_choosedevice.h>} {public | ||
135 | } | ||
136 | |||
137 | decl {\#include <ui_help_about.h>} {public | ||
138 | } | ||
139 | |||
140 | decl {\#include <ui_mixer.h>} {public | ||
141 | } | ||
142 | |||
143 | decl {\#include <time.h>} {public | ||
144 | } | ||
145 | |||
146 | decl {\#include <math.h>} {public | ||
147 | } | ||
148 | |||
149 | decl {\#include <ui_hd24trackchannel.h>} {public | ||
150 | } | ||
151 | |||
152 | decl {\#include <ui_recorder.h>} {public | ||
153 | } | ||
154 | |||
155 | decl {class HD24UserInterface;} {public | ||
156 | } | ||
157 | |||
158 | decl {class HD24control;} {public | ||
159 | } | ||
160 | |||
161 | decl {class SoundFileWrapper;} {public | ||
162 | } | ||
163 | |||
164 | class HD24data {} { | ||
165 | decl {HD24UserInterface* parentui;} {} | ||
166 | decl {friend class HD24control;} {} | ||
167 | decl {int ready;} {public | ||
168 | } | ||
169 | } | ||
170 | |||
171 | class HD24control {} { | ||
172 | decl {HD24data* data;} {} | ||
173 | Function {parentui(HD24UserInterface* p_parentui)} {open | ||
174 | } { | ||
175 | code {data->parentui=p_parentui;} {} | ||
176 | } | ||
177 | Function {parentui()} {open return_type {HD24UserInterface*} | ||
178 | } { | ||
179 | code {return data->parentui;} {} | ||
180 | } | ||
181 | Function {HD24control()} {open | ||
182 | } { | ||
183 | code {data=new HD24data();} {} | ||
184 | } | ||
185 | Function {~HD24control()} {open | ||
186 | } { | ||
187 | code {delete data;} {} | ||
188 | } | ||
189 | Function {ready()} {open return_type int | ||
190 | } { | ||
191 | code {return data->ready;} {} | ||
192 | } | ||
193 | Function {ready(int p_ready)} {open return_type void | ||
194 | } { | ||
195 | code {data->ready=p_ready;} {} | ||
196 | } | ||
197 | } | ||
198 | |||
199 | decl {\#include <hd24sndfile.h>} {public | ||
200 | } | ||
201 | |||
202 | class HD24UserInterface {open | ||
203 | } { | ||
204 | decl {hd24transferengine* transeng;} {} | ||
205 | decl {HD24control* control;} {public | ||
206 | } | ||
207 | decl {PortAudioWrapper* portaudio;} {public | ||
208 | } | ||
209 | decl {SoundFileWrapper* soundfile;} {public | ||
210 | } | ||
211 | decl {JackWrapper* libjack;} {public | ||
212 | } | ||
213 | decl {int busy;} {public | ||
214 | } | ||
215 | decl {hd24fs* defaulthd24;} {} | ||
216 | decl {hd24fs* currenthd24;} {public | ||
217 | } | ||
218 | decl {int trackselected[24];} {public | ||
219 | } | ||
220 | decl {hd24project* currproj;} {public | ||
221 | } | ||
222 | decl {hd24song* currsong;} {public | ||
223 | } | ||
224 | decl {Fl_Check_Button* track[24];} {public | ||
225 | } | ||
226 | decl {int tracksave[24]; /* to keep track[24] settings */} {public | ||
227 | } | ||
228 | decl {vector<string> format_outputextension;} {public | ||
229 | } | ||
230 | decl {vector<string> format_shortdesc;} {public | ||
231 | } | ||
232 | Function {deactivate_ui()} {open return_type void | ||
233 | } { | ||
234 | code {drivename->deactivate(); | ||
235 | rename_drive->deactivate(); | ||
236 | projectname->deactivate(); | ||
237 | rename_project->deactivate(); | ||
238 | songname->deactivate(); | ||
239 | songinfogroup->deactivate(); | ||
240 | tabDrive->deactivate(); | ||
241 | rename_song->deactivate(); | ||
242 | locatepoints->deactivate(); | ||
243 | fromto->deactivate(); | ||
244 | transfercanvas->deactivate(); | ||
245 | menufile->deactivate(); | ||
246 | tabRecorder->deactivate(); | ||
247 | tabMixer->deactivate(); | ||
248 | menuhelp->deactivate();} {} | ||
249 | } | ||
250 | Function {disable_program_controls()} {return_type void | ||
251 | } { | ||
252 | code {drivename->deactivate(); | ||
253 | rename_drive->deactivate(); | ||
254 | projectname->deactivate(); | ||
255 | rename_project->deactivate(); | ||
256 | songname->deactivate(); | ||
257 | rename_song->deactivate(); | ||
258 | transfercanvas->deactivate(); | ||
259 | locatepoints->deactivate(); | ||
260 | fromto->deactivate(); | ||
261 | button_golocatepoint->deactivate(); | ||
262 | recorder->control->disable();} {} | ||
263 | } | ||
264 | Function {activate_ui()} {open return_type void | ||
265 | } { | ||
266 | code {drivename->activate(); | ||
267 | transfercanvas->activate(); | ||
268 | tabRecorder->activate(); | ||
269 | projectname->activate(); | ||
270 | songname->activate(); | ||
271 | songinfogroup->activate(); | ||
272 | tabDrive->activate(); | ||
273 | tabMixer->activate(); | ||
274 | locatepoints->activate(); | ||
275 | fromto->activate(); | ||
276 | menufile->activate(); | ||
277 | menuhelp->activate();} {} | ||
278 | } | ||
279 | Function {addsongtodropdown(int i)} {} { | ||
280 | code {\#if (HD24DEBUG==1) | ||
281 | cout << "addsongtodropdown " << i << endl; | ||
282 | cout << "set song" << endl; | ||
283 | \#endif | ||
284 | hd24song* song=currproj->getsong(i); | ||
285 | \#if (HD24DEBUG==1) | ||
286 | cout << "song is set" << endl; | ||
287 | \#endif | ||
288 | string* strsongname=Convert::int2str(i); | ||
289 | *strsongname+=": "; | ||
290 | string* actualname=song->songname(); | ||
291 | *strsongname+=*actualname; | ||
292 | delete actualname; | ||
293 | |||
294 | \#if (HD24DEBUG==1) | ||
295 | cout << "song is set2" << endl; | ||
296 | \#endif | ||
297 | songname->add(strsongname->c_str(),0,(void (*)(Fl_Widget*,void*))(&(songname_cb)),(void*)this); | ||
298 | \#if (HD24DEBUG==1) | ||
299 | cout << "song is set3" << endl; | ||
300 | \#endif | ||
301 | delete song; | ||
302 | delete(strsongname);} {} | ||
303 | } | ||
304 | Function {populate_projectlist(int projectid)} {return_type void | ||
305 | } { | ||
306 | code {/* Set project info */ | ||
307 | int i; | ||
308 | \#if (HD24DEBUG==1) | ||
309 | cout << "clear project list" << endl; | ||
310 | \#endif | ||
311 | for (i=0;i<=100;i++) { | ||
312 | projectname->remove(0); | ||
313 | } | ||
314 | int numprojs=0; | ||
315 | if (currenthd24==NULL) { | ||
316 | return; | ||
317 | } | ||
318 | numprojs=currenthd24->projectcount(); | ||
319 | for (i=1; i<=numprojs; i++) { | ||
320 | hd24project* currproj=currenthd24->getproject(i); | ||
321 | string* projname1=Convert::int2str(i); | ||
322 | *projname1+=": "; | ||
323 | string* currpname=currproj->projectname(); | ||
324 | *projname1+=*currpname; | ||
325 | projectname->add(projname1->c_str(),0,(void (*)(Fl_Widget*,void*))(&(projectname_cb)),(void*)this); | ||
326 | delete(currpname); | ||
327 | delete(projname1); | ||
328 | delete currproj; | ||
329 | } | ||
330 | |||
331 | select_project(projectid);} {} | ||
332 | } | ||
333 | Function {populate_songlist(int songid)} {open return_type void | ||
334 | } { | ||
335 | code {int i; | ||
336 | int numsongs=currproj->songcount(); | ||
337 | \#if (HD24DEBUG==1) | ||
338 | cout << "populate_songlist" << endl; | ||
339 | \#endif | ||
340 | if (numsongs==0) | ||
341 | { | ||
342 | \#if (HD24DEBUG==1) | ||
343 | cout << "no songs" << endl; | ||
344 | \#endif | ||
345 | for (i=0;i<=100;i++) { | ||
346 | songname->remove(0); | ||
347 | } | ||
348 | songname->add("-- Empty project --",0,NULL,(void*)this); | ||
349 | songname->value(0); | ||
350 | refresh(songname); | ||
351 | return; | ||
352 | } | ||
353 | songname->activate(); | ||
354 | \#if (HD24DEBUG==1) | ||
355 | cout << "clear songlist" << endl; | ||
356 | \#endif | ||
357 | for (i=0;i<=100;i++) { | ||
358 | songname->remove(0); | ||
359 | } | ||
360 | |||
361 | songname->add("-- All songs --",0,(void (*)(Fl_Widget*,void*))(&(songname_cb)),(void*)this); | ||
362 | |||
363 | \#if (HD24DEBUG==1) | ||
364 | cout << "Add songs to dropdown" << endl; | ||
365 | \#endif | ||
366 | for (i=1; i<=numsongs; i++) { | ||
367 | addsongtodropdown(i); | ||
368 | } | ||
369 | control->ready(1); | ||
370 | this->busy=0; | ||
371 | |||
372 | \#if (HD24DEBUG==1) | ||
373 | cout << "about to select last used song" << endl; | ||
374 | \#endif | ||
375 | signed long lastsong=currproj->lastsongid(); | ||
376 | if (lastsong<1) { | ||
377 | lastsong=0; | ||
378 | } | ||
379 | \#if (HD24DEBUG==1) | ||
380 | cout << "got last song id:" << lastsong << endl; | ||
381 | \#endif | ||
382 | if (lastsong==0) { | ||
383 | songname->value(0); | ||
384 | songname->redraw(); | ||
385 | return; | ||
386 | } | ||
387 | select_song(lastsong); | ||
388 | songname->redraw();} {} | ||
389 | } | ||
390 | Function {populate_drivelist(int driveid)} {open return_type void | ||
391 | } { | ||
392 | code {// when another drive has been selected, init dropdown lists. | ||
393 | for (unsigned int q=0;q<=99;q++) { | ||
394 | drivename->remove(0); | ||
395 | } | ||
396 | // find out how many ADAT drives are detected. | ||
397 | unsigned int devcount=defaulthd24->hd24devicecount(); | ||
398 | \#if (HD24DEBUG==1) | ||
399 | cout << "devcount=" << devcount << endl; | ||
400 | \#endif | ||
401 | unsigned int usedevcount=devcount; | ||
402 | if (devcount==0) usedevcount=1; // we are using a file image. | ||
403 | for (unsigned int devnum=0;devnum<usedevcount;devnum++) | ||
404 | { | ||
405 | \#if (HD24DEBUG==1) | ||
406 | cout << "devnum" << devnum << endl; | ||
407 | \#endif | ||
408 | // currhd24 is not a spelling error. it is for local use. | ||
409 | string* idir=hd24utils::getlastdir("driveimagedir"); | ||
410 | hd24fs* currhd24 = new hd24fs(idir->c_str(),defaulthd24->mode(),devnum); | ||
411 | delete idir; | ||
412 | if (!(currhd24->isOpen())) { | ||
413 | if (!(defaulthd24->isOpen())) { | ||
414 | disable_program_controls(); | ||
415 | } | ||
416 | } | ||
417 | \#if (HD24DEBUG==1) | ||
418 | cout << "newfs" << devnum << endl; | ||
419 | \#endif | ||
420 | |||
421 | string* drivename1=Convert::int2str(devnum+1); | ||
422 | |||
423 | *drivename1+=": "; | ||
424 | string* volname; | ||
425 | |||
426 | \#if (HD24DEBUG==1) | ||
427 | cout << "getvolname" << devnum << endl; | ||
428 | \#endif | ||
429 | |||
430 | if (devcount!=usedevcount) | ||
431 | { | ||
432 | volname=currenthd24->volumename(); | ||
433 | } else { | ||
434 | volname=currhd24->volumename(); | ||
435 | } | ||
436 | |||
437 | \#if (HD24DEBUG==1) | ||
438 | cout << "gotvolname" << devnum << endl; | ||
439 | \#endif | ||
440 | |||
441 | *drivename1+=*volname; | ||
442 | // NULL=callback | ||
443 | drivename->add(drivename1->c_str(),0,(void (*)(Fl_Widget*,void*))(&(drivename_cb)),(void*)this); | ||
444 | delete(currhd24); | ||
445 | delete(volname); | ||
446 | delete(drivename1); | ||
447 | } | ||
448 | |||
449 | /* Set drive info */ | ||
450 | \#if (HD24DEBUG==1) | ||
451 | cout << "set drivename dropdown value to " << driveid << endl; | ||
452 | \#endif | ||
453 | drivename->value(driveid);} {} | ||
454 | } | ||
455 | Function {populate_locatepoints(hd24song* locsong,Fl_Choice* lpoints)} {open return_type int | ||
456 | } { | ||
457 | code {int i; | ||
458 | int numpoints=0; | ||
459 | if (locsong!=NULL) | ||
460 | { | ||
461 | numpoints=locsong->locatepointcount(); | ||
462 | } | ||
463 | |||
464 | \#if (HD24DEBUG==1) | ||
465 | cout << "populate_lpoints" << endl; | ||
466 | \#endif | ||
467 | if (numpoints==0) | ||
468 | { | ||
469 | \#if (HD24DEBUG==1) | ||
470 | cout << "no locate points." << endl; | ||
471 | \#endif | ||
472 | for (i=0;i<=99;i++) { | ||
473 | lpoints->remove(0); | ||
474 | } | ||
475 | lpoints->deactivate(); | ||
476 | refresh(lpoints); | ||
477 | return numpoints; | ||
478 | } | ||
479 | lpoints->activate(); | ||
480 | \#if (HD24DEBUG==1) | ||
481 | cout << "clear lpoints" << endl; | ||
482 | \#endif | ||
483 | for (i=0;i<=99;i++) { | ||
484 | lpoints->remove(0); | ||
485 | } | ||
486 | for (i=0; i<numpoints+1; i++) { | ||
487 | // locatepoint (max+1) is a virtual locate point 'END'. | ||
488 | \#if (HD24DEBUG==1) | ||
489 | cout << "set locate point" << endl; | ||
490 | \#endif | ||
491 | __uint32 locatepos=locsong->getlocatepos(i); | ||
492 | \#if (HD24DEBUG==1) | ||
493 | cout << "locate pos "<<i<<" is " << locatepos << endl; | ||
494 | \#endif | ||
495 | string* locname1; | ||
496 | if ((i==0)||(i==numpoints)) { | ||
497 | locname1=locsong->getlocatename(i); | ||
498 | |||
499 | if ((locname1->length())>0) { | ||
500 | while (locname1->substr(0,1)==" ") { | ||
501 | *locname1=locname1->substr(1,locname1->length()-1); | ||
502 | } | ||
503 | while (locname1->substr(locname1->length()-1,1)==" ") { | ||
504 | *locname1=locname1->substr(0,locname1->length()-1); | ||
505 | } | ||
506 | } else { | ||
507 | *locname1+="START"; | ||
508 | } | ||
509 | *locname1+=": "; | ||
510 | if (i==numpoints) { | ||
511 | *locname1+="+"; | ||
512 | } | ||
513 | string* dur=locsong->display_duration(locatepos); | ||
514 | *locname1+=*dur; | ||
515 | delete (dur); | ||
516 | } else { | ||
517 | locname1=Convert::int2str(i,2,"0"); | ||
518 | *locname1+=": +"; | ||
519 | string* dur=locsong->display_duration(locatepos); | ||
520 | *locname1+=*dur; | ||
521 | delete (dur); | ||
522 | *locname1+=" "; | ||
523 | string* lni=locsong->getlocatename(i); | ||
524 | *locname1+=*lni; | ||
525 | delete(lni); | ||
526 | } | ||
527 | |||
528 | \#if (HD24DEBUG==1) | ||
529 | cout << "add lpoints" << endl; | ||
530 | \#endif | ||
531 | lpoints->add(locname1->c_str(),0,NULL,(void*)this); | ||
532 | delete locname1; | ||
533 | lpoints->redraw(); | ||
534 | \#if (HD24DEBUG==1) | ||
535 | cout << "added lpoints" << endl; | ||
536 | \#endif | ||
537 | } | ||
538 | |||
539 | button_setlocatepoint->activate(); | ||
540 | lpoints->value(0); | ||
541 | this->setlocbuttonlabel(0); | ||
542 | return numpoints;} {} | ||
543 | } | ||
544 | Function {init_vars()} {open return_type void | ||
545 | } { | ||
546 | code {\#if (HD24DEBUG == 1) | ||
547 | cout << "init_vars" << endl; | ||
548 | \#endif | ||
549 | //jackclient=NULL; | ||
550 | //jackmtsample=NULL; | ||
551 | currsong=NULL; | ||
552 | currproj=NULL; | ||
553 | //portaudiostream=NULL; | ||
554 | //inputParameters=new PaStreamParameters; | ||
555 | //outputParameters=new PaStreamParameters; | ||
556 | //portaudiooffset=0; | ||
557 | //pa_streamtime=0; | ||
558 | //portaudio_initialized=0; | ||
559 | //portaudio_mustloop=0; | ||
560 | //portaudio_looppos=0; | ||
561 | mustdisplaytimer=true; | ||
562 | mustdispsavemessage=false; | ||
563 | closingdown=false; | ||
564 | savemessage[0]='\\0'; | ||
565 | refreshingui=0; | ||
566 | //loopmode=0; | ||
567 | //dispwritecountdown=0; | ||
568 | init_gui(0); | ||
569 | Fl::add_timeout(TIMEOUT,poll_callback,this);} {} | ||
570 | } | ||
571 | Function {ui_refresh(const char* orig)} {open | ||
572 | } { | ||
573 | code {/* to prevent re-refresh by selecting current project | ||
574 | which will select a song which will refresh the current | ||
575 | ui again...(in case of corrupt 'unexpected end of song' | ||
576 | songs): */ | ||
577 | if (refreshingui>1) return; | ||
578 | refreshingui++; | ||
579 | |||
580 | // init dropdown lists. | ||
581 | \#if (HD24DEBUG==1) | ||
582 | cout << "==TRIGGER GUI REFRESH FROM "<<orig << "==" << endl; | ||
583 | cout << "going to clear dropdown lists" << endl; | ||
584 | \#endif | ||
585 | for (unsigned int q=0;q<=99;q++) { | ||
586 | projectname->remove(0); | ||
587 | songname->remove(0); | ||
588 | } | ||
589 | int devid=0; | ||
590 | if ((currenthd24!=NULL)&&(currenthd24!=defaulthd24)) | ||
591 | { | ||
592 | devid=currenthd24->getdeviceid(); | ||
593 | if (devid<0) | ||
594 | { | ||
595 | devid=0; | ||
596 | } | ||
597 | } | ||
598 | \#if (HD24DEBUG==1) | ||
599 | cout << "going to populate drive list (" << devid << ")" << endl; | ||
600 | \#endif | ||
601 | |||
602 | populate_drivelist(devid); | ||
603 | |||
604 | // following uses fsys (the default drive) | ||
605 | \#if (HD24DEBUG==1) | ||
606 | cout << "get projcount then?" << endl; | ||
607 | \#endif | ||
608 | string* nump=Convert::int2str(currenthd24->projectcount()); | ||
609 | \#if (HD24DEBUG==1) | ||
610 | cout << "got projcount=" << *nump << endl; | ||
611 | \#endif | ||
612 | number_of_projects->value(nump->c_str()); | ||
613 | delete (nump); | ||
614 | \#if (HD24DEBUG==1) | ||
615 | cout << "last project id=" << currenthd24->lastprojectid() << endl; | ||
616 | \#endif | ||
617 | |||
618 | populate_projectlist(currenthd24->lastprojectid()); | ||
619 | |||
620 | |||
621 | string* cat=new string(""); | ||
622 | if (hd24utils::gencatalog(this->currenthd24,cat)==0) { | ||
623 | this->catalogbuffer->remove(0,this->catalogbuffer->length()-1); | ||
624 | this->catalogbuffer->append(cat->c_str()); | ||
625 | |||
626 | // if (this->catalog->buffer()!=NULL) { | ||
627 | // free(this->catalog->buffer()); | ||
628 | // } | ||
629 | // this->catalog->buffer(cat->c_str()); | ||
630 | } | ||
631 | delete(cat); | ||
632 | \#if (HD24DEBUG==1) | ||
633 | cout << "get version" << endl; | ||
634 | \#endif | ||
635 | string* version1=currenthd24->version(); | ||
636 | \#if (HD24DEBUG==1) | ||
637 | cout << "got version" << endl; | ||
638 | \#endif | ||
639 | fsversion->value(version1->c_str()); | ||
640 | delete(version1); | ||
641 | |||
642 | calcspace(); | ||
643 | Fl::add_timeout(TIMEOUT,poll_callback,this); | ||
644 | |||
645 | refreshingui--;} {} | ||
646 | } | ||
647 | Function {init_gui(int drive)} {open return_type void | ||
648 | } { | ||
649 | code {// int drive is for multi drive support. | ||
650 | |||
651 | // deselect all tracks on ' copy to hd24 tab' | ||
652 | for (unsigned int i=1; i<=MAXCHANNELS; i++) { | ||
653 | trackselected[i-1]=0; | ||
654 | } | ||
655 | // Neither jack or portaudio were found by configure. | ||
656 | // This means no sound is available, so hide the transport controls. | ||
657 | recorder->control->disable(); | ||
658 | recorder->control->audio->mixer(this->mixer->control); | ||
659 | |||
660 | \#if (HD24DEBUG==1) | ||
661 | cout << "init_gui" << endl; | ||
662 | \#endif | ||
663 | Fl::remove_timeout(poll_callback); | ||
664 | ui_refresh("init gui"); | ||
665 | Fl::add_timeout(TIMEOUT,poll_callback,this); | ||
666 | |||
667 | populate_formats(); | ||
668 | \#if (HD24DEBUG==1) | ||
669 | cout << "formats populated" << endl; | ||
670 | \#endif | ||
671 | fromtime->value("START"); | ||
672 | totime->value("END"); | ||
673 | refresh(fromtime); | ||
674 | refresh(totime); | ||
675 | \#if (HD24DEBUG==1) | ||
676 | cout << "init gui complete" << endl; | ||
677 | \#endif | ||
678 | |||
679 | calcspace(); | ||
680 | showprogtitle(); | ||
681 | |||
682 | |||
683 | setstatus("Ready.");} {} | ||
684 | } | ||
685 | Function {drivename_cb(Fl_Widget* w, void* data)} {return_type {static void} | ||
686 | } { | ||
687 | code {\#if (HD24DEBUG==1) | ||
688 | cout << "drivename_cb" << endl; | ||
689 | \#endif | ||
690 | HD24UserInterface *o=(HD24UserInterface *)data; | ||
691 | o->drivename_callback(w,data);} {} | ||
692 | } | ||
693 | Function {drivename_callback(Fl_Widget* w, void* data)} {return_type void | ||
694 | } { | ||
695 | code {\#if (HD24DEBUG==1) | ||
696 | cout << "drivename_callback" << endl; | ||
697 | \#endif | ||
698 | int choicemade=((Fl_Choice*)(w))->value(); | ||
699 | \#if (HD24DEBUG==1) | ||
700 | cout << "chose drive " << choicemade+1 << endl; | ||
701 | \#endif | ||
702 | |||
703 | |||
704 | string* idir=hd24utils::getlastdir("driveimagedir"); | ||
705 | hd24fs* newcurrenthd=new hd24fs(idir->c_str(),defaulthd24->mode(),choicemade); | ||
706 | delete idir; | ||
707 | currenthd24=newcurrenthd; | ||
708 | |||
709 | init_gui(choicemade);} {} | ||
710 | } | ||
711 | Function {trackaction_callback(Fl_Widget* w, void* data)} {return_type void | ||
712 | } { | ||
713 | code {\#if (HD24DEBUG==1) | ||
714 | cout << "trackaction_callback" << endl; | ||
715 | \#endif | ||
716 | int choicemade=((Fl_Choice*)(w))->value(); | ||
717 | if (choicemade==0) { | ||
718 | ((Fl_Choice*)(w))->color(1); | ||
719 | } else { | ||
720 | ((Fl_Choice*)(w))->color(7); | ||
721 | } | ||
722 | \#if (HD24DEBUG==1) | ||
723 | cout << "chose item " << choicemade << endl; | ||
724 | \#endif} {} | ||
725 | } | ||
726 | Function {projectname_cb(Fl_Widget* w, void* data)} {return_type {static void} | ||
727 | } { | ||
728 | code {\#if (HD24DEBUG==1) | ||
729 | cout << "projectname_cb" << endl; | ||
730 | \#endif | ||
731 | HD24UserInterface *o=(HD24UserInterface *)data; | ||
732 | o->projectname_callback(w,data);} {} | ||
733 | } | ||
734 | Function {projectname_callback(Fl_Widget* w, void* data)} {return_type void | ||
735 | } { | ||
736 | code {\#if (HD24DEBUG==1) | ||
737 | cout << "projectname_callback" << endl; | ||
738 | \#endif | ||
739 | int choicemade=((Fl_Choice*)(w))->value(); | ||
740 | select_project(choicemade+1);} {} | ||
741 | } | ||
742 | Function {songname_cb(Fl_Widget* w, void* data)} {open return_type {static void} | ||
743 | } { | ||
744 | code {\#if (HD24DEBUG == 1 ) | ||
745 | cout << "songname_cb" << endl; | ||
746 | \#endif | ||
747 | HD24UserInterface *o=(HD24UserInterface *)data; | ||
748 | o->songname_callback(w,data);} {} | ||
749 | } | ||
750 | Function {songname_callback(Fl_Widget* w, void* data)} {open return_type void | ||
751 | } { | ||
752 | code {\#if (HD24DEBUG==1) | ||
753 | cout << "songname_callback" << endl; | ||
754 | \#endif | ||
755 | int choicemade=((Fl_Choice*)(w))->value(); | ||
756 | if (currproj!=NULL) delete currproj; | ||
757 | currproj=currenthd24->getproject(projectname->value()+1); | ||
758 | //songname->value(choicemade); // should not be needed | ||
759 | select_song(choicemade); // song id=choicemade} {} | ||
760 | } | ||
761 | Function {refresh(Fl_Widget * w)} {open return_type void | ||
762 | } { | ||
763 | code {w->deactivate(); | ||
764 | w->activate();} {} | ||
765 | } | ||
766 | decl {time_t starttime,endtime} {} | ||
767 | Function {calcspace()} {return_type void | ||
768 | } { | ||
769 | code {__uint32 rate; | ||
770 | __uint32 tracks; | ||
771 | |||
772 | switch (atrate->value()) { | ||
773 | case 0: rate=44100; break; | ||
774 | case 1: rate=48000; break; | ||
775 | case 2: rate=88200; break; | ||
776 | case 3: rate=96000; break; | ||
777 | default: return; | ||
778 | } | ||
779 | switch (attracks->value()) { | ||
780 | case 0: tracks=2; break; | ||
781 | case 1: tracks=6; break; | ||
782 | case 2: tracks=8; break; | ||
783 | case 3: tracks=12; break; | ||
784 | case 4: tracks=16; break; | ||
785 | case 5: tracks=24; break; | ||
786 | default: return; | ||
787 | } | ||
788 | string* strfree=currenthd24->freespace(rate,tracks); | ||
789 | freespace->value(strfree->c_str()); | ||
790 | delete (strfree);} {} | ||
791 | } | ||
792 | Function {transferstatus(void* ui,const char* message,double pct)} {open return_type {static void} | ||
793 | } { | ||
794 | code {if (ui==NULL) return; | ||
795 | ((HD24UserInterface*)ui)->statusmsg->value(message); | ||
796 | ((HD24UserInterface*)ui)->fl_check();} {} | ||
797 | } | ||
798 | Function {setstatus(string message)} {open return_type void | ||
799 | } { | ||
800 | code {statusmsg->value(message.c_str()); | ||
801 | fl_check();} {} | ||
802 | } | ||
803 | decl {/* ===File transfer stuff ===================================================== */} {} | ||
804 | decl {Fl_Widget* trackaction[24];} {public | ||
805 | } | ||
806 | decl {int transfer_cancel;} {public | ||
807 | } | ||
808 | decl {Fl_Output* filename[24];} {public | ||
809 | } | ||
810 | Function {savemessage_callback(void* user)} {open return_type {static void} | ||
811 | } { | ||
812 | code {HD24UserInterface* mythis=(HD24UserInterface*)user; | ||
813 | string* stat=new string(mythis->savemessage); | ||
814 | mythis->setstatus(*stat); | ||
815 | //mythis->uicanvas->redraw(); | ||
816 | mythis->statusbar->damage(); | ||
817 | mythis->statusbar->redraw(); | ||
818 | |||
819 | delete (stat); | ||
820 | if (mythis->mustdispsavemessage) { | ||
821 | Fl::repeat_timeout(.25,savemessage_callback,user); | ||
822 | }} {} | ||
823 | } | ||
824 | Function {countfiletracks(const char* filename)} {open return_type int | ||
825 | } { | ||
826 | code {SF_INFO sfinfo; | ||
827 | SNDFILE* infile=NULL; | ||
828 | if (strlen(filename)==0) | ||
829 | { | ||
830 | return 0; | ||
831 | } | ||
832 | infile=soundfile->sf_open(filename,SFM_READ,&sfinfo); | ||
833 | if (!infile) | ||
834 | { | ||
835 | return 0; | ||
836 | } | ||
837 | int numchans=sfinfo.channels; | ||
838 | soundfile->sf_close(infile); | ||
839 | return numchans;} {} | ||
840 | } | ||
841 | decl {char savemessage[300];} {public | ||
842 | } | ||
843 | Function {populate_trackaction(HD24UserInterface* ui,Fl_Widget* o,int tracknum)} {open return_type void | ||
844 | } { | ||
845 | code {if (tracknum<1) { | ||
846 | return; | ||
847 | } | ||
848 | if (tracknum>24) { | ||
849 | return; | ||
850 | } | ||
851 | |||
852 | trackaction[tracknum-1]=o; | ||
853 | |||
854 | ((Fl_Choice*)o)->clear(); | ||
855 | ((Fl_Choice*)o)->add("Erase",0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
856 | ((Fl_Choice*)o)->add("SMPTE",0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
857 | ((Fl_Choice*)o)->add("Mono",0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
858 | // count number of tracks in file given by filename | ||
859 | // when >1, for each track add a line. | ||
860 | int numtracks=countfiletracks(filename[tracknum-1]->value()); | ||
861 | if (numtracks>1) { | ||
862 | for (int i=1; i<=numtracks; i++) { | ||
863 | string strtrack="Tr."; | ||
864 | string* strnum=Convert::int2str(i); | ||
865 | strtrack+=*strnum; | ||
866 | ((Fl_Choice*)o)->add(strtrack.c_str(),0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
867 | delete strnum; | ||
868 | } | ||
869 | } | ||
870 | ((Fl_Choice*)o)->value(2); // default 0=erase, 1=SMPTE, 2=mono | ||
871 | ((Fl_Choice*)o)->redraw(); | ||
872 | fl_check();} {} | ||
873 | } | ||
874 | Function {populate_trackactionbyfile(__uint32 slotnum,int trackchoice)} {open return_type void | ||
875 | } { | ||
876 | code {if (slotnum<0) return; | ||
877 | if (slotnum>23) return; | ||
878 | |||
879 | Fl_Choice* o=(Fl_Choice*)trackaction[slotnum]; | ||
880 | if (o==NULL) return; | ||
881 | for (unsigned int i=0;i<128;i++) { o->remove(0); } | ||
882 | o->add("Erase",0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
883 | o->add("SMPTE",0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
884 | o->add("Mono",0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
885 | // count number of tracks in file given by filename | ||
886 | // when >1, for each track add a line. | ||
887 | int numtracks=countfiletracks(filename[slotnum]->value()); | ||
888 | if (numtracks>1) { | ||
889 | for (int i=1; i<=numtracks; i++) { | ||
890 | string strtrack="Tr."; | ||
891 | string* strnum=Convert::int2str(i); | ||
892 | strtrack+=*strnum; | ||
893 | o->add(strtrack.c_str(),0,(void (*)(Fl_Widget*,void*))(&(trackaction_cb)),(void*)this); | ||
894 | delete strnum; | ||
895 | } | ||
896 | } | ||
897 | o->value(trackchoice); | ||
898 | trackaction_callback(o,NULL); | ||
899 | o->redraw(); | ||
900 | |||
901 | fl_check();} {} | ||
902 | } | ||
903 | Function {moveselected(__sint32 direction)} {open return_type void | ||
904 | } { | ||
905 | code {__uint32 firsttrack=0; | ||
906 | __uint32 lasttrack=0; | ||
907 | if (currsong==NULL) | ||
908 | { | ||
909 | return; | ||
910 | } | ||
911 | if (direction==-1) | ||
912 | { | ||
913 | firsttrack=1; | ||
914 | lasttrack=currsong->logical_channels(); | ||
915 | if (trackselected[0]==1) | ||
916 | { | ||
917 | // move up, but first track is selected | ||
918 | // and already upper choice- cannot move up | ||
919 | return; | ||
920 | } | ||
921 | } | ||
922 | else | ||
923 | { | ||
924 | if (direction==1) | ||
925 | { | ||
926 | lasttrack=1; | ||
927 | firsttrack=currsong->logical_channels(); | ||
928 | |||
929 | if (trackselected[currsong->logical_channels()-1]==1) | ||
930 | { | ||
931 | return; | ||
932 | } | ||
933 | } | ||
934 | } | ||
935 | // we need to move stuff. | ||
936 | if (firsttrack==0) return; // direction==0, don't move. | ||
937 | |||
938 | __uint32 tracknum=firsttrack; | ||
939 | while (tracknum!=lasttrack) | ||
940 | { | ||
941 | if (trackselected[tracknum-1]!=trackselected[tracknum-1-direction]) | ||
942 | { | ||
943 | int dummy=trackselected[tracknum-1]; | ||
944 | string* trackval=new string(filename[tracknum-1]->value()); | ||
945 | |||
946 | trackselected[tracknum-1]=trackselected[tracknum-1-direction]; | ||
947 | trackselected[tracknum-1-direction]=dummy; | ||
948 | |||
949 | int a=((Fl_Choice*)(trackaction[tracknum-1]))->value(); | ||
950 | int b=((Fl_Choice*)(trackaction[tracknum-1-direction]))->value(); | ||
951 | |||
952 | filename[tracknum-1]->value(filename[tracknum-1-direction]->value()); | ||
953 | filename[tracknum-1-direction]->value(trackval->c_str()); | ||
954 | |||
955 | populate_trackactionbyfile(tracknum-1,b); | ||
956 | populate_trackactionbyfile(tracknum-1-direction,a); | ||
957 | |||
958 | delete trackval; | ||
959 | } | ||
960 | tracknum-=direction; | ||
961 | } | ||
962 | |||
963 | redrawtracks();} {} | ||
964 | } | ||
965 | Function {trackaction_cb(Fl_Widget* w, void* data)} {open return_type {static void} | ||
966 | } { | ||
967 | code {\#if (HD24DEBUG==1) | ||
968 | cout << "trackaction_cb" << endl; | ||
969 | \#endif | ||
970 | HD24UserInterface *o=(HD24UserInterface *)data; | ||
971 | o->trackaction_callback(w,data);} {} | ||
972 | } | ||
973 | Function {redrawtracks()} {open return_type void | ||
974 | } { | ||
975 | code {bool track_active; | ||
976 | if (currsong==NULL) { | ||
977 | return; | ||
978 | } | ||
979 | |||
980 | for (unsigned int tracknum=1;tracknum<=MAXCHANNELS;tracknum++) | ||
981 | { | ||
982 | if (currsong->logical_channels()>=tracknum) { | ||
983 | track_active=true; | ||
984 | filename[tracknum-1]->activate(); | ||
985 | } else { | ||
986 | track_active=false; | ||
987 | ((Fl_Output*)filename[tracknum-1])->color(7); | ||
988 | filename[tracknum-1]->deactivate(); | ||
989 | } | ||
990 | |||
991 | if (track_active) { | ||
992 | if (trackselected[tracknum-1]==1) { | ||
993 | ((Fl_Output*)filename[tracknum-1])->color(3); | ||
994 | } else { | ||
995 | ((Fl_Output*)filename[tracknum-1])->color(7); | ||
996 | } | ||
997 | } | ||
998 | |||
999 | ((Fl_Output*)filename[tracknum-1])->redraw(); | ||
1000 | }} {} | ||
1001 | } | ||
1002 | decl {/* ===UI stuff ===================================================== */} {} | ||
1003 | Function {populate_formats()} {open return_type void | ||
1004 | } { | ||
1005 | code {\#if (HD24DEBUG==1) | ||
1006 | cout << "populate_formats" << endl; | ||
1007 | \#endif | ||
1008 | |||
1009 | for (int i=0;i<transeng->supportedformatcount();i++) | ||
1010 | { | ||
1011 | fileformat->add(transeng->getformatdesc(i),0,NULL,(void*)this); | ||
1012 | } | ||
1013 | fileformat->value(0);} {} | ||
1014 | } | ||
1015 | Function {selectfilename(int tracknum)} {return_type void | ||
1016 | } { | ||
1017 | code {this->trackselected[tracknum-1]=1-this->trackselected[tracknum-1]; | ||
1018 | if (this->trackselected[tracknum-1]==1) { | ||
1019 | this->filename[tracknum-1]->color(3); | ||
1020 | } else { | ||
1021 | this->filename[tracknum-1]->color(7); | ||
1022 | } | ||
1023 | this->filename[tracknum-1]->redraw();} {} | ||
1024 | } | ||
1025 | Function {select_project(int projectid)} {open return_type void | ||
1026 | } { | ||
1027 | code {if (currproj!=NULL) { | ||
1028 | if (currsong!=NULL) | ||
1029 | { | ||
1030 | hd24song* tmpsong=currsong; | ||
1031 | currsong=NULL; | ||
1032 | delete tmpsong; | ||
1033 | } | ||
1034 | hd24project* tmpproj=currproj; | ||
1035 | currproj=NULL; | ||
1036 | delete tmpproj; | ||
1037 | } | ||
1038 | currproj=currenthd24->getproject(projectid); | ||
1039 | \#if (HD24DEBUG==1) | ||
1040 | cout << "select_project \#" << projectid << endl; | ||
1041 | \#endif | ||
1042 | currenthd24->lastprojectid(projectid); | ||
1043 | projectname->value(projectid-1); /* project id is 1-based */ | ||
1044 | int currsongcount=0; | ||
1045 | if (currproj==NULL) | ||
1046 | { | ||
1047 | delete_project->deactivate(); | ||
1048 | } | ||
1049 | else | ||
1050 | { | ||
1051 | delete_project->activate(); | ||
1052 | currsongcount=currproj->songcount(); | ||
1053 | } | ||
1054 | |||
1055 | if (currsongcount==0) | ||
1056 | { | ||
1057 | number_of_songs->value("0"); | ||
1058 | populate_songlist(0); // shows -- EMPTY PROJECT -- | ||
1059 | select_song(0); | ||
1060 | return; | ||
1061 | } | ||
1062 | |||
1063 | // currproj is defined at this point. | ||
1064 | |||
1065 | string* nums=Convert::int2str(currproj->songcount()); | ||
1066 | number_of_songs->value(nums->c_str()); | ||
1067 | \#if (HD24DEBUG==1) | ||
1068 | cout << "number of songs=" << currproj->songcount() << endl; | ||
1069 | \#endif | ||
1070 | delete(nums); | ||
1071 | |||
1072 | int lastsongid=currproj->lastsongid(); | ||
1073 | \#if (HD24DEBUG==1) | ||
1074 | cout << "lastsongid=" << lastsongid << endl; | ||
1075 | \#endif | ||
1076 | populate_songlist(lastsongid);} {} | ||
1077 | } | ||
1078 | Function {select_song(int songid)} {open return_type void | ||
1079 | } { | ||
1080 | code {unsigned int i; | ||
1081 | button_setlocatepoint->deactivate(); | ||
1082 | \#if (HD24DEBUG==1) | ||
1083 | cout << "select_song \#" << songid << endl; | ||
1084 | \#endif | ||
1085 | |||
1086 | |||
1087 | |||
1088 | if (songid==0) { | ||
1089 | |||
1090 | // This represents the choice "all songs" | ||
1091 | if (currsong!=NULL) { | ||
1092 | hd24song* tmpsong=currsong; | ||
1093 | currsong=NULL; | ||
1094 | delete tmpsong; | ||
1095 | } | ||
1096 | transfersource->value("(All songs in the current project)"); | ||
1097 | if (number_of_tracks==NULL) | ||
1098 | { | ||
1099 | return; // ui not yet initialized? | ||
1100 | } | ||
1101 | tab_tohd24->deactivate(); | ||
1102 | rename_song->deactivate(); | ||
1103 | delete_song->deactivate(); | ||
1104 | number_of_tracks->value(""); | ||
1105 | number_of_tracks->deactivate(); | ||
1106 | sample_rate->value(""); | ||
1107 | sample_rate->deactivate(); | ||
1108 | bitdepth->value(""); | ||
1109 | bitdepth->deactivate(); | ||
1110 | duration->value(""); | ||
1111 | duration->deactivate(); | ||
1112 | //refresh (songname); | ||
1113 | for (i=0; i<MAXCHANNELS;i++) { | ||
1114 | track[i]->deactivate(); | ||
1115 | track[i]->value(1); | ||
1116 | track[i]->show(); | ||
1117 | } | ||
1118 | button_setlocatepoint->deactivate(); | ||
1119 | button_golocatepoint->deactivate(); | ||
1120 | button_invert_tracks->deactivate(); | ||
1121 | choice_startloc=0; // use default | ||
1122 | // disable locatepoint dropdown: | ||
1123 | choice_endloc=populate_locatepoints(currsong,locatepoints); | ||
1124 | choice_endloc=0; | ||
1125 | update_fromto(); | ||
1126 | fromto->deactivate(); | ||
1127 | refresh (tab_tohd24); | ||
1128 | return; | ||
1129 | |||
1130 | } else { | ||
1131 | \#if (HD24DEBUG==1) | ||
1132 | cout << "activate buttons" << endl; | ||
1133 | \#endif | ||
1134 | delete_song->activate(); | ||
1135 | rename_song->activate(); | ||
1136 | tab_tohd24->activate(); | ||
1137 | button_golocatepoint->activate(); | ||
1138 | button_setlocatepoint->activate(); | ||
1139 | button_invert_tracks->activate(); | ||
1140 | rename_song->activate(); | ||
1141 | sample_rate->activate(); | ||
1142 | bitdepth->activate(); | ||
1143 | duration->activate(); | ||
1144 | refresh (rename_song); | ||
1145 | refresh (number_of_tracks); | ||
1146 | refresh (sample_rate); | ||
1147 | refresh (bitdepth); | ||
1148 | refresh (duration); | ||
1149 | refresh (tab_tohd24); | ||
1150 | \#if (HD24DEBUG==1) | ||
1151 | cout << "deselect old song" << endl; | ||
1152 | \#endif | ||
1153 | if (currsong!=NULL) { | ||
1154 | recorder->control->song(NULL); /* tell recorder that the song is gone */ | ||
1155 | delete currsong; | ||
1156 | currsong=NULL; | ||
1157 | } | ||
1158 | \#if (HD24DEBUG==1) | ||
1159 | cout << "currprojgetsong" << endl; | ||
1160 | \#endif | ||
1161 | currsong=currproj->getsong(songid); | ||
1162 | currproj->lastsongid(songid); | ||
1163 | if (currsong->has_unexpected_end()) { | ||
1164 | if (currsong->is_fixable_unexpected_end()) { | ||
1165 | song_messages->value("Unexpected end of song.\\nTrying to find the rest of the audio..."); | ||
1166 | // currenthd24->dumpclusterusage2(currenthd24->findorphanclusters()); | ||
1167 | unsigned char* orphans=currenthd24->findorphanclusters(); | ||
1168 | if (orphans != NULL) { | ||
1169 | currsong->appendorphanclusters(orphans,true /*allowsongresize*/); | ||
1170 | song_messages->value( | ||
1171 | "Unexpected end of song. I think I found back the rest of it.\\n" | ||
1172 | "However, you really should backup all audio and reformat this drive."); | ||
1173 | if (currenthd24->getmaintenancemode()==1) { | ||
1174 | if (confirm("Song was recovered. Do you wish to save the changes?\\nAnswer Yes only if you have verified that the audio is OK)")) { | ||
1175 | currsong->save(); | ||
1176 | } | ||
1177 | } | ||
1178 | } | ||
1179 | } | ||
1180 | else | ||
1181 | { | ||
1182 | ui_refresh("selectsong"); | ||
1183 | song_messages->value("Unexpected end of song.\\nHD24tools can not automatically fix this specific occurence."); | ||
1184 | } | ||
1185 | } else { | ||
1186 | song_messages->value("No messages."); | ||
1187 | } | ||
1188 | } | ||
1189 | |||
1190 | |||
1191 | \#if (HD24DEBUG==1) | ||
1192 | cout << "songname->value" << endl; | ||
1193 | \#endif | ||
1194 | |||
1195 | songname->value(songid); // entry 0=all songs, 1=song id 1 | ||
1196 | string* dummy=currsong->songname(); | ||
1197 | transfersource->value(dummy->c_str()); | ||
1198 | |||
1199 | /* This should al be done by the recorder.... | ||
1200 | string disp="S"; | ||
1201 | string* idstr=Convert::int2str(songid,2,"0"); | ||
1202 | disp+=*idstr; | ||
1203 | delete idstr; | ||
1204 | disp+=":\\""; | ||
1205 | string* dummy=currsong->songname(); | ||
1206 | transfersource->value(dummy->c_str()); | ||
1207 | string* dummy2=Convert::readstring((unsigned char*)dummy->c_str(),0,10); | ||
1208 | string* dummy3=Convert::readstring((unsigned char*)dummy->c_str(),0,11); | ||
1209 | |||
1210 | disp+=*dummy2; | ||
1211 | delete dummy; | ||
1212 | delete dummy2; | ||
1213 | if (dummy3->length()>10) | ||
1214 | { | ||
1215 | disp+="\\4"; // arrow right | ||
1216 | } else { | ||
1217 | disp+="\\""; | ||
1218 | } | ||
1219 | delete dummy3; | ||
1220 | string* disp2=Convert::padright(disp,16," "); | ||
1221 | |||
1222 | string* dur=currsong->display_duration(); | ||
1223 | |||
1224 | *disp2+=dur->substr(0,8); | ||
1225 | *disp2+=":"; | ||
1226 | *disp2+=dur->substr(9,2); | ||
1227 | *disp2+=" "; | ||
1228 | if (currsong->iswriteprotected()) | ||
1229 | { | ||
1230 | *disp2+="\\1"; | ||
1231 | } else { | ||
1232 | *disp2+="\\2"; | ||
1233 | } | ||
1234 | string* strtracksb=Convert::int2str(currsong->logical_channels(),2,"0"); | ||
1235 | *disp2+=*strtracksb; | ||
1236 | delete strtracksb; | ||
1237 | *disp2+="t"; | ||
1238 | |||
1239 | recorder->control->dispwrite(0,disp2->c_str()); | ||
1240 | delete disp2; | ||
1241 | ............. until this point */ | ||
1242 | recorder->control->song(currsong); /* load song into recorder */ | ||
1243 | |||
1244 | redrawtracks(); // enable/disable tracks for export to HD24 | ||
1245 | string* strtracks=Convert::int2str(currsong->logical_channels()); | ||
1246 | number_of_tracks->value(strtracks->c_str()); | ||
1247 | number_of_tracks->activate(); | ||
1248 | delete (strtracks); | ||
1249 | string* samrat=Convert::int2str(currsong->samplerate()); | ||
1250 | sample_rate->value(samrat->c_str()); | ||
1251 | sample_rate->activate(); | ||
1252 | delete samrat; | ||
1253 | if (mixer!=NULL) { | ||
1254 | mixer->control->samplerate(this->samplerate()); | ||
1255 | } | ||
1256 | |||
1257 | string* bitd=Convert::int2str(currsong->bitdepth()); | ||
1258 | bitdepth->value(bitd->c_str()); | ||
1259 | bitdepth->activate(); | ||
1260 | delete(bitd); | ||
1261 | |||
1262 | string* dur=currsong->display_duration(); | ||
1263 | duration->value(dur->c_str()); | ||
1264 | duration->activate(); | ||
1265 | delete(dur); | ||
1266 | |||
1267 | if (currsong->iswriteprotected()) { | ||
1268 | writeprotected->value(1); | ||
1269 | } else { | ||
1270 | writeprotected->value(0); | ||
1271 | } | ||
1272 | |||
1273 | refresh (songname); | ||
1274 | refresh (number_of_tracks); | ||
1275 | refresh (sample_rate); | ||
1276 | refresh (bitdepth); | ||
1277 | refresh (duration); | ||
1278 | refresh (writeprotected);// writeprotected->deactivate(); | ||
1279 | |||
1280 | for (i=0; i<currsong->logical_channels();i++) { | ||
1281 | track[i]->activate(); | ||
1282 | track[i]->show(); | ||
1283 | trackled[i]->show(); | ||
1284 | } | ||
1285 | for (i=currsong->logical_channels();i<MAXCHANNELS;i++) { | ||
1286 | track[i]->deactivate(); | ||
1287 | track[i]->hide(); | ||
1288 | trackled[i]->hide(); | ||
1289 | } | ||
1290 | |||
1291 | choice_startloc=0; // use default | ||
1292 | choice_endloc=populate_locatepoints(currsong,locatepoints); | ||
1293 | button_golocatepoint->activate(); | ||
1294 | if (choice_endloc>0) { | ||
1295 | fromto->activate(); | ||
1296 | } | ||
1297 | update_fromto();} {} | ||
1298 | } | ||
1299 | decl {int choice_startloc;} {} | ||
1300 | decl {int choice_endloc;} {} | ||
1301 | decl {bool mustdispsavemessage;} {public | ||
1302 | } | ||
1303 | decl {int loopmode;} {public | ||
1304 | } | ||
1305 | decl {int uiredrawcount; /* to limit refreshing UI */} {public | ||
1306 | } | ||
1307 | Function {update_fromto()} {return_type void | ||
1308 | } { | ||
1309 | code {if (currsong==NULL) | ||
1310 | { | ||
1311 | fromtime->value("START"); | ||
1312 | totime->value("END"); | ||
1313 | return; | ||
1314 | } | ||
1315 | string* dummy1=currsong->getlocatename(choice_startloc); | ||
1316 | string* dummy2=currsong->getlocatename(choice_endloc); | ||
1317 | string* strfrom=Convert::trim(dummy1); | ||
1318 | string* strto=Convert::trim(dummy2); | ||
1319 | |||
1320 | |||
1321 | fromtime->value(strfrom->c_str()); | ||
1322 | totime->value(strto->c_str()); | ||
1323 | delete(dummy1); | ||
1324 | delete(dummy2); | ||
1325 | delete (strfrom); | ||
1326 | delete (strto);} {} | ||
1327 | } | ||
1328 | Function {make_window(hd24fs* p_fsys) /* <------------------------------------------- */} {open | ||
1329 | } { | ||
1330 | Fl_Window {} { | ||
1331 | label HD24connect open | ||
1332 | xywh {485 44 605 530} type Double color 52 align 5 | ||
1333 | code0 {defaulthd24=p_fsys;} | ||
1334 | code1 {currenthd24=p_fsys; // current and default to allow multi drive support} | ||
1335 | code2 {init_vars();} visible | ||
1336 | } { | ||
1337 | Fl_Group {} {open | ||
1338 | xywh {-5 0 1720 540} | ||
1339 | } { | ||
1340 | Fl_Group menucanvas {open | ||
1341 | xywh {0 0 640 24} | ||
1342 | } { | ||
1343 | Fl_Menu_Bar {} {open | ||
1344 | xywh {0 0 640 24} color 52 | ||
1345 | } { | ||
1346 | Submenu menufile { | ||
1347 | label {&File} open | ||
1348 | xywh {0 0 100 20} labelsize 12 | ||
1349 | } { | ||
1350 | MenuItem {} { | ||
1351 | label {&Detect HD24 drives} | ||
1352 | callback {if (currenthd24!=NULL) { | ||
1353 | delete currenthd24; | ||
1354 | currenthd24=NULL; | ||
1355 | } | ||
1356 | |||
1357 | string* idir=hd24utils::getlastdir("driveimagedir"); | ||
1358 | currenthd24=new hd24fs(idir->c_str(),hd24fs::MODE_RDWR); | ||
1359 | delete idir; | ||
1360 | defaulthd24=currenthd24; | ||
1361 | if (!(currenthd24->isOpen())) | ||
1362 | { | ||
1363 | fl_message("Sorry, during detection no valid HD24 drive was found connected to the system.\\nPlease switch on and connect the drive, or try another File menu option."); | ||
1364 | } | ||
1365 | ui_restart();} | ||
1366 | xywh {0 0 34 21} labelsize 12 divider | ||
1367 | } | ||
1368 | MenuItem {} { | ||
1369 | label {&Open drive image...} | ||
1370 | callback {string* driveimgdir=hd24utils::getlastdir("driveimagedir"); | ||
1371 | |||
1372 | Fl_Native_File_Chooser chooser; | ||
1373 | chooser.directory(driveimgdir->c_str()); | ||
1374 | delete driveimgdir; | ||
1375 | chooser.title("Select HD24 drive image\\0"); | ||
1376 | chooser.type(Fl_Native_File_Chooser::BROWSE_FILE); | ||
1377 | chooser.filter("Drive Images\\t*.{img,bin,h24,hd24}\\0"); | ||
1378 | //chooser.preview(0); | ||
1379 | switch (chooser.show()) { | ||
1380 | case -1: break; //error | ||
1381 | case 1: break; //cancel | ||
1382 | default: | ||
1383 | if (chooser.filename()) { | ||
1384 | string* cfilename=new string(chooser.filename()); | ||
1385 | |||
1386 | //cout << "filename = " << *strfile << endl; | ||
1387 | string* fpath=new string(""); | ||
1388 | *fpath+=cfilename->substr(0,strlen(cfilename->c_str())-strlen(fl_filename_name(cfilename->c_str()))); | ||
1389 | hd24utils::setlastdir("driveimagedir",fpath->c_str()); | ||
1390 | |||
1391 | hd24fs* sysob=new hd24fs(fpath->c_str(),hd24fs::MODE_RDWR,cfilename,false); | ||
1392 | delete cfilename; | ||
1393 | if (currenthd24!=NULL) | ||
1394 | { | ||
1395 | currenthd24->~hd24fs(); | ||
1396 | } | ||
1397 | if (defaulthd24!=NULL) | ||
1398 | { | ||
1399 | if (defaulthd24!=currenthd24) | ||
1400 | { | ||
1401 | defaulthd24->~hd24fs(); | ||
1402 | } | ||
1403 | } | ||
1404 | currenthd24=sysob; | ||
1405 | defaulthd24=sysob; | ||
1406 | |||
1407 | if (!(currenthd24->isOpen())) | ||
1408 | { | ||
1409 | bool choice=confirm( | ||
1410 | "File does not appear to be a valid HD24 device image.\\nDo you want to try using it anyway?\\nWarning: Choosing 'Yes' may result in\\ncrashes and other unpredictable behavior." | ||
1411 | ); | ||
1412 | |||
1413 | if (choice) { | ||
1414 | if (sysob!=NULL) { | ||
1415 | delete (sysob); | ||
1416 | } | ||
1417 | bool wantheader=confirm("Do you want to load a header file?"); | ||
1418 | |||
1419 | cfilename=new string(chooser.filename()); | ||
1420 | string* idir=hd24utils::getlastdir("driveimagedir"); | ||
1421 | sysob=new hd24fs(idir->c_str(),hd24fs::MODE_RDWR,cfilename,true); //force | ||
1422 | delete idir; | ||
1423 | delete cfilename; | ||
1424 | if (currenthd24!=NULL) | ||
1425 | { | ||
1426 | currenthd24->~hd24fs(); | ||
1427 | } | ||
1428 | if (defaulthd24!=NULL) | ||
1429 | { | ||
1430 | if (defaulthd24!=currenthd24) | ||
1431 | { | ||
1432 | defaulthd24->~hd24fs(); | ||
1433 | } | ||
1434 | |||
1435 | } | ||
1436 | |||
1437 | currenthd24=sysob; | ||
1438 | defaulthd24=sysob; | ||
1439 | if (currenthd24->isOpen()) { | ||
1440 | if (wantheader) { | ||
1441 | loadheaderfile(); | ||
1442 | } | ||
1443 | ui_restart(); | ||
1444 | return; | ||
1445 | } | ||
1446 | fl_message("Cannot open HD24 device image."); | ||
1447 | } | ||
1448 | |||
1449 | return; | ||
1450 | } | ||
1451 | ui_restart(); | ||
1452 | } | ||
1453 | break; | ||
1454 | }} | ||
1455 | xywh {0 0 34 21} labelsize 12 | ||
1456 | } | ||
1457 | MenuItem {} { | ||
1458 | label {&Save drive image...} | ||
1459 | callback {string* driveimgdir=new string(""); | ||
1460 | *driveimgdir+=*hd24utils::getlastdir("driveimagedir"); | ||
1461 | |||
1462 | Fl_Native_File_Chooser chooser; | ||
1463 | chooser.filter("Drive Images\\t*.{img,bin,h24,hd24}\\0"); | ||
1464 | chooser.title("Export full drive image file"); | ||
1465 | chooser.directory(driveimgdir->c_str()); | ||
1466 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
1467 | chooser.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); | ||
1468 | |||
1469 | switch (chooser.show()) { | ||
1470 | case -1: break; //error | ||
1471 | case 1: break; //cancel | ||
1472 | default: | ||
1473 | // save header to chooser.filename() | ||
1474 | |||
1475 | bool bFileexists=hd24utils::fileExists(chooser.filename()); | ||
1476 | if (bFileexists) { | ||
1477 | bool choice=confirm( | ||
1478 | "A file with this name already exists. Do you wish to overwrite it?" | ||
1479 | ); | ||
1480 | if (!(choice)) return; | ||
1481 | } | ||
1482 | string* strfile=new string(chooser.filename()); | ||
1483 | //cout << "filename = " << *strfile << endl; | ||
1484 | string* fpath=new string(""); | ||
1485 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
1486 | hd24utils::setlastdir("driveimagedir",fpath->c_str()); | ||
1487 | this->transfer_cancel=0; | ||
1488 | this->mustdispsavemessage=true; | ||
1489 | Fl::add_timeout(.25,savemessage_callback,this); | ||
1490 | int result=hd24utils::savedriveimage(currenthd24,strfile,&this->savemessage[0],&this->transfer_cancel); | ||
1491 | delete strfile; | ||
1492 | if (result==0) { | ||
1493 | fl_message("Drive image created successfully."); | ||
1494 | setstatus("Done."); | ||
1495 | } else { | ||
1496 | fl_message("Could not write drive image to file. Access denied? Disk full?"); | ||
1497 | } | ||
1498 | this->mustdispsavemessage=false; | ||
1499 | break; | ||
1500 | } | ||
1501 | delete driveimgdir;} | ||
1502 | xywh {10 10 34 21} labelsize 12 | ||
1503 | } | ||
1504 | Submenu {} { | ||
1505 | label {&Catalog} open | ||
1506 | xywh {0 0 70 21} labelsize 12 | ||
1507 | } { | ||
1508 | MenuItem {} { | ||
1509 | label {&Export catalog...} | ||
1510 | callback {string* catdir=new string(""); | ||
1511 | *catdir+=*hd24utils::getlastdir("catalogdir"); | ||
1512 | |||
1513 | Fl_Native_File_Chooser chooser; | ||
1514 | chooser.filter("Text files\\t*.txt"); | ||
1515 | chooser.title("Export disk catalog to file"); | ||
1516 | chooser.directory(catdir->c_str()); | ||
1517 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
1518 | chooser.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); | ||
1519 | |||
1520 | switch (chooser.show()) { | ||
1521 | case -1: break; //error | ||
1522 | case 1: break; //cancel | ||
1523 | default: | ||
1524 | // save header to chooser.filename() | ||
1525 | |||
1526 | bool bFileexists=hd24utils::fileExists(chooser.filename()); | ||
1527 | if (bFileexists) { | ||
1528 | bool choice=confirm( | ||
1529 | "A file with this name already exists. Do you wish to overwrite it?" | ||
1530 | ); | ||
1531 | if (!(choice)) return; | ||
1532 | } | ||
1533 | string* strfile=new string(chooser.filename()); | ||
1534 | //cout << "filename = " << *strfile << endl; | ||
1535 | string* fpath=new string(""); | ||
1536 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
1537 | hd24utils::setlastdir("catalogdir",fpath->c_str()); | ||
1538 | string* anyerrors=hd24utils::savecatalog(currenthd24,strfile); | ||
1539 | delete strfile; | ||
1540 | if (anyerrors==NULL) { | ||
1541 | fl_message("Catalog file created successfully."); | ||
1542 | } else { | ||
1543 | delete anyerrors; | ||
1544 | fl_message("Could not write catalog file. Access denied? Disk full?"); | ||
1545 | } | ||
1546 | break; | ||
1547 | } | ||
1548 | delete catdir;} | ||
1549 | tooltip {Save the disk directory to a printable text file} xywh {40 40 34 21} labelsize 12 | ||
1550 | } | ||
1551 | MenuItem {} { | ||
1552 | label {&Print catalog} | ||
1553 | callback {string* result=hd24utils::printcatalog(currenthd24); | ||
1554 | if (result!=NULL) | ||
1555 | { | ||
1556 | if (strlen(result->c_str())!=0) | ||
1557 | { | ||
1558 | fl_message("%s",result->c_str()); | ||
1559 | } | ||
1560 | } | ||
1561 | delete result;} | ||
1562 | tooltip {Save the disk directory to a printable text file} xywh {30 30 34 21} labelsize 12 divider | ||
1563 | } | ||
1564 | } | ||
1565 | Submenu {} { | ||
1566 | label {&Mixer} open | ||
1567 | xywh {10 10 70 21} labelsize 12 | ||
1568 | } { | ||
1569 | MenuItem {} { | ||
1570 | label {&Save mixer settings to file,,,} | ||
1571 | callback {mixer->savetofile();} | ||
1572 | tooltip {Save the current mixer settings to a file} xywh {50 50 34 21} labelsize 12 | ||
1573 | } | ||
1574 | MenuItem {} { | ||
1575 | label {&Load mixer settings from file...} | ||
1576 | callback {mixer->loadfromfile();} | ||
1577 | tooltip {Recall mixer settings from a previously saved mix} xywh {60 60 34 21} labelsize 12 divider | ||
1578 | } | ||
1579 | MenuItem {} { | ||
1580 | label {&Save mixer settings to HD24 drive,,,} | ||
1581 | tooltip {Save the current mix onto the HD24 drive} xywh {60 60 34 21} labelsize 12 deactivate | ||
1582 | } | ||
1583 | MenuItem {} { | ||
1584 | label {&Load mixer settings from HD24 drive...} | ||
1585 | tooltip {Recall mixer settings from a mix previously saved to the current HD24 drive} xywh {70 70 34 21} labelsize 12 deactivate | ||
1586 | } | ||
1587 | } | ||
1588 | Submenu {} { | ||
1589 | label {&Recovery} open | ||
1590 | xywh {0 0 70 21} labelsize 12 divider | ||
1591 | } { | ||
1592 | MenuItem {} { | ||
1593 | label {&Select device...} | ||
1594 | callback {dialog_choosedevice* chooser=new dialog_choosedevice(); | ||
1595 | Fl_Double_Window* w=chooser->make_window(currenthd24); | ||
1596 | w->end(); | ||
1597 | w->show(); | ||
1598 | while (w->visible()) { | ||
1599 | Fl::wait(); | ||
1600 | } | ||
1601 | string* cfilename; | ||
1602 | hd24fs* sysob; | ||
1603 | string* idir=NULL; | ||
1604 | switch (chooser->buttonclicked) { | ||
1605 | case 1: | ||
1606 | // OK | ||
1607 | cfilename=new string(chooser->devicename->c_str()); | ||
1608 | idir=hd24utils::getlastdir("driveimagedir"); | ||
1609 | sysob=new hd24fs(idir->c_str(),hd24fs::MODE_RDWR,cfilename,false); | ||
1610 | delete idir; idir=NULL; | ||
1611 | |||
1612 | currenthd24=sysob; | ||
1613 | defaulthd24=sysob; | ||
1614 | |||
1615 | if (!(currenthd24->isOpen())) | ||
1616 | { | ||
1617 | bool choice=confirm( | ||
1618 | "Device does not appear to be a valid HD24 device.\\nDo you want to try using it anyway?\\nWarning: Choosing 'Yes' may result in\\ncrashes and other unpredictable behavior." | ||
1619 | ); | ||
1620 | |||
1621 | if (choice) { | ||
1622 | if (sysob!=NULL) { | ||
1623 | delete (sysob); | ||
1624 | } | ||
1625 | string* idir=hd24utils::getlastdir("driveimagedir"); | ||
1626 | sysob=new hd24fs(idir->c_str(),hd24fs::MODE_RDWR,cfilename,true); //force | ||
1627 | delete idir; | ||
1628 | currenthd24=sysob; | ||
1629 | defaulthd24=sysob; | ||
1630 | int tryheader=0; | ||
1631 | if (currenthd24->isOpen()) { | ||
1632 | tryheader=1; | ||
1633 | bool wantheader=confirm("Do you want to load a header file?"); | ||
1634 | if (wantheader) { | ||
1635 | loadheaderfile(); | ||
1636 | } | ||
1637 | |||
1638 | ui_restart(); | ||
1639 | delete cfilename; | ||
1640 | return; | ||
1641 | } | ||
1642 | if (tryheader==1) { | ||
1643 | fl_message("Cannot open HD24 device."); | ||
1644 | } else { | ||
1645 | fl_message("Cannot open HD24 device. Access denied?"); | ||
1646 | } | ||
1647 | } | ||
1648 | delete cfilename; | ||
1649 | break; | ||
1650 | } | ||
1651 | ui_restart(); | ||
1652 | delete cfilename; | ||
1653 | break; | ||
1654 | case 2: | ||
1655 | // cancel | ||
1656 | break; | ||
1657 | default: | ||
1658 | // unknown | ||
1659 | break; | ||
1660 | } | ||
1661 | delete chooser;} | ||
1662 | xywh {5 5 34 21} labelsize 12 | ||
1663 | } | ||
1664 | MenuItem {} { | ||
1665 | label {Load &header file...} | ||
1666 | callback {loadheaderfile();} | ||
1667 | xywh {5 5 34 21} labelsize 12 | ||
1668 | } | ||
1669 | MenuItem {} { | ||
1670 | label {&Create header file...} | ||
1671 | callback {string* headerdir=new string(""); | ||
1672 | *headerdir+=*hd24utils::getlastdir("headerdir"); | ||
1673 | |||
1674 | Fl_Native_File_Chooser chooser; | ||
1675 | chooser.filter("Header files (*.h24)\\t"); | ||
1676 | chooser.title("Create header file"); | ||
1677 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
1678 | chooser.directory(headerdir->c_str()); | ||
1679 | chooser.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); | ||
1680 | |||
1681 | switch (chooser.show()) { | ||
1682 | case -1: break; //error | ||
1683 | case 1: break; //cancel | ||
1684 | default: | ||
1685 | // save header to chooser.filename() | ||
1686 | bool bFileexists=hd24utils::fileExists(chooser.filename()); | ||
1687 | if (bFileexists) { | ||
1688 | bool choice=confirm( | ||
1689 | "A file with this name already exists. Do you wish to overwrite it?" | ||
1690 | ); | ||
1691 | if (!(choice)) return; | ||
1692 | } | ||
1693 | string* strfile=new string(chooser.filename()); | ||
1694 | string* fpath=new string(""); | ||
1695 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
1696 | hd24utils::setlastdir("headerdir",fpath->c_str()); | ||
1697 | |||
1698 | int result=hd24utils::saveheader(currenthd24,strfile); | ||
1699 | delete strfile; | ||
1700 | if (result==0) { | ||
1701 | fl_message("Header file created successfully."); | ||
1702 | } else { | ||
1703 | fl_message("Could not write header file. Access denied? Disk full?"); | ||
1704 | } | ||
1705 | break; | ||
1706 | }} | ||
1707 | xywh {15 15 34 21} labelsize 12 | ||
1708 | } | ||
1709 | MenuItem {} { | ||
1710 | label {Recover song from &power failure} | ||
1711 | callback {if (currsong==NULL) { | ||
1712 | fl_message("First select the song to recover."); | ||
1713 | return; | ||
1714 | } | ||
1715 | |||
1716 | dialog_setlength* ui_setlength; | ||
1717 | ui_setlength=new dialog_setlength; | ||
1718 | int currlocchoice=locatepoints->value(); | ||
1719 | Fl_Window *win=ui_setlength->make_window(currsong,currlocchoice); | ||
1720 | win->end(); | ||
1721 | win->show(); | ||
1722 | |||
1723 | while (win->visible()) { Fl::wait(); } | ||
1724 | |||
1725 | if (ui_setlength->buttonclicked==1) { | ||
1726 | // TODO: | ||
1727 | // - create header file | ||
1728 | // getuserdatapath. | ||
1729 | // | ||
1730 | |||
1731 | char userdatapath[FL_PATH_MAX]; | ||
1732 | Fl_Preferences* prefs=new Fl_Preferences(Fl_Preferences::USER,"HD24","HD24connect"); | ||
1733 | prefs->getUserdataPath(userdatapath,FL_PATH_MAX); | ||
1734 | delete prefs; | ||
1735 | string* headerfilename=new string(userdatapath); | ||
1736 | |||
1737 | // add OS directory slash if forgotten | ||
1738 | \#ifdef WINDOWS | ||
1739 | \#define OSSLASH '\\\\' | ||
1740 | \#else | ||
1741 | \#define OSSLASH '/' | ||
1742 | \#endif | ||
1743 | const char* x=headerfilename->c_str(); | ||
1744 | int q=strlen(x); | ||
1745 | if (q>0) | ||
1746 | { | ||
1747 | if (x[q-1]!=OSSLASH) | ||
1748 | { | ||
1749 | *headerfilename+=OSSLASH; | ||
1750 | } | ||
1751 | } | ||
1752 | *headerfilename+="livefix.h24"; | ||
1753 | |||
1754 | int createtempheaderresult=hd24utils::savedrivesectors(currenthd24,headerfilename,0,0x10c76,NULL,NULL); | ||
1755 | |||
1756 | if (createtempheaderresult!=0) | ||
1757 | { | ||
1758 | delete headerfilename; | ||
1759 | fl_message("Couldn't create a temporary header file, cannot continue. Sorry."); | ||
1760 | return; | ||
1761 | } | ||
1762 | // header was created successfully. | ||
1763 | currenthd24->useheaderfile(*headerfilename); | ||
1764 | //cout << "Userdatapath="<<userdatapath << endl; | ||
1765 | |||
1766 | // - use header file | ||
1767 | // - this makes sure any writes go to header file | ||
1768 | |||
1769 | bool clearnew=false; | ||
1770 | currsong->songlength_in_samples(ui_setlength->locpoint,clearnew); | ||
1771 | currsong->save(); | ||
1772 | ui_refresh("liverec"); | ||
1773 | } | ||
1774 | delete ui_setlength;} | ||
1775 | xywh {10 10 36 21} labelsize 12 | ||
1776 | } | ||
1777 | } | ||
1778 | MenuItem {} { | ||
1779 | label {E&xit} | ||
1780 | callback {/* Find current window */ | ||
1781 | this->finish(); | ||
1782 | |||
1783 | Fl_Window * x=Fl::first_window(); | ||
1784 | x->~Fl_Window(); | ||
1785 | delete x; | ||
1786 | x=NULL;} | ||
1787 | xywh {0 0 100 20} labelsize 12 | ||
1788 | } | ||
1789 | } | ||
1790 | Submenu menutools { | ||
1791 | label {&Tools} open | ||
1792 | xywh {10 10 100 20} labelsize 12 | ||
1793 | } { | ||
1794 | Submenu {} { | ||
1795 | label {Alter &order of songs in project} open | ||
1796 | xywh {20 20 100 20} labelsize 12 divider | ||
1797 | } { | ||
1798 | MenuItem {} { | ||
1799 | label {Sort &Alphabetically} | ||
1800 | callback {if (this->currproj==NULL) | ||
1801 | { | ||
1802 | fl_message("Cannot sort project- no project selected."); | ||
1803 | return; | ||
1804 | } | ||
1805 | this->currproj->sort(); | ||
1806 | this->currproj->save(); | ||
1807 | this->ui_refresh("sort");} | ||
1808 | xywh {30 30 34 21} labelsize 12 | ||
1809 | } | ||
1810 | } | ||
1811 | MenuItem {} { | ||
1812 | label {&Options...} | ||
1813 | callback {dialog_options* ui_options; | ||
1814 | ui_options=new dialog_options; | ||
1815 | Fl_Window *win=ui_options->make_window(); | ||
1816 | win->end(); | ||
1817 | win->show(); | ||
1818 | |||
1819 | while (win->visible()) { Fl::wait(); } | ||
1820 | |||
1821 | delete ui_options;} | ||
1822 | xywh {30 30 34 21} labelsize 12 | ||
1823 | } | ||
1824 | } | ||
1825 | Submenu menuhelp { | ||
1826 | label {&Help} open | ||
1827 | xywh {0 0 100 20} labelsize 12 | ||
1828 | } { | ||
1829 | MenuItem {} { | ||
1830 | label {&About} | ||
1831 | callback {UserInterface_HelpAbout* ui_help_about; | ||
1832 | ui_help_about=new UserInterface_HelpAbout; | ||
1833 | |||
1834 | Fl_Window *helpaboutdialog=ui_help_about->make_window(); | ||
1835 | helpaboutdialog->end(); | ||
1836 | helpaboutdialog->show(); | ||
1837 | |||
1838 | while (helpaboutdialog->visible()) { Fl::wait(); }} | ||
1839 | xywh {0 0 100 20} labelsize 12 | ||
1840 | } | ||
1841 | MenuItem {} { | ||
1842 | label {System &Info} | ||
1843 | callback {string info="HD24connect system info\\n"; | ||
1844 | info+="JACK: "; | ||
1845 | if (libjack->libloaded) { | ||
1846 | info+="Loaded"; | ||
1847 | } else { | ||
1848 | info+="Not present"; | ||
1849 | } | ||
1850 | info+="\\n"; | ||
1851 | |||
1852 | info+="LIBSNDFILE: "; | ||
1853 | if (soundfile->libloaded) { | ||
1854 | info+="Loaded"; | ||
1855 | } else { | ||
1856 | info+="Not present"; | ||
1857 | } | ||
1858 | info+="\\n"; | ||
1859 | |||
1860 | |||
1861 | info+="PORTAUDIO: "; | ||
1862 | if (portaudio->libloaded) { | ||
1863 | info+="Loaded"; | ||
1864 | } else { | ||
1865 | info+="Not present"; | ||
1866 | } | ||
1867 | info+="\\n"; | ||
1868 | |||
1869 | |||
1870 | fl_message("%s",info.c_str());} | ||
1871 | xywh {20 20 100 20} labelsize 12 | ||
1872 | } | ||
1873 | MenuItem {} { | ||
1874 | label {Report a &Bug} | ||
1875 | callback {string bug="No warranty of any kind is given on this program.\\n\\n"; | ||
1876 | bug+="However, if you find any defects or faults in it, they\\n"; | ||
1877 | bug+="will most likely be fixed with high priority in the next\\n"; | ||
1878 | bug+="release, as long as the author is aware of them.\\n\\n"; | ||
1879 | bug+="Should you find any defects, please email the author at\\n"; | ||
1880 | bug+="the following e-mail address:\\n\\n"; | ||
1881 | bug+="mrjb@@dnd.utwente.nl.\\n\\n"; | ||
1882 | bug+="Make sure to include 'hd24' in the subject line."; | ||
1883 | fl_message("%s",bug.c_str());} | ||
1884 | xywh {0 0 100 20} labelsize 12 | ||
1885 | } | ||
1886 | MenuItem {} { | ||
1887 | label {Request a &Feature} | ||
1888 | callback {string bug="If you would like a specific feature to be added, please\\n"; | ||
1889 | bug+="please email your request to the author at the following \\n"; | ||
1890 | bug+="e-mail address:\\n\\n"; | ||
1891 | bug+="mrjb@@dnd.utwente.nl.\\n\\n"; | ||
1892 | bug+="Make sure to include 'hd24 feature request' in the subject line.\\n"; | ||
1893 | bug+="You can increase the priority of the request by donating."; | ||
1894 | fl_message("%s",bug.c_str());} | ||
1895 | xywh {10 10 100 20} labelsize 12 | ||
1896 | } | ||
1897 | MenuItem {} { | ||
1898 | label {&Credits} | ||
1899 | callback {string thanks="Extra Special thanks go out to: \\n\\n"; | ||
1900 | thanks+="Randy Bryant for trusting me to use his Mac\\n"; | ||
1901 | thanks+="Mike Crute for hosting and builder support\\n"; | ||
1902 | thanks+="Cabbage for building various Mac package installers\\n"; | ||
1903 | thanks+="Edward van Westerlaak for Windows and Mac/OSX beta testing, hardware support and suggestions\\n"; | ||
1904 | thanks+="Erik de Castro Lopo and other contributors for libsndfile\\n"; | ||
1905 | thanks+="Ross Bencina, Phil Burk, Bjorn Roche and other contributors for the portaudio library\\n"; | ||
1906 | thanks+="Bill Spitzak and others for the Fast Light Toolkit\\n"; | ||
1907 | thanks+="Sveinn Kjartansson for providing the means for high sample rate support\\n\\n"; | ||
1908 | thanks+="Special thanks go out to the Yahoo Groups HD24 community\\n"; | ||
1909 | thanks+="for additional beta testing, suggestions and general encouragement.\\n\\n"; | ||
1910 | fl_message("%s",thanks.c_str());} | ||
1911 | xywh {10 10 100 20} labelsize 12 | ||
1912 | } | ||
1913 | } | ||
1914 | } | ||
1915 | } | ||
1916 | Fl_Group uicanvas {open | ||
1917 | xywh {-5 0 1720 540} resizable | ||
1918 | } { | ||
1919 | Fl_Group transfercanvas { | ||
1920 | label Transfer | ||
1921 | xywh {10 360 590 150} box UP_BOX color 52 labelfont 1 labelsize 12 align 5 | ||
1922 | } {} | ||
1923 | Fl_Group statusbar { | ||
1924 | xywh {-5 510 725 20} box DOWN_BOX color 23 | ||
1925 | } { | ||
1926 | Fl_Output backgroundbox { | ||
1927 | xywh {0 510 605 20} color 52 labelsize 12 textsize 12 | ||
1928 | } | ||
1929 | Fl_Button stop_transfer { | ||
1930 | label Cancel | ||
1931 | callback {transfer_cancel=1; | ||
1932 | stop_transfer->hide();} | ||
1933 | xywh {525 510 80 20} labelsize 12 align 16 | ||
1934 | code0 {o->hide();} | ||
1935 | } | ||
1936 | Fl_Output statusmsg { | ||
1937 | xywh {0 510 525 20} color 52 labelsize 12 textsize 12 | ||
1938 | } | ||
1939 | } | ||
1940 | Fl_Tabs Tabs { | ||
1941 | callback {this->readmixer(); | ||
1942 | this->mixer->damage(); | ||
1943 | if (o->value()==tabRecorder) | ||
1944 | { | ||
1945 | if (recorder->button_play->value()==0) | ||
1946 | { | ||
1947 | showprogtitle(); | ||
1948 | } | ||
1949 | }} open | ||
1950 | xywh {-5 25 1600 485} | ||
1951 | code0 {o->value(tabDrive);} | ||
1952 | } { | ||
1953 | Fl_Group tabDrive { | ||
1954 | label Drive open | ||
1955 | xywh {0 45 605 465} box UP_BOX color 52 labelfont 1 labelsize 12 align 5 hide | ||
1956 | } { | ||
1957 | Fl_Choice drivename { | ||
1958 | label {Drive name:} | ||
1959 | xywh {155 80 440 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
1960 | } {} | ||
1961 | Fl_Output fsversion { | ||
1962 | label {FS version:} | ||
1963 | xywh {305 105 50 20} labelsize 12 textsize 12 | ||
1964 | code0 {o->clear_visible_focus();} | ||
1965 | } | ||
1966 | Fl_Output number_of_projects { | ||
1967 | label {Number of projects:} | ||
1968 | xywh {155 105 70 20} labelsize 12 textsize 12 | ||
1969 | code0 {o->clear_visible_focus();} | ||
1970 | } | ||
1971 | Fl_Button rename_drive { | ||
1972 | label {Rename...} | ||
1973 | callback {if (currenthd24==NULL) return; | ||
1974 | dialog_rename* ui_rename; | ||
1975 | ui_rename=new dialog_rename(); | ||
1976 | string* currname=currenthd24->volumename(); | ||
1977 | string* strname=new string("Rename project"); | ||
1978 | Fl_Window* win=ui_rename->make_window(currname,strname); | ||
1979 | if (strname!=NULL) | ||
1980 | { | ||
1981 | delete strname; | ||
1982 | } | ||
1983 | if (currname!=NULL) | ||
1984 | { | ||
1985 | delete currname; | ||
1986 | } | ||
1987 | win->end(); | ||
1988 | win->show(); | ||
1989 | |||
1990 | while (win->visible()) { Fl::wait(); } | ||
1991 | if (ui_rename->buttonclicked==1) | ||
1992 | { | ||
1993 | // OK clicked | ||
1994 | if (confirm("Do you wish to write the changes to disk?")) { | ||
1995 | currenthd24->setvolumename(*(ui_rename->itemname)); | ||
1996 | currenthd24->savedriveinfo(); | ||
1997 | populate_drivelist(1+drivename->value()); | ||
1998 | drivename->redraw(); | ||
1999 | } | ||
2000 | } | ||
2001 | delete ui_rename; | ||
2002 | ui_refresh("ren proj");} | ||
2003 | xywh {510 105 85 20} labelsize 12 align 16 | ||
2004 | } | ||
2005 | Fl_Output freespace { | ||
2006 | label {Free space preview:} | ||
2007 | xywh {155 130 140 20} labelsize 12 textsize 12 | ||
2008 | code0 {o->clear_visible_focus();} | ||
2009 | } | ||
2010 | Fl_Choice atrate { | ||
2011 | label {at } | ||
2012 | callback {calcspace();} open | ||
2013 | xywh {320 130 85 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
2014 | code0 {o->value(0);} | ||
2015 | } { | ||
2016 | MenuItem {} { | ||
2017 | label 44100 | ||
2018 | xywh {5 5 100 20} value 1 labelsize 12 | ||
2019 | } | ||
2020 | MenuItem {} { | ||
2021 | label 48000 | ||
2022 | xywh {15 15 100 20} value 1 labelsize 12 | ||
2023 | } | ||
2024 | MenuItem {} { | ||
2025 | label 88200 | ||
2026 | xywh {25 25 100 20} value 1 labelsize 12 | ||
2027 | } | ||
2028 | MenuItem {} { | ||
2029 | label 96000 | ||
2030 | xywh {35 35 100 20} value 1 labelsize 12 | ||
2031 | } | ||
2032 | } | ||
2033 | Fl_Choice attracks { | ||
2034 | label {Hz, } | ||
2035 | callback {calcspace();} open | ||
2036 | xywh {435 130 75 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
2037 | code0 {o->value(5);} | ||
2038 | } { | ||
2039 | MenuItem {} { | ||
2040 | label 2 | ||
2041 | xywh {15 15 100 20} value 1 labelsize 12 | ||
2042 | } | ||
2043 | MenuItem {} { | ||
2044 | label 6 | ||
2045 | xywh {25 25 100 20} value 1 labelsize 12 | ||
2046 | } | ||
2047 | MenuItem {} { | ||
2048 | label 8 | ||
2049 | xywh {35 35 100 20} value 1 labelsize 12 | ||
2050 | } | ||
2051 | MenuItem {} { | ||
2052 | label 12 | ||
2053 | xywh {45 45 100 20} value 1 labelsize 12 | ||
2054 | } | ||
2055 | MenuItem {} { | ||
2056 | label 16 | ||
2057 | xywh {55 55 100 20} value 1 labelsize 12 | ||
2058 | } | ||
2059 | MenuItem {} { | ||
2060 | label 24 | ||
2061 | xywh {65 65 100 20} value 1 labelsize 12 | ||
2062 | } | ||
2063 | } | ||
2064 | Fl_Box {} { | ||
2065 | label tracks | ||
2066 | xywh {510 130 55 20} labelsize 12 align 20 | ||
2067 | } | ||
2068 | Fl_Group {} {open | ||
2069 | xywh {25 70 15 15} | ||
2070 | } {} | ||
2071 | Fl_Box {} { | ||
2072 | label {Drive information} | ||
2073 | xywh {0 58 5 17} labelfont 1 labelsize 12 align 8 | ||
2074 | } | ||
2075 | Fl_Text_Display catalog { | ||
2076 | label {Drive contents} | ||
2077 | xywh {5 190 595 310} box DOWN_BOX labelfont 1 labelsize 12 align 5 textfont 4 textsize 12 | ||
2078 | code0 {if (catalogbuffer==NULL) catalogbuffer=new Fl_Text_Buffer(); string* cat=new string("\\n"); catalogbuffer->append(cat->c_str()); delete cat;} | ||
2079 | code1 {o->buffer(catalogbuffer); o->scrollbar_align(FL_ALIGN_RIGHT);} | ||
2080 | } | ||
2081 | Fl_Button format_driveimage { | ||
2082 | label Format | ||
2083 | callback {bool wantformat=confirm("This will COMPLETELY ERASE\\nALL projects and songs on this drive.\\nAre you SURE you want to format the current drive?\\n"); | ||
2084 | if (!wantformat) return; | ||
2085 | // Okay, user is absolutely sure. | ||
2086 | currenthd24->write_enable(); | ||
2087 | currenthd24->quickformat(NULL); | ||
2088 | // there's no point in re-enabling write | ||
2089 | // protection again now, is there? | ||
2090 | ui_refresh("format"); | ||
2091 | setstatus("Format complete."); | ||
2092 | return;} | ||
2093 | xywh {455 105 55 20} labelsize 12 align 16 | ||
2094 | } | ||
2095 | Fl_Button create_driveimage { | ||
2096 | label {New Image...} | ||
2097 | callback {dialog_filesize* ui_filesize; | ||
2098 | ui_filesize=new dialog_filesize(); | ||
2099 | Fl_Window *win=ui_filesize->make_window(); | ||
2100 | win->end(); | ||
2101 | win->show(); | ||
2102 | |||
2103 | while (win->visible()) { Fl::wait(); } | ||
2104 | __uint32 lastsector=0; | ||
2105 | |||
2106 | if (ui_filesize->buttonclicked!=1) | ||
2107 | { | ||
2108 | delete ui_filesize; | ||
2109 | return; | ||
2110 | } | ||
2111 | |||
2112 | lastsector=ui_filesize->lastsector; | ||
2113 | delete ui_filesize; | ||
2114 | |||
2115 | string* driveimgdir=new string(""); | ||
2116 | *driveimgdir+=*hd24utils::getlastdir("driveimagedir"); | ||
2117 | |||
2118 | Fl_Native_File_Chooser chooser; | ||
2119 | chooser.filter("Drive Images\\t*.{img,bin,h24,hd24}\\0"); | ||
2120 | chooser.title("Create empty drive image in file"); | ||
2121 | chooser.directory(driveimgdir->c_str()); | ||
2122 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
2123 | chooser.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); | ||
2124 | |||
2125 | switch (chooser.show()) { | ||
2126 | case -1: break; //error | ||
2127 | case 1: break; //cancel | ||
2128 | default: | ||
2129 | // save header to chooser.filename() | ||
2130 | |||
2131 | bool bFileexists=hd24utils::fileExists(chooser.filename()); | ||
2132 | if (bFileexists) { | ||
2133 | bool choice=confirm( | ||
2134 | "A file with this name already exists. Do you wish to overwrite it?" | ||
2135 | ); | ||
2136 | if (!(choice)) return; | ||
2137 | } | ||
2138 | string* strfile=new string(chooser.filename()); | ||
2139 | //cout << "filename = " << *strfile << endl; | ||
2140 | string* fpath=new string(""); | ||
2141 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
2142 | hd24utils::setlastdir("driveimagedir",fpath->c_str()); | ||
2143 | this->transfer_cancel=0; | ||
2144 | this->mustdispsavemessage=true; | ||
2145 | Fl::add_timeout(.25,savemessage_callback,this); | ||
2146 | // __uint32 lastsector=2097151; // 1 GiB | ||
2147 | int result=hd24utils::newdriveimage(strfile,lastsector,&this->savemessage[0],&this->transfer_cancel); | ||
2148 | |||
2149 | this->mustdispsavemessage=false; | ||
2150 | setstatus("Done."); | ||
2151 | if (result==0) { | ||
2152 | setstatus("Done."); | ||
2153 | int wantopen=confirm("Drive image created successfully.\\nDo you want to open it now?"); | ||
2154 | if (wantopen==1) | ||
2155 | { | ||
2156 | string* idir=hd24utils::getlastdir("driveimagedir"); | ||
2157 | hd24fs* sysob=new hd24fs(idir->c_str(),hd24fs::MODE_RDWR,strfile,false); | ||
2158 | delete idir; | ||
2159 | if (currenthd24!=NULL) | ||
2160 | { | ||
2161 | currenthd24->~hd24fs(); | ||
2162 | } | ||
2163 | if (defaulthd24!=NULL) | ||
2164 | { | ||
2165 | if (defaulthd24!=currenthd24) | ||
2166 | { | ||
2167 | defaulthd24->~hd24fs(); | ||
2168 | } | ||
2169 | |||
2170 | } | ||
2171 | currenthd24=sysob; | ||
2172 | defaulthd24=sysob; | ||
2173 | } | ||
2174 | |||
2175 | } else { | ||
2176 | fl_message("Could not write drive image to file. Access denied? Disk full?"); | ||
2177 | } | ||
2178 | delete strfile; | ||
2179 | break; | ||
2180 | } | ||
2181 | setstatus("Done."); | ||
2182 | ui_refresh("newdriveimage"); | ||
2183 | delete driveimgdir;} | ||
2184 | xywh {360 105 95 20} labelsize 12 align 16 | ||
2185 | } | ||
2186 | Fl_Box {} { | ||
2187 | label {Songs marked * are write-protected.} | ||
2188 | xywh {235 175 365 15} labelfont 2 labelsize 12 align 24 | ||
2189 | } | ||
2190 | } | ||
2191 | Fl_Group songinfogroup { | ||
2192 | label {Project/Song} | ||
2193 | xywh {0 50 605 460} box UP_BOX color 52 labelfont 1 labelsize 12 align 5 hide | ||
2194 | } { | ||
2195 | Fl_Choice songname { | ||
2196 | label {Song name:} open | ||
2197 | xywh {155 155 440 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
2198 | } {} | ||
2199 | Fl_Output number_of_tracks { | ||
2200 | label {Number of tracks:} | ||
2201 | xywh {155 180 90 20} labelsize 12 textsize 12 | ||
2202 | code0 {o->clear_visible_focus();} | ||
2203 | } | ||
2204 | Fl_Output sample_rate { | ||
2205 | label {Sample rate:} | ||
2206 | callback {if (currsong==NULL) return; | ||
2207 | bool confirmrate=false; | ||
2208 | if (strcmp(o->value(),"44100")==0) { | ||
2209 | o->value("48000"); | ||
2210 | currsong->samplerate(48000); | ||
2211 | if (mixer!=NULL) mixer->control->samplerate(48000); | ||
2212 | confirmrate=confirm("Re-stamp song as 48000Hz on disk?"); | ||
2213 | } else { | ||
2214 | if (strcmp(o->value(),"48000")==0) { | ||
2215 | o->value("44100"); | ||
2216 | currsong->samplerate(44100); | ||
2217 | if (mixer!=NULL) mixer->control->samplerate(44100); | ||
2218 | confirmrate=confirm("Re-stamp song as 44100Hz on disk?"); | ||
2219 | } | ||
2220 | } | ||
2221 | if (strcmp(o->value(),"88200")==0) { | ||
2222 | o->value("96000"); | ||
2223 | currsong->samplerate(96000); | ||
2224 | if (mixer!=NULL) mixer->control->samplerate(48000); | ||
2225 | confirmrate=confirm("Re-stamp song as 96000Hz on disk?"); | ||
2226 | } else { | ||
2227 | if (strcmp(o->value(),"96000")==0) { | ||
2228 | o->value("88200"); | ||
2229 | if (mixer!=NULL) mixer->control->samplerate(44100); | ||
2230 | confirmrate=confirm("Re-stamp song as 88200Hz on disk?"); | ||
2231 | } | ||
2232 | } | ||
2233 | |||
2234 | if (confirmrate) { | ||
2235 | // currsong->songname(*(ui_rename->itemname)); | ||
2236 | currsong->save(); | ||
2237 | populate_songlist(songname->value()); | ||
2238 | } else { | ||
2239 | |||
2240 | |||
2241 | |||
2242 | if (strcmp(o->value(),"44100")==0) { | ||
2243 | o->value("48000"); | ||
2244 | currsong->samplerate(48000); | ||
2245 | if (mixer!=NULL) mixer->control->samplerate(48000); | ||
2246 | } else { | ||
2247 | if (strcmp(o->value(),"48000")==0) { | ||
2248 | o->value("44100"); | ||
2249 | currsong->samplerate(44100); | ||
2250 | if (mixer!=NULL) mixer->control->samplerate(44100); | ||
2251 | } | ||
2252 | } | ||
2253 | if (strcmp(o->value(),"88200")==0) { | ||
2254 | o->value("96000"); | ||
2255 | currsong->samplerate(96000); | ||
2256 | if (mixer!=NULL) mixer->control->samplerate(48000); | ||
2257 | } else { | ||
2258 | if (strcmp(o->value(),"96000")==0) { | ||
2259 | o->value("88200"); | ||
2260 | currsong->samplerate(88200); | ||
2261 | if (mixer!=NULL) mixer->control->samplerate(44100); | ||
2262 | } | ||
2263 | } | ||
2264 | |||
2265 | |||
2266 | } | ||
2267 | ui_refresh("stamprate");} | ||
2268 | xywh {155 230 90 20} labelsize 12 textsize 12 | ||
2269 | code0 {o->clear_visible_focus();} | ||
2270 | } | ||
2271 | Fl_Output bitdepth { | ||
2272 | label {Bit depth:} | ||
2273 | xywh {155 255 90 20} labelsize 12 textsize 12 | ||
2274 | code0 {o->clear_visible_focus();} | ||
2275 | } | ||
2276 | Fl_Output duration { | ||
2277 | label {Duration:} | ||
2278 | xywh {155 205 90 20} labelsize 12 textsize 12 | ||
2279 | code0 {o->clear_visible_focus();} | ||
2280 | } | ||
2281 | Fl_Button rename_song { | ||
2282 | label {Rename...} | ||
2283 | callback {if (currsong==NULL) return; | ||
2284 | dialog_rename* ui_rename; | ||
2285 | ui_rename=new dialog_rename(); | ||
2286 | string* currname=currsong->songname(); | ||
2287 | string* strsong=new string("Rename song"); | ||
2288 | Fl_Window* win=ui_rename->make_window(currname,strsong); | ||
2289 | delete strsong; | ||
2290 | win->end(); | ||
2291 | win->show(); | ||
2292 | |||
2293 | while (win->visible()) { Fl::wait(); } | ||
2294 | if (ui_rename->buttonclicked==1) | ||
2295 | { | ||
2296 | // OK clicked | ||
2297 | if (confirm("Do you wish to write the changes to disk?")) { | ||
2298 | currsong->songname(*(ui_rename->itemname)); | ||
2299 | currsong->save(); | ||
2300 | populate_songlist(songname->value()); | ||
2301 | } | ||
2302 | } | ||
2303 | |||
2304 | delete ui_rename; | ||
2305 | ui_refresh("rename song");} | ||
2306 | xywh {510 180 85 20} labelsize 12 align 16 | ||
2307 | } | ||
2308 | Fl_Choice locatepoints { | ||
2309 | label {Locate points:} | ||
2310 | callback {setlocbuttonlabel(locatepoints->value()); | ||
2311 | if ((locatepoints->value())==25) { | ||
2312 | button_setlocatepoint->deactivate(); | ||
2313 | } else { | ||
2314 | button_setlocatepoint->activate(); | ||
2315 | }} open | ||
2316 | xywh {155 280 215 20} down_box BORDER_BOX labelsize 12 textsize 12 deactivate | ||
2317 | } {} | ||
2318 | Fl_Button button_setlocatepoint { | ||
2319 | label {Edit...} | ||
2320 | callback {if (currsong==NULL) return; | ||
2321 | dialog_setlocate* ui_setlocate; | ||
2322 | ui_setlocate=new dialog_setlocate; | ||
2323 | int currlocchoice=locatepoints->value(); | ||
2324 | Fl_Window *win=ui_setlocate->make_window(currsong,locatepoints->value()); | ||
2325 | win->end(); | ||
2326 | win->show(); | ||
2327 | |||
2328 | while (win->visible()) { Fl::wait(); } | ||
2329 | |||
2330 | /* Dialog has closed, read the results */ | ||
2331 | |||
2332 | populate_locatepoints(currsong,locatepoints); | ||
2333 | locatepoints->value(currlocchoice); | ||
2334 | |||
2335 | if (ui_setlocate->useasrange==1) { | ||
2336 | if (currlocchoice==1) | ||
2337 | { | ||
2338 | choice_startloc=1; | ||
2339 | } | ||
2340 | if (currlocchoice==2) | ||
2341 | { | ||
2342 | choice_endloc=2; | ||
2343 | } | ||
2344 | } | ||
2345 | currsong->save(); | ||
2346 | |||
2347 | update_fromto(); | ||
2348 | delete ui_setlocate;} | ||
2349 | xywh {370 280 60 20} labelsize 12 align 16 deactivate | ||
2350 | } | ||
2351 | Fl_Check_Button writeprotected { | ||
2352 | label {Write protected} | ||
2353 | callback {if (currsong==NULL) return; | ||
2354 | bool confirmprot=false; | ||
2355 | if (o->value()==0) { | ||
2356 | currsong->setwriteprotected(false); | ||
2357 | confirmprot=confirm("Write-enable song on disk?"); | ||
2358 | } else { | ||
2359 | if (o->value()==1) { | ||
2360 | currsong->setwriteprotected(true); | ||
2361 | confirmprot=confirm("Write-protect song on disk?"); | ||
2362 | } | ||
2363 | } | ||
2364 | |||
2365 | if (confirmprot) { | ||
2366 | currsong->save(); | ||
2367 | populate_songlist(songname->value()); | ||
2368 | } else { | ||
2369 | if (o->value()==0) { | ||
2370 | o->value(1); | ||
2371 | } else { | ||
2372 | o->value(0); | ||
2373 | } | ||
2374 | } | ||
2375 | ui_refresh("writeprot");} | ||
2376 | xywh {155 300 20 25} down_box DOWN_BOX labelsize 12 align 8 | ||
2377 | } | ||
2378 | Fl_Button button_golocatepoint { | ||
2379 | label Go | ||
2380 | callback {if (currsong==NULL) return; | ||
2381 | if (recorder==NULL) return; | ||
2382 | recorder->control->hd24_transport_goloc(currsong->getlocatepos(locatepoints->value()));} | ||
2383 | xywh {435 280 155 20} labelsize 12 align 16 | ||
2384 | } | ||
2385 | Fl_Output number_of_songs { | ||
2386 | label {Number of songs:} | ||
2387 | xywh {155 105 85 20} labelsize 12 textsize 12 | ||
2388 | code0 {o->clear_visible_focus();} | ||
2389 | } | ||
2390 | Fl_Choice projectname { | ||
2391 | label {Project name:} open | ||
2392 | xywh {155 80 440 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
2393 | } {} | ||
2394 | Fl_Button rename_project { | ||
2395 | label {Rename...} | ||
2396 | callback {if (currproj==NULL) return; | ||
2397 | dialog_rename* ui_rename; | ||
2398 | ui_rename=new dialog_rename(); | ||
2399 | |||
2400 | string* currname=currproj->projectname(); | ||
2401 | string* strproject=new string("Rename project"); | ||
2402 | Fl_Window* win=ui_rename->make_window(currname,strproject); | ||
2403 | if (strproject!=NULL) | ||
2404 | { | ||
2405 | delete strproject; | ||
2406 | } | ||
2407 | win->end(); | ||
2408 | win->show(); | ||
2409 | |||
2410 | while (win->visible()) { Fl::wait(); } | ||
2411 | if (ui_rename->buttonclicked==1) | ||
2412 | { | ||
2413 | // OK clicked | ||
2414 | if (confirm("Do you wish to write the changes to disk?")) { | ||
2415 | currproj->projectname(*(ui_rename->itemname)); | ||
2416 | currproj->save(); | ||
2417 | populate_projectlist(1+projectname->value()); | ||
2418 | } | ||
2419 | |||
2420 | |||
2421 | |||
2422 | |||
2423 | } | ||
2424 | delete ui_rename; | ||
2425 | ui_refresh("ren proj 2");} | ||
2426 | xywh {510 105 85 20} labelsize 12 align 16 | ||
2427 | } | ||
2428 | Fl_Box {} { | ||
2429 | label {Project information} | ||
2430 | xywh {0 58 5 17} labelfont 1 labelsize 12 align 8 | ||
2431 | } | ||
2432 | Fl_Box {} { | ||
2433 | label {Song information} | ||
2434 | xywh {0 138 5 17} labelfont 1 labelsize 12 align 8 | ||
2435 | } | ||
2436 | Fl_Output song_messages_label { | ||
2437 | label {Recovery messages:} | ||
2438 | xywh {155 325 10 20} type Multiline labelsize 12 textsize 12 | ||
2439 | code0 {o->clear_visible_focus();} | ||
2440 | } | ||
2441 | Fl_Output song_messages { | ||
2442 | xywh {155 325 440 40} type Multiline labelsize 12 textsize 12 | ||
2443 | code0 {o->clear_visible_focus();} | ||
2444 | } | ||
2445 | Fl_Button delete_project { | ||
2446 | label Delete | ||
2447 | callback {bool wantdel=confirm("Are you sure you want to delete this project, all songs in it and their recorded audio?\\nThis operation cannot be undone!"); | ||
2448 | if (!wantdel) return; | ||
2449 | __sint32 projtodel=currproj->projectid(); | ||
2450 | __uint32 result=currenthd24->deleteproject(projtodel); | ||
2451 | result++; result--; // ignore for now | ||
2452 | ui_refresh("del proj");} | ||
2453 | xywh {455 105 55 20} labelsize 12 align 16 | ||
2454 | } | ||
2455 | Fl_Button delete_song { | ||
2456 | label Delete | ||
2457 | callback {if (currproj==NULL) return; | ||
2458 | if (currsong==NULL) return; | ||
2459 | |||
2460 | bool wantdel=confirm("Are you sure you want to delete this song and its recorded audio?\\nThis operation cannot be undone!"); | ||
2461 | if (!wantdel) return; | ||
2462 | __uint32 songtodel=currsong->songid(); | ||
2463 | __uint32 result=currproj->deletesong(songtodel); | ||
2464 | result++; result--; //ignore for now | ||
2465 | ui_refresh("del song");} | ||
2466 | xywh {455 180 55 20} labelsize 12 align 16 | ||
2467 | } | ||
2468 | Fl_Button create_project { | ||
2469 | label {New Project...} | ||
2470 | callback {if (currenthd24==NULL) { | ||
2471 | fl_message("No drive is currently selected."); | ||
2472 | return; | ||
2473 | } | ||
2474 | |||
2475 | if (currenthd24->projectcount() == currenthd24->maxprojects()) | ||
2476 | { | ||
2477 | fl_message("Cannot create project.\\nThe maximum number of projects is already in use!"); | ||
2478 | return; | ||
2479 | } | ||
2480 | // - check if current project is NULL | ||
2481 | // - check if there's song space left in it | ||
2482 | dialog_newproject* ui_newproject; | ||
2483 | ui_newproject=new dialog_newproject(); | ||
2484 | Fl_Window *win=ui_newproject->make_window(); | ||
2485 | win->end(); | ||
2486 | win->show(); | ||
2487 | |||
2488 | while (win->visible()) { Fl::wait(); } | ||
2489 | |||
2490 | if (ui_newproject->buttonclicked!=1) | ||
2491 | { | ||
2492 | delete ui_newproject; | ||
2493 | return; | ||
2494 | } | ||
2495 | char projname[65]; | ||
2496 | for (int i=0;i<65;i++) { | ||
2497 | projname[i]=0; | ||
2498 | } | ||
2499 | hd24project* newproj=currenthd24->createproject( | ||
2500 | (const char*)strncpy(projname,ui_newproject->projectname,64) | ||
2501 | ); | ||
2502 | if (newproj==NULL) | ||
2503 | { | ||
2504 | fl_message("Could not create the project. Access denied?"); | ||
2505 | delete ui_newproject; | ||
2506 | return; | ||
2507 | } | ||
2508 | |||
2509 | //if (ui_newsong->buttonclicked==1) { | ||
2510 | // lastsector=ui_filesize->lastsector; | ||
2511 | //} | ||
2512 | ui_refresh("createproj"); | ||
2513 | delete ui_newproject;} | ||
2514 | xywh {360 105 95 20} labelsize 12 align 16 | ||
2515 | } | ||
2516 | Fl_Button create_song { | ||
2517 | label {New Song...} | ||
2518 | callback {if (currenthd24==NULL) { | ||
2519 | fl_message("No drive is currently selected."); | ||
2520 | return; | ||
2521 | } | ||
2522 | |||
2523 | if (currproj==NULL) { | ||
2524 | fl_message("No project is currently selected."); | ||
2525 | return; | ||
2526 | } | ||
2527 | |||
2528 | if (currproj->songcount() == currproj->maxsongs()) | ||
2529 | { | ||
2530 | fl_message("Cannot create song.\\nThe maximum number of songs is already in use!"); | ||
2531 | return; | ||
2532 | } | ||
2533 | savemessage[0]='\\0'; | ||
2534 | transfer_cancel=0; | ||
2535 | |||
2536 | this->mustdispsavemessage=true; | ||
2537 | Fl::add_timeout(0,savemessage_callback,this); | ||
2538 | |||
2539 | dialog_newsong* ui_newsong; | ||
2540 | ui_newsong=new dialog_newsong(); | ||
2541 | Fl_Window *win=ui_newsong->make_window(); | ||
2542 | win->end(); | ||
2543 | win->show(); | ||
2544 | |||
2545 | |||
2546 | |||
2547 | while (win->visible()) { Fl::wait(); } | ||
2548 | |||
2549 | |||
2550 | |||
2551 | //__uint32 lastsector=0; | ||
2552 | |||
2553 | if (ui_newsong->buttonclicked!=1) | ||
2554 | { | ||
2555 | mustdispsavemessage=false; | ||
2556 | transfer_cancel=1; | ||
2557 | delete ui_newsong; | ||
2558 | return; | ||
2559 | } | ||
2560 | |||
2561 | char songname[65]; | ||
2562 | for (int i=0;i<65;i++) { | ||
2563 | songname[i]=0; | ||
2564 | } | ||
2565 | hd24song* newsong=currproj->createsong( | ||
2566 | (const char*)strncpy(songname,ui_newsong->songname,64),ui_newsong->trackcount,ui_newsong->samplerate | ||
2567 | ); | ||
2568 | |||
2569 | |||
2570 | if (newsong==NULL) | ||
2571 | { | ||
2572 | fl_message("Could not create the song. Access denied?"); | ||
2573 | mustdispsavemessage=false; | ||
2574 | transfer_cancel=1; | ||
2575 | delete ui_newsong; | ||
2576 | return; | ||
2577 | } | ||
2578 | __uint32 samlen=ui_newsong->songlength_in_samples; | ||
2579 | win->~Fl_Window(); | ||
2580 | delete ui_newsong; | ||
2581 | // optionally, lengthen song to specified size. | ||
2582 | if (samlen>0) { | ||
2583 | setstatus("Lengthening song... "); | ||
2584 | |||
2585 | |||
2586 | \#if (HD24DEBUG==1) | ||
2587 | cout << "about to start lengthening song to maxlen=" << samlen << endl; | ||
2588 | \#endif | ||
2589 | bool clearnew=true; // clear lengthened part | ||
2590 | |||
2591 | __uint32 translen=newsong->songlength_in_samples(samlen,clearnew,&this->savemessage[0],&this->transfer_cancel,Fl::check); | ||
2592 | |||
2593 | |||
2594 | \#if (HD24DEBUG==1) | ||
2595 | cout << "verifying actual song length " << endl; | ||
2596 | cout << "new len=" << translen << endl; | ||
2597 | \#endif | ||
2598 | if (translen!=samlen) | ||
2599 | { | ||
2600 | \#if (HD24DEBUG==1) | ||
2601 | |||
2602 | cout << "new len<> maxlen so not enough space." << endl; | ||
2603 | \#endif | ||
2604 | if (transfer_cancel==0) | ||
2605 | { | ||
2606 | fl_message("Not enough space on HD24 drive."); | ||
2607 | } else | ||
2608 | { | ||
2609 | fl_message("Song lengthening cancelled by user."); | ||
2610 | } | ||
2611 | return; | ||
2612 | } | ||
2613 | newsong->save(); | ||
2614 | |||
2615 | \#if (HD24DEBUG==1) | ||
2616 | cout << "translen is now " << translen << endl; | ||
2617 | \#endif | ||
2618 | } | ||
2619 | stop_transfer->hide(); | ||
2620 | this->mustdispsavemessage=false; | ||
2621 | delete newsong; // ui refresh will pick it up as currsong. | ||
2622 | ui_refresh("newsong"); | ||
2623 | setstatus("Ready."); | ||
2624 | return;} | ||
2625 | xywh {360 180 95 20} labelsize 12 align 16 | ||
2626 | } | ||
2627 | Fl_Box {} { | ||
2628 | label Hz | ||
2629 | xywh {245 230 19 20} labelsize 12 align 20 | ||
2630 | } | ||
2631 | Fl_Box {} { | ||
2632 | label {hours:minutes:seconds.frames} | ||
2633 | xywh {245 205 195 20} labelsize 12 align 20 | ||
2634 | } | ||
2635 | } | ||
2636 | Fl_Group tabRecorder { | ||
2637 | label Recorder open | ||
2638 | xywh {-5 46 620 464} color 52 labelfont 1 labelsize 12 hide | ||
2639 | } { | ||
2640 | Fl_Group recorder {open | ||
2641 | xywh {-5 49 610 457} color 53 selection_color 53 align 0 | ||
2642 | code0 {o->set_ui(this);} | ||
2643 | code1 {o->control->audiolib(AUDIOLIB_PORTAUDIO,(void*)(this->portaudio));} | ||
2644 | code2 {o->control->audiolib(AUDIOLIB_JACK,(void*)(this->libjack));} | ||
2645 | code3 {o->control->audiolib(AUDIOLIB_SNDFILE,(void*)(this->soundfile));} | ||
2646 | class RecorderUI | ||
2647 | } {} | ||
2648 | } | ||
2649 | Fl_Group tabMixer { | ||
2650 | label Mixer open | ||
2651 | xywh {0 45 605 463} color 52 labelfont 1 labelsize 12 hide | ||
2652 | } { | ||
2653 | Fl_Group mixer {open | ||
2654 | xywh {0 49 605 456} color 53 selection_color 53 align 0 | ||
2655 | code0 {o->set_ui(this);} | ||
2656 | class MixerUI | ||
2657 | } {} | ||
2658 | } | ||
2659 | Fl_Group tabCopyToPC { | ||
2660 | label {Copy to PC} open | ||
2661 | xywh {5 50 600 455} color 52 labelfont 1 labelsize 12 hide | ||
2662 | } { | ||
2663 | Fl_Check_Button {} { | ||
2664 | xywh {85 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2665 | code0 {track[0]=o;} | ||
2666 | } | ||
2667 | Fl_Check_Button {} { | ||
2668 | xywh {105 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2669 | code0 {track[1]=o;} | ||
2670 | } | ||
2671 | Fl_Check_Button {} { | ||
2672 | xywh {125 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2673 | code0 {track[2]=o;} | ||
2674 | } | ||
2675 | Fl_Check_Button {} { | ||
2676 | xywh {145 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2677 | code0 {track[3]=o;} | ||
2678 | } | ||
2679 | Fl_Check_Button {} { | ||
2680 | xywh {165 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2681 | code0 {track[4]=o;} | ||
2682 | } | ||
2683 | Fl_Check_Button {} { | ||
2684 | xywh {185 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2685 | code0 {track[5]=o;} | ||
2686 | } | ||
2687 | Fl_Check_Button {} { | ||
2688 | xywh {205 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2689 | code0 {track[6]=o;} | ||
2690 | } | ||
2691 | Fl_Check_Button {} { | ||
2692 | xywh {225 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2693 | code0 {track[7]=o;} | ||
2694 | } | ||
2695 | Fl_Check_Button {} { | ||
2696 | xywh {255 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2697 | code0 {track[8]=o;} | ||
2698 | } | ||
2699 | Fl_Check_Button {} { | ||
2700 | xywh {275 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2701 | code0 {track[9]=o;} | ||
2702 | } | ||
2703 | Fl_Check_Button {} { | ||
2704 | xywh {295 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2705 | code0 {track[10]=o;} | ||
2706 | } | ||
2707 | Fl_Check_Button {} { | ||
2708 | xywh {315 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2709 | code0 {track[11]=o;} | ||
2710 | } | ||
2711 | Fl_Check_Button {} { | ||
2712 | xywh {335 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2713 | code0 {track[12]=o;} | ||
2714 | } | ||
2715 | Fl_Check_Button {} { | ||
2716 | xywh {355 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2717 | code0 {track[13]=o;} | ||
2718 | } | ||
2719 | Fl_Check_Button {} { | ||
2720 | xywh {375 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2721 | code0 {track[14]=o;} | ||
2722 | } | ||
2723 | Fl_Check_Button {} { | ||
2724 | xywh {395 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2725 | code0 {track[15]=o;} | ||
2726 | } | ||
2727 | Fl_Check_Button {} { | ||
2728 | xywh {425 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2729 | code0 {track[16]=o;} | ||
2730 | } | ||
2731 | Fl_Check_Button {} { | ||
2732 | xywh {445 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2733 | code0 {track[17]=o;} | ||
2734 | } | ||
2735 | Fl_Check_Button {} { | ||
2736 | xywh {465 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2737 | code0 {track[18]=o;} | ||
2738 | } | ||
2739 | Fl_Check_Button {} { | ||
2740 | xywh {485 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2741 | code0 {track[19]=o;} | ||
2742 | } | ||
2743 | Fl_Check_Button {} { | ||
2744 | xywh {505 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2745 | code0 {track[20]=o;} | ||
2746 | } | ||
2747 | Fl_Check_Button {} { | ||
2748 | xywh {525 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2749 | code0 {track[21]=o;} | ||
2750 | } | ||
2751 | Fl_Check_Button {} { | ||
2752 | xywh {545 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2753 | code0 {track[22]=o;} | ||
2754 | } | ||
2755 | Fl_Check_Button {} { | ||
2756 | xywh {565 92 20 20} down_box DOWN_BOX value 1 labelsize 12 align 1 | ||
2757 | code0 {track[23]=o;} | ||
2758 | } | ||
2759 | Fl_Box {} { | ||
2760 | label {Tracks:} | ||
2761 | xywh {15 79 70 16} box FLAT_BOX color 52 labelsize 12 align 20 | ||
2762 | } | ||
2763 | Fl_Button button_invert_tracks { | ||
2764 | label Invert | ||
2765 | callback {int i; | ||
2766 | for (i=0; i<MAXCHANNELS; i++) { | ||
2767 | track[i]->value(1-track[i]->value()); | ||
2768 | }} | ||
2769 | xywh {15 92 65 20} labelsize 12 align 16 | ||
2770 | } | ||
2771 | Fl_Box led1 { | ||
2772 | label 01 | ||
2773 | xywh {85 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2774 | code0 {this->trackled[0]=o;} | ||
2775 | } | ||
2776 | Fl_Box led2 { | ||
2777 | label 02 | ||
2778 | xywh {105 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2779 | code0 {this->trackled[1]=o;} | ||
2780 | } | ||
2781 | Fl_Box led3 { | ||
2782 | label 03 | ||
2783 | xywh {125 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2784 | code0 {this->trackled[2]=o;} | ||
2785 | } | ||
2786 | Fl_Box led4 { | ||
2787 | label 04 | ||
2788 | xywh {145 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2789 | code0 {this->trackled[3]=o;} | ||
2790 | } | ||
2791 | Fl_Box led5 { | ||
2792 | label 05 | ||
2793 | xywh {165 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2794 | code0 {this->trackled[4]=o;} | ||
2795 | } | ||
2796 | Fl_Box led6 { | ||
2797 | label 06 | ||
2798 | xywh {185 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2799 | code0 {this->trackled[5]=o;} | ||
2800 | } | ||
2801 | Fl_Box led7 { | ||
2802 | label 07 | ||
2803 | xywh {205 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2804 | code0 {this->trackled[6]=o;} | ||
2805 | } | ||
2806 | Fl_Box led8 { | ||
2807 | label 08 | ||
2808 | xywh {225 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2809 | code0 {this->trackled[7]=o;} | ||
2810 | } | ||
2811 | Fl_Box led9 { | ||
2812 | label 09 | ||
2813 | xywh {255 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2814 | code0 {this->trackled[8]=o;} | ||
2815 | } | ||
2816 | Fl_Box led10 { | ||
2817 | label 10 | ||
2818 | xywh {275 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2819 | code0 {this->trackled[9]=o;} | ||
2820 | } | ||
2821 | Fl_Box led11 { | ||
2822 | label 11 | ||
2823 | xywh {295 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2824 | code0 {this->trackled[10]=o;} | ||
2825 | } | ||
2826 | Fl_Box led12 { | ||
2827 | label 12 | ||
2828 | xywh {315 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2829 | code0 {this->trackled[11]=o;} | ||
2830 | } | ||
2831 | Fl_Box led13 { | ||
2832 | label 13 | ||
2833 | xywh {335 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2834 | code0 {this->trackled[12]=o;} | ||
2835 | } | ||
2836 | Fl_Box led14 { | ||
2837 | label 14 | ||
2838 | xywh {355 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2839 | code0 {this->trackled[13]=o;} | ||
2840 | } | ||
2841 | Fl_Box led15 { | ||
2842 | label 15 | ||
2843 | xywh {375 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2844 | code0 {this->trackled[14]=o;} | ||
2845 | } | ||
2846 | Fl_Box led16 { | ||
2847 | label 16 | ||
2848 | xywh {395 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2849 | code0 {this->trackled[15]=o;} | ||
2850 | } | ||
2851 | Fl_Box led17 { | ||
2852 | label 17 | ||
2853 | xywh {424 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2854 | code0 {this->trackled[16]=o;} | ||
2855 | } | ||
2856 | Fl_Box led18 { | ||
2857 | label 18 | ||
2858 | xywh {444 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2859 | code0 {this->trackled[17]=o;} | ||
2860 | } | ||
2861 | Fl_Box led19 { | ||
2862 | label 19 | ||
2863 | xywh {464 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2864 | code0 {this->trackled[18]=o;} | ||
2865 | } | ||
2866 | Fl_Box led20 { | ||
2867 | label 20 | ||
2868 | xywh {484 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2869 | code0 {this->trackled[19]=o;} | ||
2870 | } | ||
2871 | Fl_Box led21 { | ||
2872 | label 21 | ||
2873 | xywh {504 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2874 | code0 {this->trackled[20]=o;} | ||
2875 | } | ||
2876 | Fl_Box led22 { | ||
2877 | label 22 | ||
2878 | xywh {524 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2879 | code0 {this->trackled[21]=o;} | ||
2880 | } | ||
2881 | Fl_Box led23 { | ||
2882 | label 23 | ||
2883 | xywh {544 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2884 | code0 {this->trackled[22]=o;} | ||
2885 | } | ||
2886 | Fl_Box led24 { | ||
2887 | label 24 | ||
2888 | xywh {564 80 20 14} box FLAT_BOX color 52 selection_color 0 labelsize 12 | ||
2889 | code0 {this->trackled[23]=o;} | ||
2890 | } | ||
2891 | Fl_Button button_transfertopc { | ||
2892 | label Transfer | ||
2893 | callback {recorder->control->button_stop_call(); | ||
2894 | mustdisplaytimer=false; | ||
2895 | __sint64 bytestransferred=0; | ||
2896 | transeng->sizelimit(strtoll(sizelimit->value(),0,10)); | ||
2897 | |||
2898 | int bytespersam; | ||
2899 | int wantsplit=0; | ||
2900 | __uint32 numsongs=1; | ||
2901 | double dif; | ||
2902 | __sint64 totbytestotransfer=0; | ||
2903 | |||
2904 | bool needoverwrite=false; | ||
2905 | bool isproblem=false; | ||
2906 | __uint32 channelstotransfer=0; | ||
2907 | |||
2908 | __uint32 i=0; | ||
2909 | |||
2910 | transfer_cancel=0; | ||
2911 | |||
2912 | if (currproj==NULL) | ||
2913 | { | ||
2914 | \#if (HD24DEBUG==1) | ||
2915 | cout << "No current project." << endl; | ||
2916 | \#endif | ||
2917 | return; | ||
2918 | } | ||
2919 | |||
2920 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
2921 | //jack_client_t* saveclient=jackclient; | ||
2922 | //jackclient=NULL; | ||
2923 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
2924 | |||
2925 | if (!(hd24utils::dirExists(projectdir->value()))) | ||
2926 | { | ||
2927 | fl_message("Project directory no longer exists.\\nPlease select another directory and try again."); | ||
2928 | //jackclient=saveclient; | ||
2929 | \#if (HD24DEBUG==1) | ||
2930 | cout << "project dir no longer exists, transfer cancelled." << endl; | ||
2931 | \#endif | ||
2932 | |||
2933 | return; | ||
2934 | } | ||
2935 | transeng->setstatusfunction=HD24UserInterface::transferstatus; | ||
2936 | transeng->projectdir(projectdir->value()); | ||
2937 | transeng->set_ui((void*)this); | ||
2938 | transeng->mixer(this->mixer->control); | ||
2939 | transeng->soundfile=soundfile; | ||
2940 | bool channelwarning=false; | ||
2941 | int currfileformat=0; | ||
2942 | bool multisong=false; | ||
2943 | if (currsong==NULL) | ||
2944 | { | ||
2945 | multisong=true; | ||
2946 | } | ||
2947 | else | ||
2948 | { | ||
2949 | // count channels to transfer | ||
2950 | __uint32 channels=currsong->logical_channels(); | ||
2951 | for (unsigned int handle=0;handle<channels;handle++) | ||
2952 | { | ||
2953 | if (track[handle]->value()!=0) | ||
2954 | { | ||
2955 | channelstotransfer++; | ||
2956 | transeng->trackselected(handle,true); | ||
2957 | } | ||
2958 | else | ||
2959 | { | ||
2960 | transeng->trackselected(handle,false); | ||
2961 | } | ||
2962 | } | ||
2963 | |||
2964 | transeng->mixleft( (transfersource_mixleft->value())==1); | ||
2965 | transeng->mixright( (transfersource_mixright->value()) ==1); | ||
2966 | |||
2967 | currfileformat=fileformat->value(); | ||
2968 | |||
2969 | transeng->selectedformat(currfileformat); | ||
2970 | |||
2971 | if (transeng->format_outputchannels(currfileformat)>1) | ||
2972 | { | ||
2973 | if ((channelstotransfer%(transeng->format_outputchannels(currfileformat)))!=0) | ||
2974 | { | ||
2975 | channelwarning=true; | ||
2976 | } | ||
2977 | } | ||
2978 | |||
2979 | } | ||
2980 | |||
2981 | if (multisong) | ||
2982 | { | ||
2983 | numsongs=currproj->songcount(); | ||
2984 | } | ||
2985 | if (channelwarning) | ||
2986 | { | ||
2987 | string multiple="Number of channels to export must be a multiple of "; | ||
2988 | string* mynum=Convert::int2str(transeng->format_outputchannels(currfileformat)); | ||
2989 | multiple+=*mynum; | ||
2990 | if (transeng->format_outputchannels(currfileformat)==2) | ||
2991 | { | ||
2992 | multiple+="\\nto export to stereo pairs."; | ||
2993 | } else { | ||
2994 | multiple+="\\nfor export to groups of "; | ||
2995 | multiple+=*mynum; | ||
2996 | multiple+=" channels."; | ||
2997 | } | ||
2998 | fl_message("%s",multiple.c_str()); | ||
2999 | delete mynum; | ||
3000 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
3001 | // jackclient=saveclient; | ||
3002 | |||
3003 | |||
3004 | return; | ||
3005 | |||
3006 | } | ||
3007 | if (numsongs==0) | ||
3008 | { | ||
3009 | \#if (HD24DEBUG==1) | ||
3010 | cout << "multisong transfer: no songs in current project." << endl; | ||
3011 | \#endif | ||
3012 | fl_message("Nothing to do!"); | ||
3013 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
3014 | // jackclient=saveclient; | ||
3015 | |||
3016 | return; | ||
3017 | } | ||
3018 | int havedoublesongname=0; | ||
3019 | if (multisong && (numsongs>1)) | ||
3020 | { | ||
3021 | // check if any song names are duplicated | ||
3022 | hd24song* s1=NULL; | ||
3023 | hd24song* s2=NULL; | ||
3024 | for (unsigned i=1; i<numsongs; i++) | ||
3025 | { | ||
3026 | if (s1!=NULL) { | ||
3027 | delete s1; | ||
3028 | s1=NULL; | ||
3029 | } | ||
3030 | s1=currproj->getsong(i); | ||
3031 | string* songname1=s1->songname(); | ||
3032 | for (unsigned int j=i+1; j<=numsongs; j++) { | ||
3033 | if (s2!=NULL) { | ||
3034 | delete s2; | ||
3035 | s2=NULL; | ||
3036 | } | ||
3037 | s2=currproj->getsong(j); | ||
3038 | string* songname2=s2->songname(); | ||
3039 | if (*songname1==*songname2) { | ||
3040 | havedoublesongname=1; | ||
3041 | } | ||
3042 | delete songname2; | ||
3043 | if (havedoublesongname==1) break; | ||
3044 | } | ||
3045 | delete songname1; | ||
3046 | if (havedoublesongname==1) break; | ||
3047 | } | ||
3048 | if (s1!=NULL) { | ||
3049 | delete s1; | ||
3050 | s1=NULL; | ||
3051 | } | ||
3052 | if (s2!=NULL) { | ||
3053 | delete s2; | ||
3054 | s2=NULL; | ||
3055 | } | ||
3056 | } | ||
3057 | if (havedoublesongname==1) | ||
3058 | { | ||
3059 | if (!confirm( | ||
3060 | "Duplicate song names were detected. If you continue, \\n" | ||
3061 | "exported songs will be prefixed with the song number. \\n\\n" | ||
3062 | "If you prefer to name the songs before export, you will\\n" | ||
3063 | "want to stop now.\\n\\n" | ||
3064 | "Do you wish to continue?" | ||
3065 | ) | ||
3066 | ) { | ||
3067 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
3068 | // jackclient=saveclient; | ||
3069 | return; | ||
3070 | }; | ||
3071 | } | ||
3072 | // preparation for the transfers | ||
3073 | for (i=1; i<=numsongs; i++) | ||
3074 | { | ||
3075 | if (multisong) | ||
3076 | { | ||
3077 | if (currsong!=NULL) { | ||
3078 | delete currsong; | ||
3079 | currsong=NULL; | ||
3080 | } | ||
3081 | currsong=currproj->getsong(i); | ||
3082 | if (currsong!=NULL) | ||
3083 | { | ||
3084 | channelstotransfer=currsong->logical_channels(); | ||
3085 | choice_startloc=0; | ||
3086 | choice_endloc=currsong->locatepointcount(); | ||
3087 | } | ||
3088 | } | ||
3089 | \#if (HD24DEBUG==1) | ||
3090 | cout << "channels to transfer=" << channelstotransfer << endl; | ||
3091 | \#endif | ||
3092 | __uint64 bytestotransfer_perchannel=0; | ||
3093 | __uint64 bytestotransfer_thissong=0; | ||
3094 | transeng->sourcesong(currsong); | ||
3095 | if (currsong!=NULL) | ||
3096 | { | ||
3097 | bytespersam=(currsong->bitdepth())/8; | ||
3098 | // for kb/sec calculation | ||
3099 | // because of this, double at higher sample rates | ||
3100 | |||
3101 | __uint32 samstotrans_thissong; | ||
3102 | if (multisong) | ||
3103 | { | ||
3104 | samstotrans_thissong=currsong->songlength_in_samples(); | ||
3105 | transeng->startoffset(0); | ||
3106 | transeng->endoffset(currsong->songlength_in_samples()); | ||
3107 | } | ||
3108 | else | ||
3109 | { | ||
3110 | __uint32 startoffset=0; | ||
3111 | __uint32 endoffset=0; | ||
3112 | |||
3113 | if (choice_startloc!=0) { | ||
3114 | startoffset=currsong->getlocatepos(choice_startloc); | ||
3115 | } | ||
3116 | if (choice_endloc!=0) | ||
3117 | { | ||
3118 | endoffset=currsong->getlocatepos(choice_endloc); | ||
3119 | } | ||
3120 | transeng->startoffset(startoffset); | ||
3121 | transeng->endoffset(endoffset); | ||
3122 | if (endoffset>startoffset) | ||
3123 | { | ||
3124 | samstotrans_thissong=endoffset-startoffset; | ||
3125 | } | ||
3126 | else | ||
3127 | { | ||
3128 | samstotrans_thissong=startoffset-endoffset; | ||
3129 | } | ||
3130 | } | ||
3131 | \#if (HD24DEBUG==1) | ||
3132 | cout << "sams to transfer for this song=" << samstotrans_thissong << endl ; | ||
3133 | \#endif | ||
3134 | if (samstotrans_thissong==0xFFFFFFFF) | ||
3135 | { | ||
3136 | bool wanttransfer=confirm( | ||
3137 | "You are trying to transfer the maximum song size possible\\n" | ||
3138 | "(more than twenty hours or 300 Gigabytes of audio). \\n\\n" | ||
3139 | "HD24tools will gladly try to perform this transfer for you,\\n" | ||
3140 | "but it will take VERY LONG, and is probably not very helpful\\n" | ||
3141 | "to you.\\n\\n" | ||
3142 | "If you are currently trying to recover audio, you probably\\n" | ||
3143 | "forgot to set the export range (with the 'Range...' button\\n" | ||
3144 | "above). It is highly recommended to listen to your audio\\n" | ||
3145 | "and set two locate points before setting the export range.\\n\\n" | ||
3146 | "Do you want to perform this long and possibly useless\\n" | ||
3147 | "transfer anyway?"); | ||
3148 | if (!(wanttransfer)) return; | ||
3149 | } | ||
3150 | |||
3151 | bytestotransfer_perchannel=(__sint64)((__sint64)samstotrans_thissong*(__sint64)bytespersam); | ||
3152 | |||
3153 | // hi-samplerate correction: | ||
3154 | bytestotransfer_perchannel*=(currsong->physical_channels()/currsong->logical_channels()); | ||
3155 | bytestotransfer_thissong=(channelstotransfer*bytestotransfer_perchannel); | ||
3156 | |||
3157 | totbytestotransfer+=bytestotransfer_thissong; | ||
3158 | |||
3159 | if (!(needoverwrite)) | ||
3160 | { | ||
3161 | needoverwrite=anyfilesexist(currsong); | ||
3162 | } | ||
3163 | } | ||
3164 | |||
3165 | |||
3166 | /* The above number equals 2 giga/4, to bypass format limitations. | ||
3167 | For 24-bit samples 2 giga/3 would suffice but some space could | ||
3168 | be needed by headers etc. */ | ||
3169 | __uint64 MAXBYTES=transeng->sizelimit(); | ||
3170 | // max number of samples per giga is half for high samplerate files | ||
3171 | if (multisong) | ||
3172 | { | ||
3173 | delete currsong; | ||
3174 | currsong=NULL; | ||
3175 | } | ||
3176 | \#if (HD24DEBUG==1) | ||
3177 | cout << "Maxbytes per channel=" << MAXBYTES ; | ||
3178 | cout << "bytes per channel=" << bytestotransfer_perchannel << endl; | ||
3179 | \#endif | ||
3180 | if (bytestotransfer_perchannel>MAXBYTES) | ||
3181 | { | ||
3182 | if (wantsplit!=1) | ||
3183 | { | ||
3184 | /* | ||
3185 | int choice=fl_choice( | ||
3186 | "Exported audio files may be too large to play or edit. \\nDo you want to export the file as multiple smaller chunks?", | ||
3187 | "Yes","No","Cancel" | ||
3188 | ); | ||
3189 | if (choice==2) | ||
3190 | { | ||
3191 | \#if (HD24DEBUG==1) | ||
3192 | cout << "user cancelled too large file transfer" << endl; | ||
3193 | \#endif | ||
3194 | //jackclient=saveclient; | ||
3195 | return; // cancelled | ||
3196 | } | ||
3197 | if (choice==0) | ||
3198 | { | ||
3199 | wantsplit=1; | ||
3200 | } | ||
3201 | */ | ||
3202 | if (autosplit->value()==1) { | ||
3203 | wantsplit=1; | ||
3204 | } | ||
3205 | } | ||
3206 | } | ||
3207 | } | ||
3208 | if (multisong) | ||
3209 | { | ||
3210 | if (currsong!=NULL) { | ||
3211 | delete currsong; | ||
3212 | currsong=NULL; | ||
3213 | } | ||
3214 | } | ||
3215 | |||
3216 | // do we need to overwrite any files? Are we allowed to? | ||
3217 | if (needoverwrite) | ||
3218 | { | ||
3219 | isproblem=(!(confirm("One or more output files already exist. Do you want to overwrite them?"))); | ||
3220 | } | ||
3221 | |||
3222 | if (isproblem) | ||
3223 | { | ||
3224 | \#if (HD24DEBUG==1) | ||
3225 | cout << "user does not wish to perform needed overwrite." << endl; | ||
3226 | \#endif | ||
3227 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
3228 | // jackclient=saveclient; | ||
3229 | return; | ||
3230 | } | ||
3231 | |||
3232 | // needed to check for dir to make sure about existence of output files | ||
3233 | // but the previous question may have given the user the time to mess up. | ||
3234 | // check the dir again :) | ||
3235 | |||
3236 | if (!(hd24utils::dirExists(projectdir->value()))) | ||
3237 | { | ||
3238 | fl_message("Project directory no longer exists.\\nPlease select another directory and try again."); | ||
3239 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
3240 | // jackclient=saveclient; | ||
3241 | \#if (HD24DEBUG==1) | ||
3242 | cout << "project directory deleted" << endl; | ||
3243 | \#endif | ||
3244 | return; | ||
3245 | } | ||
3246 | \#if (HD24DEBUG==1) | ||
3247 | cout << "by calc, tot bytes to transfer=" << totbytestotransfer << endl; | ||
3248 | \#endif | ||
3249 | |||
3250 | deactivate_ui(); | ||
3251 | setstatus("Transferring audio to PC... 0%"); | ||
3252 | time (&starttime); | ||
3253 | int somethingwrong=0; | ||
3254 | for (i=1; i<=numsongs; i++) | ||
3255 | { | ||
3256 | \#if (HD24DEBUG==1) | ||
3257 | cout << "set song" << endl; | ||
3258 | \#endif | ||
3259 | if (transfer_cancel!=0) | ||
3260 | { | ||
3261 | \#if (HD24DEBUG==1) | ||
3262 | cout << "transfer cancelled by user." << endl; | ||
3263 | \#endif | ||
3264 | break; | ||
3265 | } | ||
3266 | |||
3267 | if (multisong) | ||
3268 | { | ||
3269 | if (currsong!=NULL) { | ||
3270 | delete currsong; | ||
3271 | currsong=NULL; | ||
3272 | } | ||
3273 | currsong=currproj->getsong(i); | ||
3274 | } | ||
3275 | transeng->sourcesong(currsong); | ||
3276 | if (currsong==NULL) | ||
3277 | { | ||
3278 | \#if (HD24DEBUG==1) | ||
3279 | cout << "currsong=null, nothing to transfer" << endl; | ||
3280 | \#endif | ||
3281 | continue; | ||
3282 | } | ||
3283 | \#if (HD24DEBUG==1) | ||
3284 | cout << "calling ftransfer with "; | ||
3285 | cout << "sonnum=" << i; | ||
3286 | cout << ", numsongs=" << numsongs; | ||
3287 | cout << ", totlen(bytes)=" << totbytestotransfer; | ||
3288 | cout << ", bytestransferred=" << bytestransferred; | ||
3289 | cout << ", wantsplit=" << wantsplit << endl; | ||
3290 | \#endif | ||
3291 | |||
3292 | transeng->prepare_transfer_to_pc(i,numsongs,totbytestotransfer,bytestransferred,wantsplit,(havedoublesongname==1)?(i):(0)); | ||
3293 | __sint64 currtransferred=transeng->transfer_to_pc(); | ||
3294 | if (currtransferred==0) | ||
3295 | { | ||
3296 | somethingwrong=1; | ||
3297 | break; | ||
3298 | } | ||
3299 | bytestransferred+=currtransferred; | ||
3300 | |||
3301 | if (multisong) | ||
3302 | { | ||
3303 | delete currsong; | ||
3304 | currsong=NULL; | ||
3305 | } | ||
3306 | |||
3307 | } | ||
3308 | |||
3309 | |||
3310 | if (multisong) | ||
3311 | { | ||
3312 | if (currsong!=NULL) | ||
3313 | { | ||
3314 | delete currsong; | ||
3315 | currsong=NULL; | ||
3316 | } | ||
3317 | } | ||
3318 | |||
3319 | /* TODO: DISABLE/ENABLE JACK BEFORE/AFTER TRANSFER */ | ||
3320 | //jackclient=saveclient; | ||
3321 | if (somethingwrong==1) | ||
3322 | { | ||
3323 | activate_ui(); | ||
3324 | if (transeng->lasterror()!=NULL) | ||
3325 | { | ||
3326 | |||
3327 | setstatus(transeng->lasterror()->c_str()); | ||
3328 | } | ||
3329 | else | ||
3330 | { | ||
3331 | setstatus((const char*)&"Unexpected error transferring files."); | ||
3332 | } | ||
3333 | stop_transfer->hide(); | ||
3334 | return; | ||
3335 | } | ||
3336 | |||
3337 | time (&endtime); | ||
3338 | dif=difftime(endtime,starttime); | ||
3339 | //__uint32 subsecs=(__uint32)(100*(dif-floor(dif))); | ||
3340 | dif=floor(dif); | ||
3341 | __uint32 minutes=((__uint32)dif-((__uint32)dif%60))/60; | ||
3342 | __uint32 seconds=((__uint32)dif%60); | ||
3343 | |||
3344 | string minsec="Ready. Transfer time: "; | ||
3345 | if (transfer_cancel==1) | ||
3346 | { | ||
3347 | minsec="Transfer cancelled. Elapsed transfer time: "; | ||
3348 | } | ||
3349 | transfer_cancel=0; | ||
3350 | string* strmins=Convert::int2str(minutes,2,"0"); | ||
3351 | minsec+=*strmins; | ||
3352 | delete (strmins); | ||
3353 | minsec+=":"; | ||
3354 | string* strsecs=Convert::int2str(seconds,2,"0"); | ||
3355 | minsec+=*strsecs; | ||
3356 | delete(strsecs); | ||
3357 | |||
3358 | if (dif>=1) | ||
3359 | { | ||
3360 | __uint32 kbps=(__uint32)(((bytestransferred)/1024)/dif); | ||
3361 | |||
3362 | minsec+=" ("; | ||
3363 | string* strkbps=Convert::int2str(kbps); | ||
3364 | minsec+=*strkbps; | ||
3365 | minsec+=" kB/sec)"; | ||
3366 | delete(strkbps); | ||
3367 | } | ||
3368 | activate_ui(); | ||
3369 | setstatus(minsec.c_str()); | ||
3370 | stop_transfer->hide();} | ||
3371 | xywh {530 480 70 20} labelsize 12 align 16 | ||
3372 | code0 {o->label("Transfer");} | ||
3373 | } | ||
3374 | Fl_Button {} { | ||
3375 | label {Browse...} | ||
3376 | callback {Fl_Native_File_Chooser chooser; | ||
3377 | chooser.title("Select project directory"); | ||
3378 | chooser.type(Fl_Native_File_Chooser::BROWSE_DIRECTORY); | ||
3379 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
3380 | chooser.filter(""); | ||
3381 | |||
3382 | string currdir=""; | ||
3383 | currdir+=projectdir->value(); | ||
3384 | |||
3385 | chooser.directory(currdir.c_str()); | ||
3386 | switch (chooser.show()) { | ||
3387 | case -1: break; //error | ||
3388 | case 1: break; //cancel | ||
3389 | default: | ||
3390 | if (chooser.filename()) { | ||
3391 | projectdir->value(chooser.filename()); | ||
3392 | hd24utils::setlastdir("projdir",chooser.filename()); | ||
3393 | } | ||
3394 | |||
3395 | break; | ||
3396 | }} | ||
3397 | xywh {505 175 85 20} labelsize 12 align 16 | ||
3398 | } | ||
3399 | Fl_Input projectdir { | ||
3400 | label {Project dir:} | ||
3401 | callback {/* callback when release: add a | ||
3402 | (back)slash to the end of the | ||
3403 | pathname if one is not present. */ | ||
3404 | |||
3405 | \#ifdef WINDOWS | ||
3406 | \#define MYSLASH '\\\\' | ||
3407 | \#else | ||
3408 | \#define MYSLASH '/' | ||
3409 | \#endif | ||
3410 | char* x=(char*)projectdir->value(); | ||
3411 | if (strlen(x)==0) { | ||
3412 | x[0]=MYSLASH; | ||
3413 | x[1]=0; | ||
3414 | } else { | ||
3415 | int q=strlen(x); | ||
3416 | if (x[q-1]!=MYSLASH) { | ||
3417 | x[q]=MYSLASH; | ||
3418 | x[q+1]=0; | ||
3419 | } | ||
3420 | } | ||
3421 | projectdir->value(x); | ||
3422 | hd24utils::setlastdir("projdir",projectdir->value());} | ||
3423 | xywh {85 175 415 20} labelsize 12 textsize 12 | ||
3424 | code0 {getlastprojdir(o);} | ||
3425 | code1 {/*o->clear_visible_focus();*/} | ||
3426 | } | ||
3427 | Fl_Output fromtime { | ||
3428 | label {From:} | ||
3429 | xywh {265 115 105 20} labelsize 12 textsize 12 | ||
3430 | code0 {o->clear_visible_focus();} | ||
3431 | } | ||
3432 | Fl_Output totime { | ||
3433 | label {To:} | ||
3434 | xywh {395 115 105 20} labelsize 12 textsize 12 | ||
3435 | code0 {o->clear_visible_focus();} | ||
3436 | } | ||
3437 | Fl_Button fromto { | ||
3438 | label {Range...} | ||
3439 | callback {if (currsong==NULL) return; | ||
3440 | dialog_fromto* ui_fromto; | ||
3441 | ui_fromto=new dialog_fromto; | ||
3442 | |||
3443 | Fl_Window *win=ui_fromto->make_window(currsong); | ||
3444 | populate_locatepoints(currsong,ui_fromto->fromloc); | ||
3445 | populate_locatepoints(currsong,ui_fromto->toloc); | ||
3446 | ui_fromto->fromloc->value(choice_startloc); | ||
3447 | ui_fromto->toloc->value(choice_endloc); | ||
3448 | win->end(); | ||
3449 | win->show(); | ||
3450 | |||
3451 | while (win->visible()) { Fl::wait(); } | ||
3452 | |||
3453 | /* Dialog has closed, read the results */ | ||
3454 | //if (ui_fromto->buttonclicked==0) | ||
3455 | //{ fl_message("No OK nor Cancel clicked"); } | ||
3456 | if (ui_fromto->buttonclicked==1) | ||
3457 | { | ||
3458 | // OK clicked | ||
3459 | choice_startloc=ui_fromto->choice_startloc; | ||
3460 | choice_endloc=ui_fromto->choice_endloc; | ||
3461 | update_fromto(); | ||
3462 | } | ||
3463 | //if (ui_fromto->buttonclicked==2) | ||
3464 | //{ fl_message("Cancel clicked"); } | ||
3465 | delete ui_fromto;} | ||
3466 | xywh {505 115 85 20} labelsize 12 align 16 | ||
3467 | } | ||
3468 | Fl_Choice fileformat { | ||
3469 | label {File format:} open | ||
3470 | xywh {85 200 160 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
3471 | } {} | ||
3472 | Fl_Check_Button autosplit { | ||
3473 | label {Automatically limit size of exported files} | ||
3474 | callback {if (autosplit->value()==1) { | ||
3475 | sizelimitdropdown->activate(); | ||
3476 | |||
3477 | if (sizelimitdropdown->value()==6) { | ||
3478 | sizelimit->activate(); | ||
3479 | } else { | ||
3480 | sizelimit->deactivate(); | ||
3481 | } | ||
3482 | } else { | ||
3483 | sizelimitdropdown->deactivate(); | ||
3484 | sizelimit->deactivate(); | ||
3485 | }} | ||
3486 | xywh {10 265 20 20} box FLAT_BOX down_box DOWN_BOX value 1 color 52 labelsize 12 align 8 | ||
3487 | } | ||
3488 | Fl_Input sizelimit { | ||
3489 | label bytes | ||
3490 | xywh {425 290 120 20} labelsize 12 align 8 textsize 12 | ||
3491 | code0 {long long x=1073741824LL; string* sval=Convert::int64tostr(x); o->value(sval->c_str()); delete sval; o->deactivate();} | ||
3492 | code1 {o->maximum_size(17);} | ||
3493 | } | ||
3494 | Fl_Box {} { | ||
3495 | label {Transfer target:} | ||
3496 | xywh {10 153 305 17} box FLAT_BOX color 52 labelfont 1 labelsize 12 align 20 | ||
3497 | } | ||
3498 | Fl_Box {} { | ||
3499 | label {Transfer options:} | ||
3500 | xywh {10 243 305 17} box FLAT_BOX color 52 labelfont 1 labelsize 12 align 20 | ||
3501 | } | ||
3502 | Fl_Box {} { | ||
3503 | label {Note: The actual file size will be a rough approximation of the requested split size.} | ||
3504 | xywh {30 318 550 17} box FLAT_BOX color 52 labelfont 2 labelsize 12 align 20 | ||
3505 | } | ||
3506 | Fl_Check_Button customrate { | ||
3507 | label {Stamp files with a custom sample rate} | ||
3508 | callback {if (customrate->value()==1) { | ||
3509 | ratechoice->activate(); | ||
3510 | if (ratechoice->value()==4) { | ||
3511 | stamprate->activate(); | ||
3512 | } else { | ||
3513 | stamprate->deactivate(); | ||
3514 | } | ||
3515 | } else { | ||
3516 | ratechoice->deactivate(); | ||
3517 | stamprate->deactivate(); | ||
3518 | }} | ||
3519 | xywh {10 345 20 20} box FLAT_BOX down_box DOWN_BOX color 52 labelsize 12 align 8 | ||
3520 | } | ||
3521 | Fl_Choice ratechoice { | ||
3522 | label {Sample rate:} open | ||
3523 | xywh {105 370 295 20} down_box BORDER_BOX labelsize 12 textsize 12 deactivate | ||
3524 | code0 {o->value(1);} | ||
3525 | } { | ||
3526 | MenuItem {} { | ||
3527 | label {44100 Hz} | ||
3528 | callback {long long x=44100LL; | ||
3529 | string* sval=Convert::int64tostr(x); | ||
3530 | stamprate->value(sval->c_str()); | ||
3531 | delete sval; | ||
3532 | stamprate->deactivate();} | ||
3533 | xywh {25 25 36 21} labelsize 12 | ||
3534 | } | ||
3535 | MenuItem {} { | ||
3536 | label {48000 Hz} | ||
3537 | callback {long long x=48000LL; | ||
3538 | string* sval=Convert::int64tostr(x); | ||
3539 | stamprate->value(sval->c_str()); | ||
3540 | delete sval; | ||
3541 | stamprate->deactivate();} | ||
3542 | xywh {35 35 36 21} labelsize 12 | ||
3543 | } | ||
3544 | MenuItem {} { | ||
3545 | label {88200 Hz} | ||
3546 | callback {long long x=88200LL; | ||
3547 | string* sval=Convert::int64tostr(x); | ||
3548 | stamprate->value(sval->c_str()); | ||
3549 | delete sval; | ||
3550 | stamprate->deactivate();} | ||
3551 | xywh {45 45 36 21} labelsize 12 | ||
3552 | } | ||
3553 | MenuItem {} { | ||
3554 | label {96000 Hz} | ||
3555 | callback {long long x=96000LL; | ||
3556 | string* sval=Convert::int64tostr(x); | ||
3557 | stamprate->value(sval->c_str()); | ||
3558 | delete sval; | ||
3559 | stamprate->deactivate();} | ||
3560 | xywh {55 55 36 21} labelsize 12 | ||
3561 | } | ||
3562 | MenuItem {} { | ||
3563 | label {User defined, specify -->} | ||
3564 | callback {stamprate->activate();} | ||
3565 | xywh {85 85 36 21} labelsize 12 | ||
3566 | } | ||
3567 | } | ||
3568 | Fl_Input stamprate { | ||
3569 | label Hz | ||
3570 | xywh {425 370 120 20} labelsize 12 align 8 textsize 12 deactivate | ||
3571 | code0 {long long x=48000; string* sval=Convert::int64tostr(x); o->value(sval->c_str()); delete sval; o->deactivate();} | ||
3572 | code1 {o->maximum_size(5);} | ||
3573 | } | ||
3574 | Fl_Choice sizelimitdropdown { | ||
3575 | label {Split every:} open | ||
3576 | tooltip 1 xywh {105 290 295 20} down_box BORDER_BOX labelsize 12 textsize 12 | ||
3577 | code0 {o->value(2);} | ||
3578 | } { | ||
3579 | MenuItem {} { | ||
3580 | label {650 MB (74 minute CD)} | ||
3581 | callback {long long x=650000000LL; | ||
3582 | string* sval=Convert::int64tostr(x); | ||
3583 | sizelimit->value(sval->c_str()); | ||
3584 | delete sval; | ||
3585 | sizelimit->deactivate();} | ||
3586 | xywh {20 20 36 21} labelsize 12 | ||
3587 | } | ||
3588 | MenuItem {} { | ||
3589 | label {700 MB (80 minute CD)} | ||
3590 | callback {long long x=700000000LL; | ||
3591 | string* sval=Convert::int64tostr(x); | ||
3592 | sizelimit->value(sval->c_str()); | ||
3593 | delete sval; | ||
3594 | sizelimit->deactivate();} | ||
3595 | xywh {30 30 36 21} labelsize 12 | ||
3596 | } | ||
3597 | MenuItem {} { | ||
3598 | label {1 GiB (Recommended for wave editors)} | ||
3599 | callback {long long x=1073741824LL; | ||
3600 | string* sval=Convert::int64tostr(x); | ||
3601 | sizelimit->value(sval->c_str()); | ||
3602 | delete sval; | ||
3603 | sizelimit->deactivate();} | ||
3604 | xywh {40 40 36 21} labelsize 12 | ||
3605 | } | ||
3606 | MenuItem {} { | ||
3607 | label {2 GiB (Max. legal WAV size)} | ||
3608 | callback {long long x=2147483648LL; | ||
3609 | string* sval=Convert::int64tostr(x); | ||
3610 | sizelimit->value(sval->c_str()); | ||
3611 | delete sval; | ||
3612 | sizelimit->deactivate();} | ||
3613 | xywh {50 50 36 21} labelsize 12 | ||
3614 | } | ||
3615 | MenuItem {} { | ||
3616 | label {4 GiB (Max. 32-bit limit)} | ||
3617 | callback {long long x=4294967296LL; | ||
3618 | string* sval=Convert::int64tostr(x); | ||
3619 | sizelimit->value(sval->c_str()); | ||
3620 | delete sval; | ||
3621 | sizelimit->deactivate();} | ||
3622 | xywh {60 60 36 21} labelsize 12 | ||
3623 | } | ||
3624 | MenuItem {} { | ||
3625 | label {4.7 GB (DVD size)} | ||
3626 | callback {long long x=4700000000LL; | ||
3627 | string* sval=Convert::int64tostr(x); | ||
3628 | sizelimit->value(sval->c_str()); | ||
3629 | delete sval; | ||
3630 | sizelimit->deactivate();} | ||
3631 | xywh {70 70 36 21} labelsize 12 | ||
3632 | } | ||
3633 | MenuItem {} { | ||
3634 | label {User defined, specify -->} | ||
3635 | callback {sizelimit->activate();} | ||
3636 | xywh {80 80 36 21} labelsize 12 | ||
3637 | } | ||
3638 | } | ||
3639 | Fl_Check_Button transfersource_mixleft { | ||
3640 | label {Mixer Left} | ||
3641 | callback {saverestoretrackselection(o);} | ||
3642 | xywh {85 115 20 20} down_box DOWN_BOX labelsize 12 align 4 | ||
3643 | } | ||
3644 | Fl_Check_Button transfersource_mixright { | ||
3645 | label Right | ||
3646 | callback {saverestoretrackselection(o);} | ||
3647 | xywh {105 115 20 20} down_box DOWN_BOX labelsize 12 align 8 | ||
3648 | } | ||
3649 | Fl_Group batch_stuff { | ||
3650 | label {batch stuff } open | ||
3651 | xywh {5 390 600 115} align 16 hide deactivate | ||
3652 | } { | ||
3653 | Fl_Box {} { | ||
3654 | label {Batch transfer list:} | ||
3655 | xywh {10 393 305 17} box FLAT_BOX color 52 labelfont 1 labelsize 12 align 20 deactivate | ||
3656 | } | ||
3657 | Fl_Output transfer_list { | ||
3658 | xywh {10 410 515 90} type Multiline labelsize 12 textsize 12 deactivate | ||
3659 | code0 {o->clear_visible_focus();} | ||
3660 | } | ||
3661 | Fl_Button button_addtobatch { | ||
3662 | label {To Batch} | ||
3663 | xywh {530 410 70 20} labelsize 12 align 16 deactivate | ||
3664 | } | ||
3665 | Fl_Button button_removefrombatch { | ||
3666 | label Remove | ||
3667 | xywh {530 430 70 20} labelsize 12 align 16 deactivate | ||
3668 | } | ||
3669 | } | ||
3670 | Fl_Output transfersource { | ||
3671 | label {Transfer source:} | ||
3672 | xywh {127 57 458 20} box NO_BOX labelfont 1 labelsize 12 textsize 12 | ||
3673 | } | ||
3674 | Fl_Button {} { | ||
3675 | label {?} | ||
3676 | callback {fl_message("This option allows you to limit the size of exported files. \\n" | ||
3677 | "In the dropdown box, the following units are used:\\n\\n" | ||
3678 | "MB - Megabyte, 1000x1000 bytes\\n" | ||
3679 | "GB - Gigabyte, 1000x1000x1000 bytes\\n" | ||
3680 | "GiB - Binary Gigabyte or Gibibyte, 1024x1024x1024 bytes\\n\\n" | ||
3681 | "In any situation, the actual byte count is displayed on the right.");} | ||
3682 | tooltip {Click here for an explanation about file splitting.} xywh {400 290 20 20} box FLAT_BOX down_box FLAT_BOX color 15 selection_color 15 labelfont 1 labelsize 11 labelcolor 7 | ||
3683 | } | ||
3684 | Fl_Button {} { | ||
3685 | label {?} | ||
3686 | callback {fl_message("Stamping files with another sample rates allows you \\n" | ||
3687 | "to export files with a sample rate that differs from the sample \\n" | ||
3688 | "rate at which the song was recorded. When using this option, \\n" | ||
3689 | "note that no resampling takes place; both the pitch and playback \\n" | ||
3690 | "speed will change compared to the original sample rate. ");} | ||
3691 | tooltip {Click here for an explanation about sample rate stamping} xywh {400 370 20 20} box FLAT_BOX down_box FLAT_BOX color 15 selection_color 15 labelfont 1 labelsize 11 labelcolor 7 | ||
3692 | } | ||
3693 | } | ||
3694 | Fl_Group tab_tohd24 { | ||
3695 | label {Copy to HD24} open | ||
3696 | xywh {0 45 605 461} color 52 labelfont 1 labelsize 12 | ||
3697 | } { | ||
3698 | Fl_Button button_transfertohd24 { | ||
3699 | label Transfer | ||
3700 | callback {recorder->control->button_stop_call(); //stop transport | ||
3701 | bool have_smpte=false; | ||
3702 | if (currproj==NULL) | ||
3703 | { | ||
3704 | fl_message("No project selected, nothing to do!\\nSelect a project on the Project/Song tab and try again."); | ||
3705 | return; | ||
3706 | } | ||
3707 | if (currsong==NULL) | ||
3708 | { | ||
3709 | fl_message("No song selected, nothing to do!\\nSelect a song on the Project/Song tab and try again."); | ||
3710 | return; | ||
3711 | } | ||
3712 | |||
3713 | int havefiles=0; | ||
3714 | for (unsigned int ch=1;ch<=currsong->logical_channels();ch++) { | ||
3715 | |||
3716 | if (strlen(filename[ch-1]->value())>0) { | ||
3717 | // track has a file selected | ||
3718 | havefiles=1; | ||
3719 | currsong->trackarmed(ch,true); | ||
3720 | continue; | ||
3721 | } | ||
3722 | int action=((Fl_Choice*)(trackaction[ch-1]))->value(); | ||
3723 | if (action==0) { /* 0=ERASE */ | ||
3724 | // track action says 'erase' | ||
3725 | havefiles=1; | ||
3726 | currsong->trackarmed(ch,true); | ||
3727 | continue; | ||
3728 | } | ||
3729 | if (action==1) { /* 1=SMPTE */ | ||
3730 | // track action says 'stripe with SMPTE/LTC' | ||
3731 | havefiles=1; | ||
3732 | have_smpte=true; | ||
3733 | currsong->trackarmed(ch,true); | ||
3734 | continue; | ||
3735 | } | ||
3736 | // no file, no timecode stripe and no erase, keep track. | ||
3737 | currsong->trackarmed(ch,false); | ||
3738 | |||
3739 | } | ||
3740 | if (havefiles==0) { | ||
3741 | fl_message( | ||
3742 | "To transfer files to the HD24, load one or more files.\\n" | ||
3743 | "Each file will be assigned to an empty track slot.\\n\\n" | ||
3744 | "Before transferring, you will be able to rearrange the\\n" | ||
3745 | "order of the tracks by clicking on one or more tracks\\n" | ||
3746 | "and clicking the up or down arrow buttons.\\n\\n" | ||
3747 | "When a track slot is empty, the existing track will be\\n" | ||
3748 | "preserved, unless 'Erase' or 'SMPTE' is selected on \\n" | ||
3749 | "the right of the track.\\n\\n" | ||
3750 | "When a file to transfer contains multiple tracks, you\\n" | ||
3751 | "can choose to mixdown the file to mono (the default), \\n" | ||
3752 | "or you can select the track that you want to transfer \\n" | ||
3753 | "to the HD24 drive." | ||
3754 | ); | ||
3755 | for (unsigned int ch=1;ch<=currsong->logical_channels();ch++) { | ||
3756 | currsong->trackarmed(ch,false); | ||
3757 | } | ||
3758 | return; | ||
3759 | } | ||
3760 | if (currsong->iswriteprotected()) | ||
3761 | { | ||
3762 | fl_message("The song is write protected."); | ||
3763 | for (unsigned int ch=1;ch<=currsong->logical_channels();ch++) { | ||
3764 | currsong->trackarmed(ch,false); | ||
3765 | } | ||
3766 | return; | ||
3767 | } | ||
3768 | // ask ARE YOU SURE???? | ||
3769 | bool sure=confirm("Are you sure you want to overwrite the existing audio?"); | ||
3770 | if (!sure) return; | ||
3771 | |||
3772 | // check if all files still exist | ||
3773 | |||
3774 | int filemissing=0; | ||
3775 | for (unsigned int misscheck=1;misscheck<=currsong->logical_channels();misscheck++) { | ||
3776 | if (strlen(filename[misscheck-1]->value())==0) continue; | ||
3777 | if (!(hd24utils::fileExists(filename[misscheck-1]->value()))) | ||
3778 | { | ||
3779 | filemissing=1; | ||
3780 | break; | ||
3781 | } | ||
3782 | } | ||
3783 | |||
3784 | if (filemissing==1) { | ||
3785 | fl_message("One or more files no longer exist. \\nPlease clear and reload the files, then try again."); | ||
3786 | return; | ||
3787 | } | ||
3788 | // end of checking if all files still exist | ||
3789 | transeng->targetsong(currsong); | ||
3790 | transeng->soundfile=soundfile; | ||
3791 | for (unsigned int filenum=1;filenum<=currsong->logical_channels();filenum++) | ||
3792 | { | ||
3793 | transeng->sourcefilename(filenum,filename[filenum-1]->value()); | ||
3794 | transeng->trackaction(filenum,((Fl_Choice*)(trackaction[filenum-1]))->value()); | ||
3795 | } | ||
3796 | transeng->transfer_to_hd24(); | ||
3797 | stop_transfer->hide(); | ||
3798 | if (transeng->lasterror()!=NULL) | ||
3799 | { | ||
3800 | if (transeng->lasterror()->c_str()!=NULL) | ||
3801 | { | ||
3802 | setstatus(transeng->lasterror()->c_str()); | ||
3803 | } | ||
3804 | else | ||
3805 | { | ||
3806 | setstatus("Done. No error messages."); | ||
3807 | } | ||
3808 | } else { | ||
3809 | setstatus("Done."); | ||
3810 | } | ||
3811 | ui_refresh("tohd24_done"); | ||
3812 | activate_ui(); | ||
3813 | fl_check();} selected | ||
3814 | xywh {530 480 70 20} labelsize 12 | ||
3815 | } | ||
3816 | Fl_Output filename1 { | ||
3817 | label {01 } | ||
3818 | callback {selectfilename(1);} | ||
3819 | xywh {40 50 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3820 | code0 {filename[0]=o;} | ||
3821 | } | ||
3822 | Fl_Output filename2 { | ||
3823 | label {02 } | ||
3824 | callback {selectfilename(2);} | ||
3825 | xywh {40 69 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3826 | code0 {filename[1]=o;} | ||
3827 | } | ||
3828 | Fl_Output filename3 { | ||
3829 | label {03 } | ||
3830 | callback {selectfilename(3);} | ||
3831 | xywh {40 88 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3832 | code0 {filename[2]=o;} | ||
3833 | } | ||
3834 | Fl_Output filename4 { | ||
3835 | label {04 } | ||
3836 | callback {selectfilename(4);} | ||
3837 | xywh {40 107 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3838 | code0 {filename[3]=o;} | ||
3839 | } | ||
3840 | Fl_Output filename5 { | ||
3841 | label {05 } | ||
3842 | callback {selectfilename(5);} | ||
3843 | xywh {40 126 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3844 | code0 {filename[4]=o;} | ||
3845 | } | ||
3846 | Fl_Output filename6 { | ||
3847 | label {06 } | ||
3848 | callback {selectfilename(6);} | ||
3849 | xywh {40 145 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3850 | code0 {filename[5]=o;} | ||
3851 | } | ||
3852 | Fl_Output filename7 { | ||
3853 | label {07 } | ||
3854 | callback {selectfilename(7);} | ||
3855 | xywh {40 164 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3856 | code0 {filename[6]=o;} | ||
3857 | } | ||
3858 | Fl_Output filename8 { | ||
3859 | label {08 } | ||
3860 | callback {selectfilename(8);} | ||
3861 | xywh {40 183 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3862 | code0 {filename[7]=o;} | ||
3863 | } | ||
3864 | Fl_Output filename9 { | ||
3865 | label {09 } | ||
3866 | callback {selectfilename(9);} | ||
3867 | xywh {40 202 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3868 | code0 {filename[8]=o;} | ||
3869 | } | ||
3870 | Fl_Output filename10 { | ||
3871 | label {10 } | ||
3872 | callback {selectfilename(10);} | ||
3873 | xywh {40 221 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3874 | code0 {filename[9]=o;} | ||
3875 | } | ||
3876 | Fl_Output filename11 { | ||
3877 | label {11 } | ||
3878 | callback {selectfilename(11);} | ||
3879 | xywh {40 240 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3880 | code0 {filename[10]=o;} | ||
3881 | } | ||
3882 | Fl_Output filename12 { | ||
3883 | label {12 } | ||
3884 | callback {selectfilename(12);} | ||
3885 | xywh {40 259 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3886 | code0 {filename[11]=o;} | ||
3887 | } | ||
3888 | Fl_Output filename13 { | ||
3889 | label {13 } | ||
3890 | callback {selectfilename(13);} | ||
3891 | xywh {40 278 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3892 | code0 {filename[12]=o;} | ||
3893 | } | ||
3894 | Fl_Output filename14 { | ||
3895 | label {14 } | ||
3896 | callback {selectfilename(14);} | ||
3897 | xywh {40 297 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3898 | code0 {filename[13]=o;} | ||
3899 | } | ||
3900 | Fl_Output filename15 { | ||
3901 | label {15 } | ||
3902 | callback {selectfilename(15);} | ||
3903 | xywh {40 316 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3904 | code0 {filename[14]=o;} | ||
3905 | } | ||
3906 | Fl_Output filename16 { | ||
3907 | label {16 } | ||
3908 | callback {selectfilename(16);} | ||
3909 | xywh {40 335 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3910 | code0 {filename[15]=o;} | ||
3911 | } | ||
3912 | Fl_Output filename17 { | ||
3913 | label {17 } | ||
3914 | callback {selectfilename(17);} | ||
3915 | xywh {40 354 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3916 | code0 {filename[16]=o;} | ||
3917 | } | ||
3918 | Fl_Output filename18 { | ||
3919 | label {18 } | ||
3920 | callback {selectfilename(18);} | ||
3921 | xywh {40 373 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3922 | code0 {filename[17]=o;} | ||
3923 | } | ||
3924 | Fl_Output filename19 { | ||
3925 | label {19 } | ||
3926 | callback {selectfilename(19);} | ||
3927 | xywh {40 392 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3928 | code0 {filename[18]=o;} | ||
3929 | } | ||
3930 | Fl_Output filename20 { | ||
3931 | label {20 } | ||
3932 | callback {selectfilename(20);} | ||
3933 | xywh {40 411 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3934 | code0 {filename[19]=o;} | ||
3935 | } | ||
3936 | Fl_Output filename21 { | ||
3937 | label {21 } | ||
3938 | callback {selectfilename(21);} | ||
3939 | xywh {40 430 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3940 | code0 {filename[20]=o;} | ||
3941 | } | ||
3942 | Fl_Output filename22 { | ||
3943 | label {22 } | ||
3944 | callback {selectfilename(22);} | ||
3945 | xywh {40 449 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3946 | code0 {filename[21]=o;} | ||
3947 | } | ||
3948 | Fl_Output filename23 { | ||
3949 | label {23 } | ||
3950 | callback {selectfilename(23);} | ||
3951 | xywh {40 468 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3952 | code0 {filename[22]=o;} | ||
3953 | } | ||
3954 | Fl_Output filename24 { | ||
3955 | label {24 } | ||
3956 | callback {selectfilename(24);} | ||
3957 | xywh {40 487 430 19} labelfont 1 labelsize 12 textsize 12 | ||
3958 | code0 {filename[23]=o;} | ||
3959 | } | ||
3960 | Fl_Repeat_Button button_moveup { | ||
3961 | callback {moveselected(-1);} | ||
3962 | image {images/up.gif} xywh {530 255 70 20} labelsize 12 align 17 | ||
3963 | } | ||
3964 | Fl_Repeat_Button button_movedown { | ||
3965 | callback {moveselected(1);} | ||
3966 | image {images/down.gif} xywh {530 275 70 20} labelsize 12 | ||
3967 | } | ||
3968 | Fl_Button button_load { | ||
3969 | label {Load...} | ||
3970 | callback {if (currsong == NULL) { | ||
3971 | fl_message("No song selected.\\nSelect a song on the Project/Song tab and try again."); | ||
3972 | return; | ||
3973 | return; | ||
3974 | } | ||
3975 | string* audiofiledir=hd24utils::getlastdir("audiofiledir"); | ||
3976 | |||
3977 | Fl_Native_File_Chooser chooser; | ||
3978 | chooser.directory(audiofiledir->c_str()); | ||
3979 | delete audiofiledir; | ||
3980 | chooser.title("Select the files to transfer:\\0"); | ||
3981 | chooser.type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE); | ||
3982 | chooser.filter("Audio files\\t*.{wav,aif}\\0"); | ||
3983 | //chooser.preview(0); | ||
3984 | int tosplitornottosplit=0; | ||
3985 | |||
3986 | switch (chooser.show()) { | ||
3987 | case -1: break; //error | ||
3988 | case 1: break; //cancel | ||
3989 | default: | ||
3990 | if (chooser.filename()) { | ||
3991 | string* cfilename=new string(chooser.filename()); | ||
3992 | |||
3993 | string* fpath=new string(""); | ||
3994 | *fpath+=cfilename->substr(0,strlen(cfilename->c_str())-strlen(fl_filename_name(cfilename->c_str()))); | ||
3995 | hd24utils::setlastdir("audiofiledir",fpath->c_str()); | ||
3996 | delete cfilename; | ||
3997 | for (int n = 0; n < chooser.count(); n++ ) { | ||
3998 | string* cfilename=new string(chooser.filename(n)); | ||
3999 | int currfiletracks=countfiletracks(cfilename->c_str()); | ||
4000 | int totfiletracks=currfiletracks; | ||
4001 | int haveslot=0; | ||
4002 | while (currfiletracks>0) { | ||
4003 | if (totfiletracks>1) { | ||
4004 | if (tosplitornottosplit==0) { | ||
4005 | bool wantsplit= | ||
4006 | confirm("One or more selected files have more than 1 track. Do you wish to split them up?"); | ||
4007 | if (!wantsplit) { | ||
4008 | tosplitornottosplit=1; | ||
4009 | } else { | ||
4010 | tosplitornottosplit=2; | ||
4011 | } | ||
4012 | } | ||
4013 | } | ||
4014 | |||
4015 | haveslot=0; | ||
4016 | for (unsigned int freeslot=0;freeslot<currsong->logical_channels();freeslot++) { | ||
4017 | if (strlen(filename[freeslot]->value())==0) { | ||
4018 | haveslot=1; | ||
4019 | filename[freeslot]->value(chooser.filename(n)); | ||
4020 | // cout << "Clear slot " << freeslot << endl; | ||
4021 | ((Fl_Choice*)(trackaction[freeslot]))->clear(); | ||
4022 | if (tosplitornottosplit>1) { | ||
4023 | populate_trackactionbyfile(freeslot,3+(totfiletracks-currfiletracks)); | ||
4024 | } else { | ||
4025 | populate_trackactionbyfile(freeslot,2); | ||
4026 | } | ||
4027 | break; | ||
4028 | } | ||
4029 | } | ||
4030 | if (haveslot==0) { | ||
4031 | break; | ||
4032 | } | ||
4033 | if (tosplitornottosplit==1) { | ||
4034 | currfiletracks=0; | ||
4035 | } else { | ||
4036 | currfiletracks--; | ||
4037 | } | ||
4038 | } | ||
4039 | delete cfilename; | ||
4040 | if (haveslot==0) { | ||
4041 | fl_message("One or more files could not be assigned to a track slot.\\n" | ||
4042 | "Please clear one or more track slots and try again."); | ||
4043 | break; | ||
4044 | } | ||
4045 | } | ||
4046 | } | ||
4047 | }} | ||
4048 | xywh {530 50 70 20} labelsize 12 | ||
4049 | } | ||
4050 | Fl_Button button_clear { | ||
4051 | label Clear | ||
4052 | callback {for (unsigned int i=0;i<MAXCHANNELS;i++) { | ||
4053 | if (trackselected[i]==1) { | ||
4054 | filename[i]->value(""); | ||
4055 | trackselected[i]=0; | ||
4056 | |||
4057 | } | ||
4058 | }; | ||
4059 | redrawtracks();} | ||
4060 | xywh {530 70 70 20} labelsize 12 | ||
4061 | } | ||
4062 | Fl_Choice trackaction1 {open | ||
4063 | xywh {470 50 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4064 | code0 {this->populate_trackaction(this,o,1);} | ||
4065 | } {} | ||
4066 | Fl_Choice trackaction2 {open | ||
4067 | xywh {470 69 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4068 | code0 {this->populate_trackaction(this,o,2);} | ||
4069 | } {} | ||
4070 | Fl_Choice trackaction3 {open | ||
4071 | xywh {470 88 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4072 | code0 {this->populate_trackaction(this,o,3);} | ||
4073 | } {} | ||
4074 | Fl_Choice trackaction4 {open | ||
4075 | xywh {470 107 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4076 | code0 {this->populate_trackaction(this,o,4);} | ||
4077 | } {} | ||
4078 | Fl_Choice trackaction5 {open | ||
4079 | xywh {470 126 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4080 | code0 {this->populate_trackaction(this,o,5);} | ||
4081 | } {} | ||
4082 | Fl_Choice trackaction6 {open | ||
4083 | xywh {470 145 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4084 | code0 {this->populate_trackaction(this,o,6);} | ||
4085 | } {} | ||
4086 | Fl_Choice trackaction7 {open | ||
4087 | xywh {470 164 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4088 | code0 {this->populate_trackaction(this,o,7);} | ||
4089 | } {} | ||
4090 | Fl_Choice trackaction8 {open | ||
4091 | xywh {470 183 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4092 | code0 {this->populate_trackaction(this,o,8);} | ||
4093 | } {} | ||
4094 | Fl_Choice trackaction9 {open | ||
4095 | xywh {470 202 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4096 | code0 {this->populate_trackaction(this,o,9);} | ||
4097 | } {} | ||
4098 | Fl_Choice trackaction10 {open | ||
4099 | xywh {470 221 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4100 | code0 {this->populate_trackaction(this,o,10);} | ||
4101 | } {} | ||
4102 | Fl_Choice trackaction11 {open | ||
4103 | xywh {470 240 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4104 | code0 {this->populate_trackaction(this,o,11);} | ||
4105 | } {} | ||
4106 | Fl_Choice trackaction12 {open | ||
4107 | xywh {470 259 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4108 | code0 {this->populate_trackaction(this,o,12);} | ||
4109 | } {} | ||
4110 | Fl_Choice trackaction13 {open | ||
4111 | xywh {470 278 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4112 | code0 {this->populate_trackaction(this,o,13);} | ||
4113 | } {} | ||
4114 | Fl_Choice trackaction14 {open | ||
4115 | xywh {470 297 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4116 | code0 {this->populate_trackaction(this,o,14);} | ||
4117 | } {} | ||
4118 | Fl_Choice trackaction15 {open | ||
4119 | xywh {470 316 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4120 | code0 {this->populate_trackaction(this,o,15);} | ||
4121 | } {} | ||
4122 | Fl_Choice trackaction16 {open | ||
4123 | xywh {470 335 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4124 | code0 {this->populate_trackaction(this,o,16);} | ||
4125 | } {} | ||
4126 | Fl_Choice trackaction17 {open | ||
4127 | xywh {470 354 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4128 | code0 {this->populate_trackaction(this,o,17);} | ||
4129 | } {} | ||
4130 | Fl_Choice trackaction18 {open | ||
4131 | xywh {470 373 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4132 | code0 {this->populate_trackaction(this,o,18);} | ||
4133 | } {} | ||
4134 | Fl_Choice trackaction19 {open | ||
4135 | xywh {470 392 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4136 | code0 {this->populate_trackaction(this,o,19);} | ||
4137 | } {} | ||
4138 | Fl_Choice trackaction20 {open | ||
4139 | xywh {470 411 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4140 | code0 {this->populate_trackaction(this,o,20);} | ||
4141 | } {} | ||
4142 | Fl_Choice trackaction21 {open | ||
4143 | xywh {470 430 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4144 | code0 {this->populate_trackaction(this,o,21);} | ||
4145 | } {} | ||
4146 | Fl_Choice trackaction22 {open | ||
4147 | xywh {470 449 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4148 | code0 {this->populate_trackaction(this,o,22);} | ||
4149 | } {} | ||
4150 | Fl_Choice trackaction23 {open | ||
4151 | xywh {470 468 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4152 | code0 {this->populate_trackaction(this,o,23);} | ||
4153 | } {} | ||
4154 | Fl_Choice trackaction24 {open | ||
4155 | xywh {470 487 55 19} down_box BORDER_BOX labelsize 11 textsize 11 | ||
4156 | code0 {this->populate_trackaction(this,o,24);} | ||
4157 | } {} | ||
4158 | Fl_Button button_transfertohd24help { | ||
4159 | label Help | ||
4160 | callback {fl_message( | ||
4161 | "To transfer files to the HD24, load one or more files.\\n" | ||
4162 | "Each file will be assigned to an empty track slot.\\n\\n" | ||
4163 | "Before transferring, you will be able to rearrange the\\n" | ||
4164 | "order of the tracks by clicking on one or more tracks\\n" | ||
4165 | "and clicking the up or down arrow buttons.\\n\\n" | ||
4166 | "When a track slot is empty, the existing track will be\\n" | ||
4167 | "preserved, unless 'Erase' or 'SMPTE' is selected on \\n" | ||
4168 | "the right of the track.\\n\\n" | ||
4169 | "When a file to transfer contains multiple tracks, you\\n" | ||
4170 | "can choose to mixdown the file to mono (the default), \\n" | ||
4171 | "or you can select the track that you want to transfer \\n" | ||
4172 | "to the HD24 drive." | ||
4173 | );} | ||
4174 | xywh {530 455 70 20} labelsize 12 | ||
4175 | } | ||
4176 | } | ||
4177 | } | ||
4178 | Fl_Group uicanvas_futureversions {open | ||
4179 | xywh {5 10 1710 530} hide resizable | ||
4180 | } { | ||
4181 | Fl_Tabs Future_Tabs {open | ||
4182 | xywh {10 35 1595 485} | ||
4183 | } { | ||
4184 | Fl_Group tab_wave { | ||
4185 | label Wave open | ||
4186 | xywh {15 60 595 455} color 52 labelfont 1 labelsize 12 deactivate | ||
4187 | code0 {o->hide();} | ||
4188 | } { | ||
4189 | Fl_Box {} { | ||
4190 | label {A future version of HD24connect may display a wave form here. | ||
4191 | Initially, the purpose of this wave form would be to make it | ||
4192 | easier to select an export range.} | ||
4193 | xywh {15 68 460 222} align 21 | ||
4194 | } | ||
4195 | } | ||
4196 | Fl_Group tab_data { | ||
4197 | label Data open | ||
4198 | xywh {15 60 595 455} color 52 labelfont 1 labelsize 12 hide deactivate | ||
4199 | code0 {o->hide();} | ||
4200 | } { | ||
4201 | Fl_Box {} { | ||
4202 | label {A future version of HD24connect may display a list of data files here. | ||
4203 | Specifically, this would be a list of files associated with the current | ||
4204 | project and/or song. To make this possible, a single song on the | ||
4205 | HD24 drive may be sacrificed as data area. This tab would then contain | ||
4206 | functionality to import/export/list those files, as well as functionality to | ||
4207 | create a data area on the drive. | ||
4208 | Without data area on the HD24 drive itself, songs may still be given a | ||
4209 | unique identifier to allow, for instance, automatically associating a mix | ||
4210 | on the DAW computer with a song. } | ||
4211 | xywh {15 63 505 222} align 21 | ||
4212 | } | ||
4213 | } | ||
4214 | } | ||
4215 | } | ||
4216 | } | ||
4217 | } | ||
4218 | } | ||
4219 | } | ||
4220 | Function {make_cli(hd24fs* p_fsys)} {return_type void | ||
4221 | } { | ||
4222 | code {// make_cli: stands for make commandline interface | ||
4223 | // (intended to allow batch processing and regression testing) | ||
4224 | // both current and default to allow multi drive support | ||
4225 | defaulthd24=p_fsys; | ||
4226 | currenthd24=p_fsys;} {} | ||
4227 | } | ||
4228 | decl {/* ===RECORDER UI stuff ===================================================== */} {} | ||
4229 | Function {readmixer()} {open return_type void | ||
4230 | } { | ||
4231 | code {// set solo status of channel to value | ||
4232 | /* | ||
4233 | for (unsigned int i=0;i<MAXCHANNELS;i++) { | ||
4234 | solobutton[i]->value(mixer->mixerchannel[i]->control->solo()); | ||
4235 | solobutton[i]->redraw(); | ||
4236 | mutebutton[i]->value(mixer->mixerchannel[i]->control->mute()); | ||
4237 | mutebutton[i]->redraw(); | ||
4238 | } | ||
4239 | */} {} | ||
4240 | } | ||
4241 | decl {/* === UTILS ===================================================== */} {} | ||
4242 | Function {getlastprojdir(Fl_Input* o)} {return_type void | ||
4243 | } { | ||
4244 | code {string* projdir=hd24utils::getlastdir("projdir"); | ||
4245 | o->value(projdir->c_str()); | ||
4246 | delete projdir;} {} | ||
4247 | } | ||
4248 | Function {ui_restart()} {open | ||
4249 | } { | ||
4250 | code {//if (isportaudioinitialized()) { | ||
4251 | // portaudio_transport_stop(); | ||
4252 | //} | ||
4253 | if (recorder!=NULL) { | ||
4254 | if (recorder->control!=NULL) { | ||
4255 | recorder->control->button_stop_call(); | ||
4256 | } | ||
4257 | } | ||
4258 | Fl::remove_timeout(poll_callback); | ||
4259 | |||
4260 | recorder->~RecorderUI(); | ||
4261 | delete recorder; | ||
4262 | |||
4263 | Fl_Window * winx=Fl::first_window(); | ||
4264 | if (currproj!=NULL) | ||
4265 | { | ||
4266 | delete currproj; | ||
4267 | currproj=NULL; | ||
4268 | } | ||
4269 | |||
4270 | if (currsong!=NULL) | ||
4271 | { | ||
4272 | delete currsong; | ||
4273 | currsong=NULL; | ||
4274 | } | ||
4275 | |||
4276 | Fl_Window * winy=make_window(currenthd24); | ||
4277 | |||
4278 | winy->position(winx->x(),winx->y()); | ||
4279 | winy->end(); | ||
4280 | winy->show(); | ||
4281 | \#ifdef LINUX | ||
4282 | XSetWMHints(fl_display, fl_xid(winy), XGetWMHints(fl_display, fl_xid(winx))); | ||
4283 | \#endif | ||
4284 | winx->~Fl_Window(); | ||
4285 | delete winx; | ||
4286 | winx=NULL; | ||
4287 | //if (jackmtsample!=NULL) | ||
4288 | //{ | ||
4289 | // free(jackmtsample); | ||
4290 | //}} {} | ||
4291 | } | ||
4292 | Function {loadheaderfile()} {} { | ||
4293 | code {Fl_Native_File_Chooser chooser; | ||
4294 | chooser.title("Select header file\\0"); | ||
4295 | chooser.filter("Drive Images\\t*.{img,bin,h24,hd24}\\0"); | ||
4296 | chooser.type(Fl_Native_File_Chooser::BROWSE_FILE); | ||
4297 | |||
4298 | string* headerdir=hd24utils::getlastdir("headerdir"); | ||
4299 | chooser.directory(headerdir->c_str()); | ||
4300 | delete headerdir; | ||
4301 | switch (chooser.show()) { | ||
4302 | case -1: break; //error | ||
4303 | case 1: break; //cancel | ||
4304 | default: | ||
4305 | if (chooser.filename()) { | ||
4306 | if (!(currenthd24->useheaderfile (chooser.filename()))) { | ||
4307 | fl_message("Couldn't load headerfile. Possible causes: \\n- Most likely you haven't selected a device or drive image yet.\\n- Maybe you have no read access to the file."); | ||
4308 | return; | ||
4309 | } | ||
4310 | string* strfile=new string(chooser.filename()); | ||
4311 | string* fpath=new string(""); | ||
4312 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
4313 | hd24utils::setlastdir("headerdir",fpath->c_str()); | ||
4314 | ui_restart(); | ||
4315 | return; | ||
4316 | } | ||
4317 | break; | ||
4318 | }} {} | ||
4319 | } | ||
4320 | Function {anyfilesexist(hd24song* thesong)} {return_type bool | ||
4321 | } { | ||
4322 | code {bool anyexist=false; | ||
4323 | |||
4324 | struct stat fi; | ||
4325 | __uint32 channels=thesong->logical_channels(); | ||
4326 | for (unsigned int q=0; q<100; q++) | ||
4327 | { | ||
4328 | for (unsigned int handle=0;handle<channels;handle++) | ||
4329 | { | ||
4330 | if (track[handle]->value()==0) { | ||
4331 | // channel not selected for export | ||
4332 | continue; | ||
4333 | } | ||
4334 | string* fname=transeng->generate_filename(handle,0,q); | ||
4335 | \#if (HD24DEBUG==1) | ||
4336 | cout << "check if file exists:" << *fname << endl; | ||
4337 | \#endif | ||
4338 | if ((stat (fname->c_str(), &fi) != -1) && ((fi.st_mode & S_IFDIR) == 0)) { | ||
4339 | anyexist=true; | ||
4340 | \#if (HD24DEBUG==1) | ||
4341 | cout << "yes, exists" << *fname << endl; | ||
4342 | \#endif | ||
4343 | delete fname; | ||
4344 | break; | ||
4345 | } | ||
4346 | |||
4347 | fname=transeng->generate_filename(handle,1,q); | ||
4348 | \#if (HD24DEBUG==1) | ||
4349 | cout << "check if file exists:" << *fname << endl; | ||
4350 | \#endif | ||
4351 | if ((stat (fname->c_str(), &fi) != -1) && ((fi.st_mode & S_IFDIR) == 0)) { | ||
4352 | anyexist=true; | ||
4353 | \#if (HD24DEBUG==1) | ||
4354 | cout << "yes, exists" << *fname << endl; | ||
4355 | \#endif | ||
4356 | delete fname; | ||
4357 | break; | ||
4358 | } | ||
4359 | \#if (HD24DEBUG==1) | ||
4360 | cout << "no, doesnt exist" << endl; | ||
4361 | \#endif | ||
4362 | |||
4363 | delete fname; | ||
4364 | } | ||
4365 | if (anyexist==true) break; | ||
4366 | } | ||
4367 | return anyexist;} {} | ||
4368 | } | ||
4369 | Function {fl_check()} {open return_type void | ||
4370 | } { | ||
4371 | code {refresh(stop_transfer); | ||
4372 | refresh(statusmsg); | ||
4373 | Fl::check();} {} | ||
4374 | } | ||
4375 | decl {bool mustdisplaytimer;} {public | ||
4376 | } | ||
4377 | decl {bool polling;} {public | ||
4378 | } | ||
4379 | decl {Fl_Text_Buffer* catalogbuffer;} {public | ||
4380 | } | ||
4381 | Function {HD24UserInterface(int argc,char** argv,char* absprogpath)} {open | ||
4382 | } { | ||
4383 | code {control=new HD24control(); | ||
4384 | control->parentui(this); | ||
4385 | control->ready(0); | ||
4386 | /*currpeakmode=0; | ||
4387 | for (unsigned int i=0;i<MAXCHANNELS;i++) { trackpeak[i]=0; } */ | ||
4388 | catalogbuffer=NULL; | ||
4389 | portaudio=new PortAudioWrapper(absprogpath); | ||
4390 | soundfile=new SoundFileWrapper(absprogpath); | ||
4391 | libjack=new JackWrapper(absprogpath); | ||
4392 | this->recorder=NULL; // will be initialized by make_window code | ||
4393 | this->transeng=new hd24transferengine();} {} | ||
4394 | } | ||
4395 | Function {~HD24UserInterface()} {open | ||
4396 | } { | ||
4397 | code {if (control!=NULL) delete control; | ||
4398 | if (portaudio!=NULL) delete portaudio; | ||
4399 | if (soundfile!=NULL) delete soundfile; | ||
4400 | if (libjack!=NULL) delete libjack; | ||
4401 | if (currsong!=NULL) delete currsong; | ||
4402 | if (currproj!=NULL) delete currproj; | ||
4403 | if (currenthd24==defaulthd24) | ||
4404 | { | ||
4405 | if (currenthd24!=NULL) delete currenthd24; | ||
4406 | } else { | ||
4407 | if (currenthd24!=NULL) delete currenthd24; | ||
4408 | if (defaulthd24!=NULL) delete defaulthd24; | ||
4409 | } | ||
4410 | if (transeng!=NULL) | ||
4411 | { | ||
4412 | delete transeng; | ||
4413 | transeng=NULL; | ||
4414 | }} {} | ||
4415 | } | ||
4416 | Function {confirm(const char* question)} {open return_type bool | ||
4417 | } { | ||
4418 | code {int result=fl_choice("%s","No","Yes",NULL,question); | ||
4419 | if (result==1) { | ||
4420 | return true; | ||
4421 | } | ||
4422 | return false;} {} | ||
4423 | } | ||
4424 | Function {samplerate()} {open return_type __uint32 | ||
4425 | } { | ||
4426 | code {// returns current samplerate of the UI, used by mixer | ||
4427 | if (currsong==NULL) return 44100; | ||
4428 | return currsong->samplerate();} {} | ||
4429 | } | ||
4430 | decl {friend class ScrubWheel;} {} | ||
4431 | decl {int refreshingui;} {} | ||
4432 | Function {saverestoretrackselection(Fl_Check_Button* o)} {open return_type void | ||
4433 | } { | ||
4434 | code {int i; | ||
4435 | if (o->value()==1) | ||
4436 | { | ||
4437 | if ( | ||
4438 | (transfersource_mixleft->value() | ||
4439 | +transfersource_mixright->value()) | ||
4440 | ==1) | ||
4441 | { | ||
4442 | // save selected tracks | ||
4443 | // disable track selection | ||
4444 | // (repopulate formats list/file name/whatever?) | ||
4445 | for (i=0;i<MAXCHANNELS;i++) | ||
4446 | { | ||
4447 | tracksave[i]=track[i]->value(); | ||
4448 | track[i]->value(1); | ||
4449 | track[i]->deactivate(); | ||
4450 | button_invert_tracks->deactivate(); | ||
4451 | } | ||
4452 | fileformat->deactivate(); | ||
4453 | return; | ||
4454 | } | ||
4455 | } | ||
4456 | |||
4457 | if (o->value()==0) | ||
4458 | { | ||
4459 | if ( | ||
4460 | (transfersource_mixleft->value() | ||
4461 | +transfersource_mixright->value()) | ||
4462 | ==0) | ||
4463 | { | ||
4464 | // restore tracks | ||
4465 | // enable track selection | ||
4466 | for (i=0;i<MAXCHANNELS;i++) | ||
4467 | { | ||
4468 | track[i]->value(tracksave[i]); | ||
4469 | track[i]->activate(); | ||
4470 | button_invert_tracks->activate(); | ||
4471 | |||
4472 | } | ||
4473 | fileformat->activate(); | ||
4474 | } | ||
4475 | }} {} | ||
4476 | } | ||
4477 | Function {showprogtitle()} {open return_type void | ||
4478 | } { | ||
4479 | code {recorder->control->dispwrite(0,"HD24connect " | ||
4480 | "HD24VERSION ",3000);} {} | ||
4481 | } | ||
4482 | decl {bool closingdown;} {public | ||
4483 | } | ||
4484 | Function {finish()} {open return_type void | ||
4485 | } { | ||
4486 | code {this->control->ready(0); | ||
4487 | this->closingdown=true; | ||
4488 | this->recorder->finish();} {} | ||
4489 | } | ||
4490 | Function {poll_callback(void* user)} {open return_type {static void} | ||
4491 | } { | ||
4492 | code {HD24UserInterface* mythis=(HD24UserInterface*)user; | ||
4493 | //RecorderUI* mythis=(RecorderUI*)user; | ||
4494 | \#if (HD24DEBUG==1) | ||
4495 | //cout << "poll_callback" << endl; | ||
4496 | \#endif | ||
4497 | if (mythis->control->ready()!=1) { return; } | ||
4498 | |||
4499 | |||
4500 | if (mythis->busy!=1) { | ||
4501 | mythis->busy=1; | ||
4502 | hd24song* mycurrsong=mythis->currsong; | ||
4503 | |||
4504 | if (mythis->recorder->control->song()!=mythis->currsong) | ||
4505 | { | ||
4506 | mythis->recorder->control->song(mythis->currsong); /* tell recorder that the song is gone */ | ||
4507 | } | ||
4508 | |||
4509 | if (mycurrsong!=NULL) { | ||
4510 | mycurrsong->bufferpoll(); | ||
4511 | } | ||
4512 | |||
4513 | |||
4514 | mythis->uiredrawcount=(mythis->uiredrawcount+1)%UIREFRESH; | ||
4515 | if (mythis->uiredrawcount==0) { | ||
4516 | |||
4517 | for (unsigned int i=0;i<MAXCHANNELS;i++) { | ||
4518 | // if (mythis->Tabs->value()==mythis->tabCopyToPC) { | ||
4519 | // if (mythis->trackpeak[i]>.01) { | ||
4520 | // if (mythis->trackpeak[i]>.9) | ||
4521 | // { | ||
4522 | // mythis->trackled[i]->color(1); | ||
4523 | // mythis->trackled[i]->redraw(); | ||
4524 | // } else { | ||
4525 | // if (mythis->trackpeak[i]>.7) { | ||
4526 | // mythis->trackled[i]->color(3); | ||
4527 | // mythis->trackled[i]->redraw(); | ||
4528 | // } else { | ||
4529 | // mythis->trackled[i]->color(2); | ||
4530 | // mythis->trackled[i]->redraw(); | ||
4531 | // } | ||
4532 | // } | ||
4533 | // } else { | ||
4534 | // mythis->trackled[i]->color(52); | ||
4535 | // mythis->trackled[i]->redraw(); | ||
4536 | // } | ||
4537 | // } | ||
4538 | } | ||
4539 | |||
4540 | if (mythis->Tabs->value()==mythis->tabMixer) { | ||
4541 | // mythis->mixer->redraw(); | ||
4542 | mythis->mixer->control->updatemeters(); | ||
4543 | } | ||
4544 | if (mythis->Tabs->value()==mythis->tabRecorder) { | ||
4545 | // mythis->mixer->redraw(); | ||
4546 | // mythis->recorder->control->updatemeters(); | ||
4547 | } | ||
4548 | // Fl check?? | ||
4549 | } | ||
4550 | } | ||
4551 | if (mythis->recorder!=NULL) { | ||
4552 | RecorderUI::poll_callback(mythis->recorder); | ||
4553 | } | ||
4554 | mythis->busy=0; | ||
4555 | Fl::add_timeout(TIMEOUT,poll_callback,user);} {} | ||
4556 | } | ||
4557 | decl {Fl_Box* trackled[24];} {public | ||
4558 | } | ||
4559 | Function {setlocbuttonlabel(int i)} {open return_type void | ||
4560 | } { | ||
4561 | code {hd24song* locsong=this->currsong; | ||
4562 | int numpoints=0; | ||
4563 | if (locsong!=NULL) | ||
4564 | { | ||
4565 | numpoints=locsong->locatepointcount(); | ||
4566 | } | ||
4567 | __uint32 locatepos=locsong->getlocatepos(i); | ||
4568 | string* locname1=new string(""); | ||
4569 | if (!(((i==0)||(i==numpoints)))) { | ||
4570 | *locname1+="+"; | ||
4571 | string* dur=locsong->display_duration(locatepos); | ||
4572 | *locname1+=*dur; | ||
4573 | delete (dur); | ||
4574 | } else { | ||
4575 | if (i!=0) | ||
4576 | { | ||
4577 | *locname1+="+"; | ||
4578 | string* dur=locsong->display_duration(locatepos); | ||
4579 | *locname1+=*dur; | ||
4580 | delete (dur); | ||
4581 | } else { | ||
4582 | *locname1+="START"; | ||
4583 | } | ||
4584 | } | ||
4585 | |||
4586 | *locname1="Seek to "+*locname1; | ||
4587 | int l=strlen(locname1->c_str()); | ||
4588 | for (i=0;i<l;i++) { | ||
4589 | locbuttonlabel[i]=locname1->c_str()[i]; | ||
4590 | locbuttonlabel[i+1]=(char)0; | ||
4591 | } | ||
4592 | |||
4593 | button_golocatepoint->label(&(this->locbuttonlabel[0])); | ||
4594 | delete locname1;} {} | ||
4595 | } | ||
4596 | decl {char locbuttonlabel[64];} {} | ||
4597 | } | ||