6 * Copyright (C) 2015 Adam Williams <broadcast at earthling dot net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "arraylist.h"
25 #include "audiodevice.inc"
28 #include "bctimer.inc"
29 #include "convert.inc"
31 #include "formattools.h"
33 #include "mainprogress.inc"
35 #include "mwindow.inc"
36 #include "packagerenderer.h"
39 class ConvertRender : public Thread
42 ConvertRender(MWindow *mwindow, const char *suffix);
45 void to_convert_path(char *new_path, Indexable *idxbl);
46 int from_convert_path(char *new_path, Indexable *idxbl);
48 ArrayList<Indexable *> orig_idxbls; // originals which match the convert assets
49 ArrayList<Asset *> orig_copies; // convert assets
50 ArrayList<Indexable *> needed_idxbls; // originals which match the needed_assets
51 ArrayList<Asset *> needed_copies; // assets which must be created
53 EDL *convert_edl(EDL *edl, Indexable *idxbl); // create render edl for this indexable
54 int add_original(EDL *edl, Indexable *idxbl);
55 void add_needed(Indexable *idxbl, Asset *convert);
56 int find_convertable_assets(EDL *edl);
58 // if user canceled progress bar
60 void set_format(Asset *asset);
61 void start_convert(float beep, int remove_originals);
63 void create_copy(int i);
64 void start_progress();
65 void stop_progress(const char *msg);
70 MainProgressBar *progress;
71 ConvertProgress *convert_progress;
72 Timer *progress_timer;
75 int total_rendered, remove_originals;
76 int failed, canceled, result;
80 class ConvertMenuItem : public BC_MenuItem
83 ConvertMenuItem(MWindow *mwindow);
87 void create_objects();
90 ConvertDialog *dialog;
93 class ConvertFormatTools : public FormatTools
96 ConvertFormatTools(MWindow *mwindow, ConvertWindow *gui, Asset *asset);
102 class ConvertSuffixText : public BC_TextBox
105 ConvertSuffixText(ConvertWindow *gui, ConvertDialog *dialog, int x, int y);
106 ~ConvertSuffixText();
110 ConvertDialog *dialog;
113 class ConvertRemoveOriginals : public BC_CheckBox
116 ConvertRemoveOriginals(ConvertWindow *gui, int x, int y);
117 ~ConvertRemoveOriginals();
124 class ConvertBeepOnDone : public BC_FPot
127 ConvertBeepOnDone(ConvertWindow *gui, int x, int y);
134 class ConvertPackageRenderer : public PackageRenderer
137 ConvertPackageRenderer(ConvertRender *render);
138 ~ConvertPackageRenderer();
142 void set_result(int value);
143 void set_progress(int64_t value);
144 int progress_cancelled();
146 ConvertRender *render;
149 class ConvertProgress : public Thread
152 ConvertProgress(MWindow *mwindow, ConvertRender *render);
158 ConvertRender *render;
162 class ConvertWindow : public BC_Window
165 ConvertWindow(MWindow *mwindow, ConvertDialog *dialog,
169 void create_objects();
172 ConvertDialog *dialog;
174 ConvertSuffixText *suffix_text;
175 ConvertFormatTools *format_tools;
176 ConvertRemoveOriginals *remove_originals;
177 ConvertBeepOnDone *beep_on_done;
180 class ConvertDialog : public BC_DialogThread
183 ConvertDialog(MWindow *mwindow);
185 BC_Window* new_gui();
187 void handle_close_event(int result);
193 char suffix[BCTEXTLEN];
194 ConvertRender *convert_render;
196 int orig_scale, new_scale;
197 int use_scaler, auto_scale;
199 int remove_originals;
203 class ConvertBeep : public Thread
206 enum { BEEP_SAMPLE_RATE=48000 };
207 typedef int16_t audio_data_t;
208 ConvertBeep(MWindow *mwindow);
214 void tone(double freq, double secs, double gain);
217 double freq, secs, gain;
219 int playing_audio, interrupted;