3 * Copyright (C) 2008-2015 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __MIXERSALIGN_H__
22 #define __MIXERSALIGN_H__
29 #include "loadbalance.h"
30 #include "mainprogress.inc"
31 #include "mixersalign.inc"
32 #include "mwindow.inc"
33 #include "renderengine.h"
34 #include "samples.inc"
36 #include "zwindow.inc"
38 class MixersAlignMixer
41 MixersAlignMixer(Mixer *mix);
51 class MixersAlignMixers : public ArrayList<MixersAlignMixer*>
54 MixersAlignMixers() {}
55 ~MixersAlignMixers() { clear(); }
56 void clear() { remove_all_objects(); }
59 class MixersAlignMixerList : public BC_ListBox
61 enum { MIX_MIXER, MIX_NUDGE, MIX_SZ };
62 static const char *mix_titles[MIX_SZ];
63 static int mix_widths[MIX_SZ];
65 MixersAlignMixerList(MixersAlignWindow *gui,
66 MixersAlign *dialog, int x, int y, int w, int h);
67 ~MixersAlignMixerList();
71 void add_mixer(MixersAlignMixer *mixer);
74 int selection_changed();
76 MixersAlignWindow *gui;
78 MixersAlignMixers mixers;
80 const char *col_titles[MIX_SZ];
81 int col_widths[MIX_SZ];
82 ArrayList<BC_ListBoxItem*> cols[MIX_SZ];
84 void set_all_selected(int v) { BC_ListBox::set_all_selected(cols, v); }
85 void set_selected(int idx, int v) { BC_ListBox::set_selected(cols, idx, v); }
86 bool is_selected(int idx) { return cols[0][idx]->get_selected() != 0; }
90 class MixersAlignMTrack
93 MixersAlignMTrack(Track *trk, int no);
99 class MixersAlignMTracks : public ArrayList<MixersAlignMTrack*>
102 MixersAlignMTracks() {}
103 ~MixersAlignMTracks() { clear(); }
104 void clear() { remove_all_objects(); }
108 class MixersAlignMTrackList : public BC_ListBox
110 enum { MTK_NO, MTK_MIXER, MTK_TRACK, MTK_SZ };
111 static const char *mtk_titles[MTK_SZ];
112 static int mtk_widths[MTK_SZ];
114 MixersAlignMTrackList(MixersAlignWindow *gui,
115 MixersAlign *dialog, int x, int y, int w, int h);
116 ~MixersAlignMTrackList();
119 void add_mtrack(MixersAlignMTrack *mtrk);
123 MixersAlignWindow *gui;
126 ArrayList<BC_ListBoxItem*> cols[MTK_SZ];
127 const char *col_titles[MTK_SZ];
128 int col_widths[MTK_SZ];
130 void set_all_selected(int v) { BC_ListBox::set_all_selected(cols, v); }
131 void set_selected(int idx, int v) { BC_ListBox::set_selected(cols, idx, v); }
132 bool is_selected(int idx) { return cols[0][idx]->get_selected() != 0; }
136 class MixersAlignATrack
139 MixersAlignATrack(Track *trk, int no);
140 ~MixersAlignATrack();
150 class MixersAlignATracks : public ArrayList<MixersAlignATrack*>
153 MixersAlignATracks() {}
154 ~MixersAlignATracks() { clear(); }
155 void clear() { remove_all_objects(); }
158 class MixersAlignATrackList : public BC_ListBox
160 enum { ATK_TRACK, ATK_AUDIO, ATK_NUDGE, ATK_MX, ATK_MI, ATK_SZ };
161 static const char *atk_titles[ATK_SZ];
162 static int atk_widths[ATK_SZ];
164 MixersAlignATrackList(MixersAlignWindow *gui,
165 MixersAlign *dialog, int x, int y, int w, int h);
166 ~MixersAlignATrackList();
169 void add_atrack(MixersAlignATrack *track);
172 int selection_changed();
174 MixersAlignWindow *gui;
177 ArrayList<BC_ListBoxItem*> cols[ATK_SZ];
178 const char *col_titles[ATK_SZ];
179 int col_widths[ATK_SZ];
181 void set_all_selected(int v) { BC_ListBox::set_all_selected(cols, v); }
182 void set_selected(int idx, int v) { BC_ListBox::set_selected(cols, idx, v); }
183 bool is_selected(int idx) { return cols[0][idx]->get_selected() != 0; }
186 class MixersAlignReset : public BC_GenericButton
189 MixersAlignReset(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
191 static int calculate_width(BC_WindowBase *gui);
194 MixersAlignWindow *gui;
197 class MixersAlignThread : public Thread
200 MixersAlignThread(MixersAlign *dialog);
201 ~MixersAlignThread();
209 class MixersAlignMatch : public BC_GenericButton
212 MixersAlignMatch(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
216 MixersAlignWindow *gui;
219 class MixersAlignMatchAll : public BC_GenericButton
222 MixersAlignMatchAll(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
226 MixersAlignWindow *gui;
229 class MixersAlignNudgeTracks : public BC_GenericButton
232 MixersAlignNudgeTracks(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
234 static int calculate_width(BC_WindowBase *gui);
237 MixersAlignWindow *gui;
240 class MixersAlignNudgeSelected : public BC_GenericButton
243 MixersAlignNudgeSelected(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
245 static int calculate_width(BC_WindowBase *gui);
248 MixersAlignWindow *gui;
251 class MixersAlignCheckPoint : public BC_GenericButton
254 MixersAlignCheckPoint(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
258 MixersAlignWindow *gui;
261 class MixersAlignUndoEDLs : public ArrayList<EDL *>
264 MixersAlignUndoEDLs() {}
265 ~MixersAlignUndoEDLs() { clear(); }
267 for( int i=size(); --i>=0; ) get(i)->remove_user();
272 class MixersAlignUndoItem : public BC_MenuItem
275 MixersAlignUndoItem(const char *text, int no);
276 ~MixersAlignUndoItem();
282 class MixersAlignUndo : public BC_PopupMenu
285 MixersAlignUndo(MixersAlignWindow *gui, MixersAlign *dialog, int x, int y);
287 void create_objects();
288 void add_undo_item(int no);
291 MixersAlignWindow *gui;
295 class MixersAlignWindow : public BC_Window
298 MixersAlignWindow(MixersAlign *dialog, int x, int y);
299 ~MixersAlignWindow();
301 void create_objects();
302 int resize_event(int w, int h);
304 void default_selection();
308 BC_Title *mixer_title, *mtrack_title, *atrack_title;
310 MixersAlignMixerList *mixer_list;
311 MixersAlignMTrackList *mtrack_list;
312 MixersAlignATrackList *atrack_list;
313 MixersAlignMatch *match;
314 MixersAlignMatchAll *match_all;
315 MixersAlignReset *reset;
316 MixersAlignNudgeTracks *nudge_tracks;
317 MixersAlignNudgeSelected *nudge_selected;
318 MixersAlignCheckPoint *check_point;
319 MixersAlignUndo *undo;
323 class MixersAlignARender : public RenderEngine
326 MixersAlignARender(MWindow *mwindow, EDL *edl);
327 ~MixersAlignARender();
329 int render(Samples **samples, int64_t len, int64_t pos);
333 class MixersAlignScanPackage : public LoadPackage
336 MixersAlignScanPackage(MixersAlignScanFarm *farm);
337 ~MixersAlignScanPackage();
339 MixersAlignMixer *mixer;
342 class MixersAlignScanClient : public LoadClient
345 MixersAlignScanClient(MixersAlignScanFarm *farm);
346 ~MixersAlignScanClient();
347 void process_package(LoadPackage *package);
349 MixersAlignScanFarm *farm;
350 MixersAlignScanPackage *pkg;
355 class MixersAlignScanFarm : public LoadServer
358 MixersAlignScanFarm(MixersAlign *dialog, int cpus, int n);
359 ~MixersAlignScanFarm();
360 void init_packages();
361 LoadClient *new_client();
362 LoadPackage *new_package();
370 class MixersAlignMatchFwdPackage : public LoadPackage
373 MixersAlignMatchFwdPackage();
374 ~MixersAlignMatchFwdPackage();
376 MixersAlignMixer *mixer;
379 class MixersAlignMatchFwdClient : public LoadClient
382 MixersAlignMatchFwdClient(MixersAlignMatchFwdFarm *farm);
383 ~MixersAlignMatchFwdClient();
385 void process_package(LoadPackage *package);
386 MixersAlignMatchFwdPackage *pkg;
389 class MixersAlignMatchFwdFarm : public LoadServer
392 MixersAlignMatchFwdFarm(MixersAlign *dialog, int n);
393 ~MixersAlignMatchFwdFarm();
394 void init_packages();
395 LoadClient *new_client();
396 LoadPackage *new_package();
402 class MixersAlignMatchRevPackage : public LoadPackage
405 MixersAlignMatchRevPackage();
406 ~MixersAlignMatchRevPackage();
408 MixersAlignMixer *mix;
411 class MixersAlignMatchRevClient : public LoadClient
414 MixersAlignMatchRevClient(MixersAlignMatchRevFarm *farm);
415 ~MixersAlignMatchRevClient();
417 void process_package(LoadPackage *package);
418 MixersAlignMatchRevPackage *pkg;
422 class MixersAlignMatchRevFarm : public LoadServer
425 MixersAlignMatchRevFarm(int n, int cpus,
426 MixersAlign *dialog, double *ar, double *ai, int len);
427 ~MixersAlignMatchRevFarm();
428 void init_packages();
429 LoadClient *new_client();
430 LoadPackage *new_package();
440 class MixersAlignTargetPackage : public LoadPackage
443 MixersAlignTargetPackage(MixersAlignTarget *pfft);
444 ~MixersAlignTargetPackage();
451 class MixersAlignTargetClient : public LoadClient
454 MixersAlignTargetClient();
455 ~MixersAlignTargetClient();
457 void process_package(LoadPackage *package);
458 MixersAlignTargetPackage *pkg;
461 class MixersAlignTarget : public LoadServer
464 MixersAlignTarget(int n, int cpus,
465 MixersAlignScanClient *scan, Samples **samples, int len);
466 ~MixersAlignTarget();
467 void init_packages();
468 LoadClient *new_client();
469 LoadPackage *new_package();
471 MixersAlignScanClient *scan;
477 class MixersAlign : public BC_DialogThread, public FFT
480 MixersAlign(MWindow *mwindow);
483 void start_dialog(int wx, int wy);
484 BC_Window *new_gui();
488 void handle_done_event(int result);
489 void handle_close_event(int result);
491 int atrack_of(MixersAlignMixer *mix, int ch);
492 int mixer_of(Track *track, int &midx);
493 int mixer_of(Track *track) { int midx = -1; return mixer_of(track, midx); }
494 int mmixer_of(int mi) {
495 return mi>=0 && mi<mtracks.size() ? mixer_of(mtracks[mi]->track) : -1;
497 int amixer_of(int ai) {
498 return ai>=0 && ai<atracks.size() ? mixer_of(atracks[ai]->track) : -1;
501 EDL *mixer_audio_clip(Mixer *mixer);
502 EDL *mixer_master_clip(Track *track);
503 int64_t mixer_tracks_total(int midx);
504 void load_master_audio(Track *track);
505 void scan_mixer_audio();
506 void start_progress(int64_t total_len);
507 void stop_progress(const char *msg);
508 void update_progress(int64_t len);
514 void apply_undo(int no);
516 void nudge_selected();
517 void clear_mixer_nudge();
519 void reset_targets();
521 void scan_master(Track *track);
523 MixersAlignWindow *ma_gui;
525 MixersAlignMixers mixers;
526 MixersAlignMTracks mtracks;
527 MixersAlignATracks atracks;
530 MixersAlignUndoEDLs undo_edls;
532 MainProgressBar *progress;
533 MixersAlignThread *thread;
535 int64_t total_rendered;
537 int64_t master_len, sample_len;
538 double *master_r, *master_i;
539 double master_start, master_end, master_ss;
540 double audio_start, audio_end;