r370: Heroine Virutal's official release 1.2.1
[cinelerra_cv/mob.git] / hvirtual / cinelerra / playbackprefs.C
blob4941309a1454006eda039ba279354da564763cb1
1 #include "adeviceprefs.h"
2 #include "audioconfig.h"
3 #include "audiodevice.inc"
4 #include "clip.h"
5 #include "defaults.h"
6 #include "edl.h"
7 #include "edlsession.h"
8 #include "language.h"
9 #include "mwindow.h"
10 #include "overlayframe.inc"
11 #include "playbackprefs.h"
12 #include "preferences.h"
13 #include "vdeviceprefs.h"
14 #include "videodevice.inc"
18 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
19  : PreferencesDialog(mwindow, pwindow)
21 //      head_text = 0;
22 //      head_count_text = 0;
23 //      host_text = 0;
24         video_device = 0;
27 PlaybackPrefs::~PlaybackPrefs()
29 //      delete_strategy();
30 //      mwindow->defaults->update("PLAYBACK_HEAD", current_head);
31         delete audio_device;
32         delete video_device;
35 int PlaybackPrefs::create_objects()
37         int x = 5, y = 5, x2;
38         char string[BCTEXTLEN];
39         BC_PopupTextBox *popup;
41         playback_config = pwindow->thread->edl->session->playback_config;
42 //      current_head = mwindow->defaults->get("PLAYBACK_HEAD", 0);
43 //      strategies.append(new BC_ListBoxItem(_("Local Host")));
44 //      strategies.append(new BC_ListBoxItem(_("Multihead")));
45 //      strategies.append(new BC_ListBoxItem(_("Blond Symphony")));
47 // Global playback options
49 // All strategies use these
50         add_subwindow(new BC_Title(x, y, _("Audio Out"), LARGEFONT, BLACK));
51         y += 30;
55         BC_Title *title1, *title2;
56 //      add_subwindow(title1 = new BC_Title(x, y, _("Samples to read from disk at a time:"), MEDIUMFONT, BLACK));
57         add_subwindow(title2 = new BC_Title(x, y, _("Samples to send to console at a time:"), MEDIUMFONT, BLACK));
58         x2 = MAX(title2->get_w(), title2->get_w()) + 10;
60 //      sprintf(string, "%d", pwindow->thread->edl->session->audio_read_length);
61 //      add_subwindow(new PlaybackReadLength(x2, y, pwindow, this, string));
62         sprintf(string, "%d", playback_config->aconfig->fragment_size);
63         PlaybackModuleFragment *menu;
64         add_subwindow(menu = new PlaybackModuleFragment(x2, 
65                 y, 
66                 pwindow, 
67                 this, 
68                 string));
69         menu->add_item(new BC_MenuItem("2048"));
70         menu->add_item(new BC_MenuItem("4096"));
71         menu->add_item(new BC_MenuItem("8192"));
72         menu->add_item(new BC_MenuItem("16384"));
73         menu->add_item(new BC_MenuItem("32768"));
74         menu->add_item(new BC_MenuItem("65536"));
75         menu->add_item(new BC_MenuItem("131072"));
76         menu->add_item(new BC_MenuItem("262144"));
78         y += 30;
79         add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
80         y += 30;
81         add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
82         y += 30;
83         add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
84         y += 40;
85         add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
86         audio_device = new ADevicePrefs(x + 100, 
87                 y, 
88                 pwindow, 
89                 this, 
90                 playback_config->aconfig, 
91                 0,
92                 MODEPLAY);
93         audio_device->initialize();
95 // Strategic playback options created here
96 //      set_strategy(pwindow->thread->edl->session->playback_strategy);
97 // 
98 //      add_subwindow(new BC_Title(x, y, _("Playback driver:"), MEDIUMFONT, BLACK));
99 //      add_subwindow(new AudioDriverMenu(x, y + 20, out_device, &(pwindow->thread->preferences->aconfig->audio_out_driver), 0, 1));
100         y += 60;
102         add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT, BLACK));
103         y += 30;
105         add_subwindow(new VideoEveryFrame(pwindow, x, y));
107         add_subwindow(new BC_Title(x + 200, y + 10, _("Framerate achieved:")));
108         add_subwindow(framerate_title = new BC_Title(x + 350, y + 10, _("--"), MEDIUMFONT, RED));
109         draw_framerate();
111         y += 35;
112         add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
113         y += 20;
114         add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow, 
115                 this, 
116                 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR, 
117                 10, 
118                 y));
119         y += 20;
120         add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow, 
121                 this, 
122                 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR, 
123                 10, 
124                 y));
125         y += 20;
126         add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow, 
127                 this, 
128                 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR, 
129                 10, 
130                 y));
132         y += 35;
133         add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT, BLACK));
134         sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
135         add_subwindow(new PlaybackPreload(x + 210, y, pwindow, this, string));
137 //      y += 30;
138 //      add_subwindow(new PlaybackDeblock(pwindow, 10, y));
140         y += 35;
141         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
142         video_device = new VDevicePrefs(x + 100, 
143                 y, 
144                 pwindow, 
145                 this, 
146                 playback_config->vconfig, 
147                 0,
148                 MODEPLAY);
149         video_device->initialize();
151 // Strategic playback options created here
152 //      set_strategy(pwindow->thread->edl->session->playback_strategy, y);
153         
155         return 0;
158 // char* PlaybackPrefs::strategy_to_string(int strategy)
159 // {
160 //      switch(strategy)
161 //      {
162 //              case PLAYBACK_LOCALHOST:
163 //                      return _("Local Host");
164 //                      break;
165 //              case PLAYBACK_MULTIHEAD:
166 //                      return _("Multihead");
167 //                      break;
168 //              case PLAYBACK_BLONDSYMPHONY:
169 //                      return _("Blond Symphony");
170 //                      break;
171 //      }
172 //      return _("Local Host");
173 // }
174 // 
175 // // Delete strategy dependant objects
176 // void PlaybackPrefs::delete_strategy()
177 // {
178 //      if(head_text) 
179 //      {
180 //              delete head_text;
181 //              delete head_title;
182 //              head_text = 0;
183 //      }
184 //      if(host_text)
185 //      {
186 //              delete host_title;
187 //              delete host_text;
188 //              host_text = 0;
189 //      }
190 //      if(head_count_text)
191 //      {
192 //              delete head_count_title;
193 //              delete head_count_text;
194 //              head_count_text = 0;
195 //      }
196 //      if(video_device)
197 //      {
198 //              delete vdevice_title;
199 //              delete video_device;
200 //              video_device = 0;
201 //      }
202 // }
203 // 
204 // int PlaybackPrefs::set_strategy(int strategy)
205 // {
206 //      int x = 350, x1 = 450, y = 10;
207 //      delete_strategy();
208 // 
209 //      pwindow->thread->edl->session->playback_strategy = strategy;
210 //      switch(strategy)
211 //      {
212 //              case PLAYBACK_LOCALHOST:
213 //                      break;
214 //              case PLAYBACK_MULTIHEAD:
215 //                      add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
216 //                      head_text = new PlaybackHead(this, x1, y);
217 //                      head_text->create_objects();
218 //                      y += 25;
219 //                      add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
220 //                      head_count_text = new PlaybackHeadCount(this, x1, y);
221 //                      head_count_text->create_objects();
222 //                      x = 10;
223 //                      y = 390;
224 //                      add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
225 //                      video_device = new VDevicePrefs(x + 100, 
226 //                              y, 
227 //                              pwindow, 
228 //                              this, 
229 //                              playback_config->vconfig, 
230 //                              0,
231 //                              MODEPLAY);
232 //                      video_device->initialize();
233 //                      break;
234 //              case PLAYBACK_BLONDSYMPHONY:
235 //                      add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
236 //                      head_text = new PlaybackHead(this, x1, y);
237 //                      head_text->create_objects();
238 //                      y += 25;
239 //                      add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
240 //                      head_count_text = new PlaybackHeadCount(this, x1, y);
241 //                      head_count_text->create_objects();
242 //                      y += 25;
243 //                      add_subwindow(host_title = new BC_Title(x, y, _("Hostname:")));
244 //                      add_subwindow(host_text = new PlaybackHost(this, x1, y));
245 //                      x = 10;
246 //                      y = 390;
247 //                      add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
248 //                      video_device = new VDevicePrefs(x + 100, 
249 //                              y, 
250 //                              pwindow, 
251 //                              this, 
252 //                              playback_config->vconfig,
253 //                              0,
254 //                              MODEPLAY);
255 //                      video_device->initialize();
256 //                      break;
257 //      }
258 //      
259 //      return 1;
260 // }
262 // ArrayList<PlaybackConfig*>* PlaybackPrefs::current_config_list()
263 // {
264 //      return pwindow->thread->edl->session->get_playback_config(
265 //              pwindow->thread->edl->session->playback_strategy);
266 // }
267 // 
268 // PlaybackConfig* PlaybackPrefs::current_config()
269 // {
270 //      return current_config_list()->values[current_head];
271 // }
274 void PlaybackPrefs::update(int interpolation)
276         pwindow->thread->edl->session->interpolation_type = interpolation;
277         nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
278 //      cubic_cubic->update(interpolation == CUBIC_CUBIC);
279         cubic_linear->update(interpolation == CUBIC_LINEAR);
280         linear_linear->update(interpolation == LINEAR_LINEAR);
284 int PlaybackPrefs::get_buffer_bytes()
286 //      return pwindow->thread->edl->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
289 int PlaybackPrefs::draw_framerate()
291 //printf("PlaybackPrefs::draw_framerate 1 %f\n", pwindow->thread->edl->session->actual_frame_rate);
292         char string[BCTEXTLEN];
293         sprintf(string, "%.4f", pwindow->thread->edl->session->actual_frame_rate);
294         framerate_title->update(string);
295         return 0;
302 // PlaybackStrategy::PlaybackStrategy(PlaybackPrefs *prefs, 
303 //      int x, 
304 //      int y)
305 //  : BC_PopupTextBox(prefs, 
306 //              &prefs->strategies,
307 //              prefs->strategy_to_string(prefs->pwindow->thread->edl->session->playback_strategy),
308 //              x, 
309 //              y, 
310 //              200,
311 //              100)
312 // {
313 //      this->prefs = prefs;
314 // }
315 // 
316 // int PlaybackStrategy::handle_event()
317 // {
318 //      prefs->set_strategy(get_number());
319 //      return 1;
320 // }
321 // 
322 // 
323 // 
324 // 
325 // 
326 // PlaybackHead::PlaybackHead(PlaybackPrefs *prefs, 
327 //      int x, 
328 //      int y)
329 //  : BC_TumbleTextBox(prefs, 
330 //              prefs->current_head,
331 //              (int64_t)0, 
332 //              (int64_t)prefs->current_config_list()->total - 1, 
333 //              x,
334 //              y,
335 //              100)
336 // {
337 //      this->prefs = prefs;
338 // }
339 // 
340 // int PlaybackHead::handle_event()
341 // {
342 //      return 1;
343 // }
344 // 
345 // PlaybackHeadCount::PlaybackHeadCount(PlaybackPrefs *prefs, 
346 //      int x, 
347 //      int y)
348 //  : BC_TumbleTextBox(prefs, 
349 //              prefs->current_config_list()->total, 
350 //              1, 
351 //              MAX_CHANNELS,
352 //              x,
353 //              y,
354 //              100)
355 // {
356 //      this->prefs = prefs;
357 // }
358 // 
359 // int PlaybackHeadCount::handle_event()
360 // {
361 //      return 1;
362 // }
363 // 
364 // 
365 // 
366 // PlaybackHost::PlaybackHost(PlaybackPrefs *prefs, int x, int y)
367 //  : BC_TextBox(x, y, 100, 1, prefs->current_config()->hostname)
368 // {
369 //      this->prefs = prefs; 
370 // }
371 // 
372 // int PlaybackHost::handle_event() 
373 // {
374 //      strcpy(prefs->current_config()->hostname, get_text()); 
375 //      return 1;
376 // }
381 // PlaybackReadLength::PlaybackReadLength(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
382 //  : BC_TextBox(x, y, 100, 1, text)
383 // { 
384 //      this->pwindow = pwindow; 
385 //      this->playback = playback; 
386 // }
387 // 
388 // int PlaybackReadLength::handle_event() 
389 // { 
390 //      pwindow->thread->edl->session->audio_read_length = atol(get_text()); 
391 //      return 1;
392 // }
394 // PlaybackBufferSize::PlaybackBufferSize(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
395 //  : BC_TextBox(x, y, 100, 1, text)
396 // { 
397 //      this->pwindow = pwindow; 
398 //      this->playback = playback; 
399 // }
400 // 
401 // int PlaybackBufferSize::handle_event() 
402 // {
403 //      pwindow->thread->edl->session->playback_buffer = atol(get_text()); 
404 //      return 1;
405 // }
406 // 
407 // PlaybackBufferBytes::PlaybackBufferBytes(int x, 
408 //      int y, 
409 //      PreferencesWindow *pwindow, 
410 //      PlaybackPrefs *playback, 
411 //      char *text)
412 //  : BC_Title(x, y, text)
413 // {
414 //      this->pwindow = pwindow; 
415 //      this->playback = playback;
416 // }
417 // int PlaybackBufferBytes::update_bytes()
418 // {
419 //      sprintf(string, "%d", playback->get_buffer_bytes());
420 //      update(string);
421 //      return 1;
422 // }
423 // 
424 // PlaybackDisableNoEdits::PlaybackDisableNoEdits(PreferencesWindow *pwindow, int value, int y)
425 //  : BC_CheckBox(10, y, value, _("Disable tracks when no edits."))
426 // {
427 //      this->pwindow = pwindow; 
428 // }
429 // 
430 // int PlaybackDisableNoEdits::handle_event() 
431 // { 
432 //      pwindow->thread->edl->session->test_playback_edits = get_value(); 
433 //      return 1;
434 // }
438 PlaybackModuleFragment::PlaybackModuleFragment(int x, 
439         int y, 
440         PreferencesWindow *pwindow, 
441         PlaybackPrefs *playback, 
442         char *text)
443  : BC_PopupMenu(x, 
444         y, 
445         100, 
446         text,
447         1)
449         this->pwindow = pwindow;
450         this->playback = playback;
453 int PlaybackModuleFragment::handle_event() 
455         playback->playback_config->aconfig->fragment_size = atol(get_text()); 
456         return 1;
462 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
463  : BC_CheckBox(10, y, value, _("View follows playback"))
465         this->pwindow = pwindow; 
468 int PlaybackViewFollows::handle_event() 
470         pwindow->thread->edl->session->view_follows_playback = get_value(); 
471         return 1;
477 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
478  : BC_CheckBox(10, y, value, _("Use software for positioning information"))
480         this->pwindow = pwindow; 
483 int PlaybackSoftwareTimer::handle_event() 
485         pwindow->thread->edl->session->playback_software_position = get_value(); 
486         return 1;
492 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
493  : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
495         this->pwindow = pwindow; 
498 int PlaybackRealTime::handle_event() 
500         pwindow->thread->edl->session->real_time_playback = get_value(); 
501         return 1;
510 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
511  : BC_Radial(x, y, value, _("Nearest neighbor enlarge and reduce"))
513         this->pwindow = pwindow;
514         this->prefs = prefs;
516 int PlaybackNearest::handle_event()
518         prefs->update(NEAREST_NEIGHBOR);
519         return 1;
526 PlaybackBicubicBicubic::PlaybackBicubicBicubic(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
527  : BC_Radial(x, y, value, _("Bicubic enlarge and reduce"))
529         this->pwindow = pwindow;
530         this->prefs = prefs;
532 int PlaybackBicubicBicubic::handle_event()
534         prefs->update(CUBIC_CUBIC);
535         return 1;
541 PlaybackBicubicBilinear::PlaybackBicubicBilinear(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
542  : BC_Radial(x, y, value, _("Bicubic enlarge and bilinear reduce"))
544         this->pwindow = pwindow;
545         this->prefs = prefs;
547 int PlaybackBicubicBilinear::handle_event()
549         prefs->update(CUBIC_LINEAR);
550         return 1;
554 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow, 
555         PlaybackPrefs *prefs, 
556         int value, 
557         int x, 
558         int y)
559  : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
561         this->pwindow = pwindow;
562         this->prefs = prefs;
564 int PlaybackBilinearBilinear::handle_event()
566         prefs->update(LINEAR_LINEAR);
567         return 1;
571 PlaybackPreload::PlaybackPreload(int x, 
572         int y, 
573         PreferencesWindow *pwindow, 
574         PlaybackPrefs *playback, 
575         char *text)
576  : BC_TextBox(x, y, 100, 1, text)
578         this->pwindow = pwindow; 
579         this->playback = playback; 
582 int PlaybackPreload::handle_event() 
584         pwindow->thread->edl->session->playback_preload = atol(get_text()); 
585         return 1;
590 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow, int x, int y)
591  : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
593         this->pwindow = pwindow;
596 int VideoEveryFrame::handle_event()
598         pwindow->thread->edl->session->video_every_frame = get_value();
599         return 1;
606 // PlaybackDeblock::PlaybackDeblock(PreferencesWindow *pwindow, int x, int y)
607 //  : BC_CheckBox(x, 
608 //      y, 
609 //      pwindow->thread->edl->session->mpeg4_deblock, 
610 //      _("MPEG-4 Deblocking"))
611 // {
612 //      this->pwindow = pwindow;
613 // }
614 // 
615 // int PlaybackDeblock::handle_event()
616 // {
617 //      pwindow->thread->edl->session->mpeg4_deblock = get_value();
618 //      return 1;
619 // }
620 //