Andrew contribution to add preference method for Fast/Slow speed
authorGood Guy <[email protected]>
Tue, 10 Aug 2021 23:22:15 +0000 (17:22 -0600)
committerGood Guy <[email protected]>
Tue, 10 Aug 2021 23:22:15 +0000 (17:22 -0600)
22 files changed:
cinelerra-5.1/cinelerra/amodule.C
cinelerra-5.1/cinelerra/assetpopup.C
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/batchrender.C
cinelerra-5.1/cinelerra/fileref.C
cinelerra-5.1/cinelerra/indexfile.C
cinelerra-5.1/cinelerra/mixersalign.C
cinelerra-5.1/cinelerra/packagerenderer.C
cinelerra-5.1/cinelerra/playbackengine.C
cinelerra-5.1/cinelerra/preferences.C
cinelerra-5.1/cinelerra/preferences.h
cinelerra-5.1/cinelerra/proxy.C
cinelerra-5.1/cinelerra/render.C
cinelerra-5.1/cinelerra/renderengine.C
cinelerra-5.1/cinelerra/resourcepixmap.C
cinelerra-5.1/cinelerra/resourcethread.C
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/cinelerra/transportque.C
cinelerra-5.1/cinelerra/transportque.h
cinelerra-5.1/cinelerra/vmodule.C
cinelerra-5.1/cinelerra/vwindowgui.C
cinelerra-5.1/plugins/titler/titler.C

index d8fb4396437ecea793686c20b5d55539880bdfd6..f8d2e78933a076327614b721398c0d55101777ac 100644 (file)
@@ -283,7 +283,7 @@ int AModule::import_samples(AEdit *edit,
                int command = direction == PLAY_REVERSE ?
                        NORMAL_REWIND : NORMAL_FWD;
                if( !nested_command )
-                       nested_command = new TransportCommand;
+                       nested_command = new TransportCommand(get_preferences());
                nested_command->command = command;
                nested_command->get_edl()->copy_all(nested_edl);
                nested_command->change_type = CHANGE_ALL;
index bbdf172fc2dbcc1fb5a4ec5f334c1bcb8f01f904..66b3361a29b7ec22aad033fad9fe8e9236b23740 100644 (file)
@@ -949,7 +949,7 @@ int SnapshotMenuItem::handle_event()
                        processors > 1 ? 2 : 1, 0);
                VFrame ***frames = file.get_video_buffer();
                VFrame *frame = frames[0][0];
-               TransportCommand command;
+               TransportCommand command(preferences);
                //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME;
                command.command = CURRENT_FRAME;
                command.get_edl()->copy_all(edl);
index 67c759180d05200a9034193f6e21e2887fbda066..be782977341a96c11781ec0a8c743c51c2a658e7 100644 (file)
@@ -882,7 +882,7 @@ void AssetPicon::reset()
 
 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
 {
-       TransportCommand command;
+       TransportCommand command(mwindow->preferences);
        command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
        command.get_edl()->copy_all(edl);
        command.change_type = CHANGE_ALL;
index ace9e562ff735510f53027275484b639b9c72f48..b657e0f096002b6a8525cb803590b490fccdb015 100644 (file)
@@ -542,7 +542,7 @@ void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
                        PackageDispatcher *packages = new PackageDispatcher;
 
 // Load EDL
-                       TransportCommand *command = new TransportCommand;
+                       TransportCommand *command = new TransportCommand(preferences);
                        FileXML *file = new FileXML;
                        file->read_from_file(job->edl_path);
 
index a60b3f3e4e5b678a75a69b0543a91af868c7cee8..094c44ec8c9cb21de5c1a38e0dfc95338bf00765 100644 (file)
@@ -96,7 +96,7 @@ int FileREF::open_file(int rd, int wr)
                asset->sample_rate = ref->get_sample_rate();
                asset->audio_length = asset->audio_data ? ref->get_audio_samples() : 0;
                strcpy(asset->acodec, "REF");
-               command = new TransportCommand();
+               command = new TransportCommand(file->preferences);
                command->reset();
                command->get_edl()->copy_all(ref);
                command->command = NORMAL_FWD;
index 0337d0c2062d9e932051f86721b2939c7f61d1a9..977ad1cbfd5c99cb7239dca14479baed5570d691 100644 (file)
@@ -350,7 +350,7 @@ int IndexFile::open_source()
        }
        else
        {
-               TransportCommand command;
+               TransportCommand command(mwindow->preferences);
                command.command = NORMAL_FWD;
                command.get_edl()->copy_all((EDL*)indexable);
                command.change_type = CHANGE_ALL;
index 6e9abcc6260340dcace8b27e35e952b370f5ecaa..bd4116f39bd0a595443f4f39da4e73792b46b14e 100644 (file)
@@ -1011,7 +1011,7 @@ void MixersAlign::apply_undo(int no)
 MixersAlignARender::MixersAlignARender(MWindow *mwindow, EDL *edl)
  : RenderEngine(0, mwindow->preferences, 0, 0)
 {
-       TransportCommand command;
+       TransportCommand command(mwindow->preferences);
        command.command = NORMAL_FWD;
        command.get_edl()->copy_all(edl);
        command.change_type = CHANGE_ALL;
index 1c86af68d02b5bb2d050cfa2b5a52a463c4514fb..49aaf98af72f6e08d648e34f7eda428170549fa4 100644 (file)
@@ -137,7 +137,7 @@ int PackageRenderer::initialize(MWindow *mwindow,
 
 
 //printf("PackageRenderer::initialize %d\n", preferences->processors);
-       command = new TransportCommand;
+       command = new TransportCommand(preferences);
        command->command = NORMAL_FWD;
        command->get_edl()->copy_all(edl);
        command->change_type = CHANGE_ALL;
index 3b2b9ed4313f2ac01699179015e7fd61a85c9bf4..815e506fa9dd684eb2e13427b2baf3fb3098739a 100644 (file)
@@ -56,14 +56,14 @@ PlaybackEngine::PlaybackEngine(MWindow *mwindow, Canvas *output)
        tracking_active = 0;
        audio_cache = 0;
        video_cache = 0;
-       command = new TransportCommand();
+       command = new TransportCommand(mwindow->preferences);
        command->command = STOP;
-       next_command = new TransportCommand();
+       next_command = new TransportCommand(mwindow->preferences);
        next_command->change_type = CHANGE_ALL;
-       stop_command = new TransportCommand();
+       stop_command = new TransportCommand(mwindow->preferences);
        stop_command->command = STOP;
        stop_command->realtime = 1;
-       sent_command = new TransportCommand();
+       sent_command = new TransportCommand(mwindow->preferences);
        sent_command->command = -1;
        send_active = 0;
        tracking_lock = new Mutex("PlaybackEngine::tracking_lock");
index f4716a723c1a774e58721615c4390257628b7f0b..2b8d84bd969414fd12d0923fb0e10dd4dfa0886c 100644 (file)
@@ -128,6 +128,9 @@ Preferences::Preferences()
        android_remote = 0;
        android_port = 23432;
        strcpy(android_pin, "cinelerra");
+       
+       fast_speed = 2.0;
+       slow_speed = 0.5;
 
        memset(channel_positions, 0, sizeof(channel_positions));
        int channels = 0;
@@ -201,6 +204,10 @@ void Preferences::copy_from(Preferences *that)
        android_remote = that->android_remote;
        android_port = that->android_port;
        strcpy(android_pin, that->android_pin);
+       
+       slow_speed = that->slow_speed;
+       fast_speed = that->fast_speed;
+       
        this->shbtn_prefs.remove_all_objects();
        for( int i=0; i<that->shbtn_prefs.size(); ++i )
                this->shbtn_prefs.append(new ShBtnPref(*that->shbtn_prefs[i]));
@@ -332,6 +339,8 @@ int Preferences::load_defaults(BC_Hash *defaults)
        scan_commercials = defaults->get("SCAN_COMMERCIALS", scan_commercials);
        android_remote = defaults->get("ANDROID_REMOTE", android_remote);
        android_port = defaults->get("ANDROID_PORT", android_port);
+       fast_speed = defaults->get("FAST_SPEED", fast_speed);
+       slow_speed = defaults->get("SLOW_SPEED", slow_speed);
        defaults->get("ANDROID_PIN", android_pin);
        defaults->get("INDEX_DIRECTORY", index_directory);
        index_size = defaults->get("INDEX_SIZE", index_size);
@@ -495,7 +504,8 @@ int Preferences::save_defaults(BC_Hash *defaults)
        defaults->update("ANDROID_REMOTE", android_remote);
        defaults->update("ANDROID_PIN", android_pin);
        defaults->update("ANDROID_PORT", android_port);
-
+       defaults->update("SLOW_SPEED", slow_speed);
+       defaults->update("FAST_SPEED", fast_speed);
        defaults->update("CACHE_SIZE", cache_size);
        defaults->update("CACHE_TRANSITIONS", cache_transitions);
        defaults->update("INDEX_DIRECTORY", index_directory);
index 7dd3871c961d162c8b93215af9b80826eabdae80..4f743975ea04ea8eb41a8853b7792a25e25d93c9 100644 (file)
@@ -193,6 +193,9 @@ public:
        ArrayList<ShBtnPref *> shbtn_prefs;
 // file open probe order
        ArrayList<ProbePref *> file_probes;
+// fast/slow forward and backward speeds, default 2.0/0.5
+       float fast_speed;
+       float slow_speed;
 
 // ====================================== Plugin Set ==============================
        char plugin_dir[BCTEXTLEN];
index 64897df96a338f6a2adef99dddc362bb8f4c1020..0012fd1924d1b0fb40ce992b13a60605641fa86f 100644 (file)
@@ -741,7 +741,7 @@ void ProxyClient::process_package(LoadPackage *ptr)
                        result = 1;
        }
        else {
-               TransportCommand command;
+               TransportCommand command(preferences);
                command.command = CURRENT_FRAME;
                command.get_edl()->copy_all((EDL *)orig);
                command.change_type = CHANGE_ALL;
index a7456717556bc3e58e194578bf297de7ab7576c2..77e7ce790f39413d53b60e883feb68e79a999adf 100644 (file)
@@ -684,7 +684,7 @@ void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl,
        render->result = 0;
 
 // Create rendering command
-       TransportCommand *command = new TransportCommand;
+       TransportCommand *command = new TransportCommand(mwindow->preferences);
        command->command = NORMAL_FWD;
        command->get_edl()->copy_all(edl);
        command->change_type = CHANGE_ALL;
index 0d8b06342fba9f7d1896f53f62aa06c29f7e5763..7e7a52d75163c108adfe90165b8845b0b07eaa70 100644 (file)
@@ -62,7 +62,7 @@ RenderEngine::RenderEngine(PlaybackEngine *playback_engine,
        do_video = 0;
        interrupted = 0;
        this->preferences = new Preferences;
-       this->command = new TransportCommand;
+       this->command = new TransportCommand(preferences);
        this->preferences->copy_from(preferences);
        edl = 0;
 
index 991b85d4c65eb0ee89a9ec62d8478bf3c8df8a6d..1406dd2d8280191f01a3c986e3aad42945a04d74 100644 (file)
@@ -472,7 +472,7 @@ void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, i
                        }
 
                        if( !mwindow->gui->render_engine ) {
-                               TransportCommand command;
+                               TransportCommand command(mwindow->preferences);
                                command.command = NORMAL_FWD;
                                command.get_edl()->copy_all(edit->nested_edl);
                                command.change_type = CHANGE_ALL;
index fca02199b4f7f54cbdb7b83edd2a0a471f78d96b..18b8dc813fe65e76f08f9554f28025bd428356d9 100644 (file)
@@ -327,7 +327,7 @@ void ResourceThreadBase::open_render_engine(EDL *nested_edl,
 
        if( !render_engine ) {
                MWindow *mwindow = resource_thread->mwindow;
-               TransportCommand command;
+               TransportCommand command(mwindow->preferences);
                command.command = do_audio ? NORMAL_FWD : CURRENT_FRAME;
                command.get_edl()->copy_all(nested_edl);
                command.change_type = CHANGE_ALL;
index d15f9a3774f0978adece81815e2adc412342b89e..d39ce4554757009a84897e7828a093c4415e1588 100644 (file)
@@ -4601,7 +4601,7 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode)
        case 0: {
                VFrame vlt(edl->get_w(), edl->get_h(), edl->session->color_model);
                VFrame vrt(edl->get_w(), edl->get_h(), edl->session->color_model);
-               TransportCommand command;
+               TransportCommand command(mwindow->preferences);
                command.command = CURRENT_FRAME;
                command.get_edl()->copy_all((EDL *)edl);
                command.change_type = CHANGE_ALL;
index a8c1fb9297b065c1000afa793c2cc6f9f5046f4a..5048beaf73cc42520323514b38255f4b324bcf2e 100644 (file)
 #include "edlsession.h"
 #include "localsession.h"
 #include "playbackengine.h"
+#include "preferences.h"
 #include "tracks.h"
 #include "transportque.h"
 
-TransportCommand::TransportCommand()
+
+TransportCommand::TransportCommand(Preferences *preferences)
 {
 // In rendering we want a master EDL so settings don't get clobbered
 // in the middle of a job.
@@ -37,6 +39,7 @@ TransportCommand::TransportCommand()
        edl->create_objects();
        command = 0;
        change_type = 0;
+       this->preferences = preferences;
        reset();
 }
 
@@ -134,10 +137,16 @@ int TransportCommand::get_direction(int command)
 
 float TransportCommand::get_speed(int command, float speed)
 {
+// fast = 2.0, slow = 0.5
+// float my_fast_speed = 2.0;
+// float my_slow_speed = 0.5;
+float my_fast_speed = preferences->fast_speed;
+float my_slow_speed = preferences->slow_speed; 
+
        switch(command) {
        case SLOW_FWD:
        case SLOW_REWIND:
-               return speed ? speed : 0.5;
+               return speed ? speed : my_slow_speed;
 
        case NORMAL_FWD:
        case NORMAL_REWIND:
@@ -149,7 +158,7 @@ float TransportCommand::get_speed(int command, float speed)
 
        case FAST_FWD:
        case FAST_REWIND:
-               return speed ? speed : 2.;
+               return speed ? speed : my_fast_speed;
        }
 
        return 0.;
index 2594594ff7a4723b180b8d84d023cdc64b134a3f..fcfc1703154d613b7a90741d1ae85ce6685c5ea3 100644 (file)
 #include "condition.inc"
 #include "edl.inc"
 #include "playbackengine.inc"
+#include "preferences.inc"
 #include "transportque.inc"
 
 class TransportCommand
 {
 public:
-       TransportCommand();
+       TransportCommand(Preferences *preferences);
        ~TransportCommand();
 
        void reset();
@@ -41,7 +42,7 @@ public:
        void set_playback_range(EDL *edl, int use_inout, int do_displacement);
        static int single_frame(int command);
        static int get_direction(int command);
-       static float get_speed(int command, float speed=0);
+       float get_speed(int command, float speed=0);
 
 // Adjust playback range with in/out points for rendering
        void playback_range_adjust_inout();
@@ -84,6 +85,7 @@ public:
 private:
 // Copied to render engines
        EDL *edl;
+       Preferences *preferences;
 };
 
 #endif
index e2a2f7f6f8453e264919a08826694205b54104a3..64521524935e21bf63beea9aeab79b57aa33931a 100644 (file)
@@ -178,7 +178,7 @@ int VModule::import_frame(VFrame *output, VEdit *current_edit,
                                nested_renderengine = 0;
                        }
                        if( !nested_command )
-                               nested_command = new TransportCommand;
+                               nested_command = new TransportCommand(get_preferences());
                        nested_command->command = command;
                        nested_command->get_edl()->copy_all(nested_edl);
                        nested_command->change_type = CHANGE_ALL;
index 196b2980630197ee7ee8f65bb24590523ceed882..9b7f6ca8cafced412de405ac6e856b3600ab6bde 100644 (file)
@@ -97,7 +97,7 @@ VWindowGUI::~VWindowGUI()
 
 void VWindowGUI::draw_wave()
 {
-       TransportCommand command;
+       TransportCommand command(mwindow->preferences);
        command.command = NORMAL_FWD;
        command.get_edl()->copy_all(vwindow->get_edl());
        command.change_type = CHANGE_ALL;
index 95218e4c83dc0545be551aa2b73b73c64c553f40..06fb7938278aa654505471e5041683b4d25ab0c7 100644 (file)
@@ -1213,7 +1213,7 @@ Indexable *TitleMain::open_background(const char *filename)
        nested_edl->create_objects();
        nested_edl->set_path(filename);
        nested_edl->load_xml(&xml_file, LOAD_ALL);
-       TransportCommand command;
+       TransportCommand command(server->preferences);
        //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME;
        command.command = CURRENT_FRAME;
        command.get_edl()->copy_all(nested_edl);