r860: Merge 2.1:
[cinelerra_cv.git] / cinelerra / recordprefs.C
blob951c3d796227bbd74ea92e7ecf0a0f8aea10d6b3
1 #include "adeviceprefs.h"
2 #include "audioconfig.h"
3 #include "clip.h"
4 #include "edl.h"
5 #include "edlsession.h"
6 #include "formattools.h"
7 #include "new.h"
8 #include "language.h"
9 #include "mwindow.h"
10 #include "preferences.h"
11 #include "recordconfig.h"
12 #include "recordprefs.h"
13 #include "theme.h"
14 #include "vdeviceprefs.h"
19 RecordPrefs::RecordPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
20  : PreferencesDialog(mwindow, pwindow)
22         this->mwindow = mwindow;
25 RecordPrefs::~RecordPrefs()
27         delete audio_in_device;
28         delete recording_format;
29 //      delete duplex_device;
32 int RecordPrefs::create_objects()
34         int x, y, x2;
35         char string[BCTEXTLEN];
36         BC_Resources *resources = BC_WindowBase::get_resources();
37         BC_Title *title;
39         x = mwindow->theme->preferencesoptions_x;
40         y = mwindow->theme->preferencesoptions_y;
42         add_subwindow(title = new BC_Title(x, 
43                 y, 
44                 _("File Format:"), 
45                 LARGEFONT, 
46                 resources->text_default));
47         y += title->get_h() + 5;
49         recording_format = 
50                 new FormatTools(mwindow,
51                         this, 
52                         pwindow->thread->edl->session->recording_format);
53         recording_format->create_objects(x, 
54                 y, 
55                 1,  // Include tools for audio
56                 1,  // Include tools for video
57                 1,  // Include checkbox for audio
58                 1,  // Include checkbox for video
59                 0,
60                 1,
61                 0,  // Select compressors to be offered
62                 1,  // Prompt for recording options
63                 0,  // If nonzero, prompt for insertion strategy
64                 0); // Supply file formats for background rendering
70 // Audio hardware
71         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
72         y += 5;
75         add_subwindow(title = new BC_Title(x, 
76                 y, 
77                 _("Audio In"), 
78                 LARGEFONT, 
79                 resources->text_default));
81         y += title->get_h() + 5;
83         add_subwindow(new BC_Title(x, y, _("Record Driver:"), MEDIUMFONT, resources->text_default));
84         audio_in_device = new ADevicePrefs(x + 110, 
85                 y, 
86                 pwindow, 
87                 this, 
88                 0,
89                 pwindow->thread->edl->session->aconfig_in, 
90                 MODERECORD);
91         audio_in_device->initialize(1);
92         y += audio_in_device->get_h(1);
95         BC_TextBox *textbox;
96         BC_Title *title1, *title2, *title3;
97         add_subwindow(title1 = new BC_Title(x, y, _("Samples to write to disk at a time:")));
98         add_subwindow(title2 = new BC_Title(x, y + 30, _("Sample rate for recording:")));
99         add_subwindow(title3 = new BC_Title(x, y + 60, _("Channels to record:")));
100         x2 = MAX(title1->get_w(), title2->get_w()) + 10;
101         x2 = MAX(x2, title3->get_w() + 10);
103         sprintf(string, "%ld", pwindow->thread->edl->session->record_write_length);
104         add_subwindow(textbox = new RecordWriteLength(mwindow, 
105                 pwindow, 
106                 x2, 
107                 y, 
108                 string));
109         add_subwindow(textbox = new RecordSampleRate(pwindow, x2, y + 30));
110         add_subwindow(new SampleRatePulldown(mwindow, textbox, x2 + textbox->get_w(), y + 30));
112         RecordChannels *channels = new RecordChannels(pwindow, this, x2, y + 60);
113         channels->create_objects();
115         y += 90;
118         add_subwindow(new RecordRealTime(mwindow, 
119                 pwindow, 
120                 x, 
121                 y, 
122                 pwindow->thread->edl->session->real_time_record));
123         y += 45;
124         x = 5;
129 // Video hardware
130         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
131         y += 5;
134         add_subwindow(new BC_Title(x, y, _("Video In"), LARGEFONT, resources->text_default));
135         y += 25;
137         add_subwindow(new BC_Title(x, 
138                 y, 
139                 _("Record Driver:"), 
140                 MEDIUMFONT, 
141                 resources->text_default));
142         video_in_device = new VDevicePrefs(x + 110, 
143                 y, 
144                 pwindow, 
145                 this, 
146                 0, 
147                 pwindow->thread->edl->session->vconfig_in, 
148                 MODERECORD);
149         video_in_device->initialize(1);
151         y += 55;
152         sprintf(string, "%d", pwindow->thread->edl->session->video_write_length);
153         add_subwindow(textbox = new VideoWriteLength(pwindow, string, y));
154         add_subwindow(new CaptureLengthTumbler(pwindow, textbox, textbox->get_x() + textbox->get_w(), y));
155         add_subwindow(new BC_Title(x, y, _("Frames to record to disk at a time:")));
156         y += 27;
157         sprintf(string, "%d", pwindow->thread->edl->session->vconfig_in->capture_length);
158         add_subwindow(textbox = new VideoCaptureLength(pwindow, string, y));
159         add_subwindow(new CaptureLengthTumbler(pwindow, textbox, textbox->get_x() + textbox->get_w(), y));
160         add_subwindow(new BC_Title(x, y, _("Frames to buffer in device:")));
161         y += 27;
163         add_subwindow(new RecordSoftwareTimer(pwindow, 
164                 pwindow->thread->edl->session->record_software_position, 
165                 x, 
166                 y));
167         y += 27;
168         add_subwindow(new RecordSyncDrives(pwindow, 
169                 pwindow->thread->edl->session->record_sync_drives, 
170                 x, 
171                 y));
172         y += 35;
174         BC_TextBox *w_text, *h_text;
175         add_subwindow(new BC_Title(x, y, _("Size of captured frame:")));
176         x += 170;
177         add_subwindow(w_text = new RecordW(pwindow, x, y));
178         x += w_text->get_w() + 2;
179         add_subwindow(new BC_Title(x, y, "x"));
180         x += 10;
181         add_subwindow(h_text = new RecordH(pwindow, x, y));
182         x += h_text->get_w();
183         add_subwindow(new FrameSizePulldown(mwindow, 
184                 w_text, 
185                 h_text, 
186                 x, 
187                 y));
189         y += 30;
190         x = 5;
191         add_subwindow(new BC_Title(x, y, _("Frame rate for recording:")));
192         x += 180;
193         add_subwindow(textbox = new RecordFrameRate(pwindow, x, y));
194         x += 75;
195         add_subwindow(new FrameRatePulldown(mwindow, textbox, x, y));
196         y += 45;
197         x = 5;
198         
199         add_subwindow(new BC_Title(x, y, _("Images"), LARGEFONT, BLACK));
200         y += 25;
201         add_subwindow(new StillImageUseDuration(pwindow, 
202                 pwindow->thread->edl->session->si_useduration, 
203                 x, 
204                 y));
205         x += 260;
206         y += 5;
207         add_subwindow(new StillImageDuration(pwindow, x, y));
208         x += 80;
209         y += 5;
210         add_subwindow(new BC_Title(x, y, _("Seconds")));
211         y += 30;
213         return 0;
217 RecordWriteLength::RecordWriteLength(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, char *text)
218  : BC_TextBox(x, y, 100, 1, text)
220         this->pwindow = pwindow; 
223 int RecordWriteLength::handle_event()
225         pwindow->thread->edl->session->record_write_length = atol(get_text());
226         return 1; 
231 RecordRealTime::RecordRealTime(MWindow *mwindow, 
232         PreferencesWindow *pwindow, 
233         int x, 
234         int y, 
235         int value)
236  : BC_CheckBox(x, 
237         y, 
238         value, 
239         _("Record in realtime priority (root only)"))
241         this->pwindow = pwindow; 
244 int RecordRealTime::handle_event()
246         pwindow->thread->edl->session->real_time_record = get_value();
250 RecordSampleRate::RecordSampleRate(PreferencesWindow *pwindow, int x, int y)
251  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->aconfig_in->in_samplerate)
253         this->pwindow = pwindow;
255 int RecordSampleRate::handle_event()
257         pwindow->thread->edl->session->aconfig_in->in_samplerate = atol(get_text());
258         return 1;
262 // DuplexEnable::DuplexEnable(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y, int value)
263 //  : BC_CheckBox(x, y, value, _("Enable full duplex"))
264 // { this->pwindow = pwindow; }
265 // 
266 // int DuplexEnable::handle_event()
267 // {
268 //      pwindow->thread->edl->session->enable_duplex = get_value();
269 // }
270 // 
273 RecordW::RecordW(PreferencesWindow *pwindow, int x, int y)
274  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->vconfig_in->w)
276         this->pwindow = pwindow;
278 int RecordW::handle_event()
280         pwindow->thread->edl->session->vconfig_in->w = atol(get_text());
281         return 1;
284 RecordH::RecordH(PreferencesWindow *pwindow, int x, int y)
285  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->vconfig_in->h)
287         this->pwindow = pwindow;
289 int RecordH::handle_event()
291         pwindow->thread->edl->session->vconfig_in->h = atol(get_text());
292         return 1;
295 RecordFrameRate::RecordFrameRate(PreferencesWindow *pwindow, int x, int y)
296  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->vconfig_in->in_framerate)
298         this->pwindow = pwindow;
300 int RecordFrameRate::handle_event()
302         pwindow->thread->edl->session->vconfig_in->in_framerate = atof(get_text());
303         return 1;
308 RecordChannels::RecordChannels(PreferencesWindow *pwindow, BC_SubWindow *gui, int x, int y)
309  : BC_TumbleTextBox(gui, 
310                 pwindow->thread->edl->session->aconfig_in->channels,
311                 1,
312                 MAX_CHANNELS,
313                 x, 
314                 y, 
315                 100)
317         this->pwindow = pwindow; 
320 int RecordChannels::handle_event()
322         pwindow->thread->edl->session->aconfig_in->channels = atoi(get_text());
323         return 1;
328 VideoWriteLength::VideoWriteLength(PreferencesWindow *pwindow, char *text, int y)
329  : BC_TextBox(260, y, 100, 1, text)
331         this->pwindow = pwindow; 
334 int VideoWriteLength::handle_event()
336         pwindow->thread->edl->session->video_write_length = atol(get_text()); 
337         return 1;
341 VideoCaptureLength::VideoCaptureLength(PreferencesWindow *pwindow, char *text, int y)
342  : BC_TextBox(260, y, 100, 1, text)
344         this->pwindow = pwindow;
347 int VideoCaptureLength::handle_event()
349         pwindow->thread->edl->session->vconfig_in->capture_length = atol(get_text()); 
350         return 1; 
353 CaptureLengthTumbler::CaptureLengthTumbler(PreferencesWindow *pwindow, BC_TextBox *text, int x, int y)
354  : BC_Tumbler(x, y)
356         this->pwindow;
357         this->text = text;
360 int CaptureLengthTumbler::handle_up_event()
362         int value = atol(text->get_text());
363         value++;
364         char string[BCTEXTLEN];
365         sprintf(string, "%d", value);
366         text->update(string);
367         text->handle_event();
368         return 1;
371 int CaptureLengthTumbler::handle_down_event()
373         int value = atol(text->get_text());
374         value--;
375         value = MAX(1, value);
376         char string[BCTEXTLEN];
377         sprintf(string, "%d", value);
378         text->update(string);
379         text->handle_event();
380         return 1;
385 RecordSoftwareTimer::RecordSoftwareTimer(PreferencesWindow *pwindow, int value, int x, int y)
386  : BC_CheckBox(x, y, value, _("Use software for positioning information"))
388         this->pwindow = pwindow; 
391 int RecordSoftwareTimer::handle_event() 
393         pwindow->thread->edl->session->record_software_position = get_value(); 
394         return 1;
399 RecordSyncDrives::RecordSyncDrives(PreferencesWindow *pwindow, int value, int x, int y)
400  : BC_CheckBox(x, y, value, _("Sync drives automatically"))
402         this->pwindow = pwindow; 
405 int RecordSyncDrives::handle_event() 
407         pwindow->thread->edl->session->record_sync_drives = get_value(); 
408         return 1;
411 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
412  : BC_CheckBox(x, y, value, _("Import images with a duration of"))
414         this->pwindow = pwindow; 
417 int StillImageUseDuration::handle_event()
419         pwindow->thread->edl->session->si_useduration = get_value();
422 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
423  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
425         this->pwindow = pwindow;
427 int StillImageDuration::handle_event()
429         pwindow->thread->edl->session->si_duration = atof(get_text());
430         return 1;