From a70cf593410cada9f0ca8bc515534c635a9cb495 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 4 Apr 2019 19:54:08 -0600 Subject: [PATCH] update shortcuts, rework update_lv2 for jitter bug, override LV2_PATH --- cinelerra-5.1/cinelerra/audioalsa.C | 16 ++---- cinelerra-5.1/cinelerra/mwindow.C | 9 +--- cinelerra-5.1/cinelerra/pluginlv2.C | 7 ++- cinelerra-5.1/cinelerra/pluginlv2.h | 4 +- cinelerra-5.1/cinelerra/pluginlv2client.C | 62 ++++++++++++++++------- cinelerra-5.1/cinelerra/pluginlv2client.h | 10 ++-- cinelerra-5.1/cinelerra/pluginlv2gui.C | 2 +- cinelerra-5.1/cinelerra/pluginlv2ui.C | 16 ++++-- cinelerra-5.1/doc/shortcuts.html | 8 ++- 9 files changed, 83 insertions(+), 51 deletions(-) diff --git a/cinelerra-5.1/cinelerra/audioalsa.C b/cinelerra-5.1/cinelerra/audioalsa.C index 07afaa79..f256a506 100644 --- a/cinelerra-5.1/cinelerra/audioalsa.C +++ b/cinelerra-5.1/cinelerra/audioalsa.C @@ -234,18 +234,10 @@ snd_pcm_format_t AudioALSA::translate_format(int format) { switch(format) { - case 8: - return SND_PCM_FORMAT_S8; - break; - case 16: - return SND_PCM_FORMAT_S16_LE; - break; - case 24: - return SND_PCM_FORMAT_S24_LE; - break; - case 32: - return SND_PCM_FORMAT_S32_LE; - break; + case 8: return SND_PCM_FORMAT_S8; + case 16: return SND_PCM_FORMAT_S16_LE; + case 24: return SND_PCM_FORMAT_S24_LE; + case 32: return SND_PCM_FORMAT_S32_LE; } return SND_PCM_FORMAT_UNKNOWN; } diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 546444fe..14d06c93 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -939,14 +939,7 @@ void MWindow::init_preferences() { preferences = new Preferences; preferences->load_defaults(defaults); - const char *lv2_path = getenv("LV2_PATH"); - if( lv2_path && strcmp(lv2_path, preferences->lv2_path) ) { - strncpy(preferences->lv2_path, lv2_path, sizeof(preferences->lv2_path)); - remove_plugin_index(); - } - else if( !lv2_path && preferences->lv2_path[0] ) { - File::setenv_path("LV2_PATH",preferences->lv2_path, 0); - } + File::setenv_path("LV2_PATH",preferences->lv2_path, 0); session = new MainSession(this); session->load_defaults(defaults); // set x11_host, screens, window_config diff --git a/cinelerra-5.1/cinelerra/pluginlv2.C b/cinelerra-5.1/cinelerra/pluginlv2.C index d1c5a8c4..7b7dc678 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2.C +++ b/cinelerra-5.1/cinelerra/pluginlv2.C @@ -22,6 +22,7 @@ PluginLV2::PluginLV2() samplerate = 44100; refreshrate = 30.; + min_block_length = 1; block_length = 4096; midi_buf_size = 8192; @@ -189,9 +190,10 @@ int PluginLV2::init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz) ui_updateRate = uri_table.map(LV2_UI__updateRate); samplerate = sample_rate; - block_length = bfrsz; options.add(param_sampleRate, sizeof(float), atom_float, &samplerate); - options.add(bufsz_minBlockLength, sizeof(int), atom_int, &block_length); + if( min_block_length > bfrsz ) min_block_length = bfrsz; + options.add(bufsz_minBlockLength, sizeof(int), atom_int, &min_block_length); + block_length = bfrsz; options.add(bufsz_maxBlockLength, sizeof(int), atom_int, &block_length); options.add(bufsz_sequenceSize, sizeof(int), atom_int, &midi_buf_size); options.add(ui_updateRate, sizeof(float), atom_float, &refreshrate); @@ -218,6 +220,7 @@ int PluginLV2::init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz) (lilv_plugin_has_feature(lilv, powerOf2BlockLength) || lilv_plugin_has_feature(lilv, fixedBlockLength) || lilv_plugin_has_feature(lilv, boundedBlockLength)) ? 4096 : 0; + init_buffer(bfrsz); return 0; } diff --git a/cinelerra-5.1/cinelerra/pluginlv2.h b/cinelerra-5.1/cinelerra/pluginlv2.h index 075816a7..ac99d253 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2.h +++ b/cinelerra-5.1/cinelerra/pluginlv2.h @@ -90,7 +90,8 @@ public: LV2_Atom_Sequence seq_in[2]; LV2_Atom_Sequence *seq_out; float samplerate, refreshrate; - int block_length, midi_buf_size; + int min_block_length, block_length; + int midi_buf_size; LilvInstance *inst; SuilInstance *sinst; @@ -146,6 +147,7 @@ typedef struct { int sample_rate, bfrsz; char path[1]; } open_bfr_t; enum { NO_COMMAND, LV2_OPEN, LV2_LOAD, + LV2_CONFIG, LV2_UPDATE, LV2_SHOW, LV2_HIDE, diff --git a/cinelerra-5.1/cinelerra/pluginlv2client.C b/cinelerra-5.1/cinelerra/pluginlv2client.C index 289eed4e..d416987f 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2client.C +++ b/cinelerra-5.1/cinelerra/pluginlv2client.C @@ -182,6 +182,7 @@ int PluginLV2Client::load_configuration() { int64_t src_position = get_source_position(); KeyFrame *prev_keyframe = get_prev_keyframe(src_position); + if( prev_keyframe->is_default ) return 0; PluginLV2ClientConfig curr_config; curr_config.copy_from(config); read_data(prev_keyframe); @@ -198,16 +199,16 @@ void PluginLV2Client::update_gui() load_configuration(); if( config.update() > 0 ) { gui->update_selected(); - update_lv2(); + update_lv2(LV2_UPDATE); } gui->unlock_window(); } -void PluginLV2Client::update_lv2() +void PluginLV2Client::update_lv2(int token) { PluginLV2ParentUI *ui = find_ui(); if( !ui ) return; - ui->send_child(LV2_UPDATE, config.ctls, sizeof(float)*config.nb_ports); + ui->send_child(token, config.ctls, sizeof(float)*config.nb_ports); } @@ -295,27 +296,54 @@ void PluginLV2Client::process_buffer(int size) } int PluginLV2Client::process_realtime(int64_t size, - Samples *input_ptr, Samples *output_ptr) -{ - if( load_configuration() ) - update_lv2(); - init_buffer(size); - load_buffer(size, &input_ptr, 1); - process_buffer(size); - return unload_buffer(size, &output_ptr, 1); + Samples **input_ptr, Samples **output_ptr, int chs) +{ + int64_t pos = get_source_position(); + int64_t end = pos + size; + int64_t samples = 0; + while( pos < end ) { + KeyFrame *prev_keyframe = get_prev_keyframe(pos); + if( !prev_keyframe->is_default ) { + read_data(prev_keyframe); + update_lv2(LV2_CONFIG); + } + KeyFrame *next_keyframe = get_next_keyframe(pos); + int64_t next_pos = next_keyframe->position; + if( pos >= next_pos || next_pos > end ) + next_pos = end; + int64_t len = next_pos - pos; + if( len > block_length ) + len = block_length; + if( pos + len > end ) + len = end - pos; + init_buffer(len); + for( int i=chs; --i>=0; ) { + input_ptr[i]->set_offset(samples); + output_ptr[i]->set_offset(samples); + } + load_buffer(len, input_ptr, chs); + process_buffer(len); + unload_buffer(len, output_ptr, chs); + samples += len; + pos += len; + } + for( int i=chs; --i>=0; ) + output_ptr[i]->set_offset(0); + return samples; } int PluginLV2Client::process_realtime(int64_t size, Samples **input_ptr, Samples **output_ptr) { - if( load_configuration() ) - update_lv2(); - init_buffer(size); - load_buffer(size, input_ptr, PluginClient::total_in_buffers); - process_buffer(size); - return unload_buffer(size, output_ptr, PluginClient::total_out_buffers); + return process_realtime(size, input_ptr, output_ptr, + PluginClient::total_out_buffers); } +int PluginLV2Client::process_realtime(int64_t size, + Samples *input_ptr, Samples *output_ptr) +{ + return process_realtime(size, &input_ptr, &output_ptr, 1); +} PluginLV2BlackList::PluginLV2BlackList(const char *path) { diff --git a/cinelerra-5.1/cinelerra/pluginlv2client.h b/cinelerra-5.1/cinelerra/pluginlv2client.h index 1f5f3b35..80654ef5 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2client.h +++ b/cinelerra-5.1/cinelerra/pluginlv2client.h @@ -69,11 +69,11 @@ public: ~PluginLV2Client(); int process_realtime(int64_t size, - Samples *input_ptr, - Samples *output_ptr); + Samples **input_ptr, Samples **output_ptr, int chs); int process_realtime(int64_t size, - Samples **input_ptr, - Samples **output_ptr); + Samples *input_ptr, Samples *output_ptr); + int process_realtime(int64_t size, + Samples **input_ptr, Samples **output_ptr); // Update output pointers as well int is_realtime(); int is_multichannel(); @@ -86,7 +86,7 @@ public: int unload_buffer(int samples, Samples **output, int och); void process_buffer(int size); void update_gui(); - void update_lv2(); + void update_lv2(int token); int init_lv2(); PluginLV2ParentUI *find_ui(); PluginLV2ParentUI *get_ui(); diff --git a/cinelerra-5.1/cinelerra/pluginlv2gui.C b/cinelerra-5.1/cinelerra/pluginlv2gui.C index 9ae3ba39..cbd5b67f 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2gui.C +++ b/cinelerra-5.1/cinelerra/pluginlv2gui.C @@ -72,7 +72,7 @@ int PluginLV2ClientReset::handle_event() PluginLV2Client *client = gui->client; client->config.init_lv2(client->lilv, client); client->config.update(); - client->update_lv2(); + client->update_lv2(LV2_LOAD); gui->update(0); client->send_configure_change(); return 1; diff --git a/cinelerra-5.1/cinelerra/pluginlv2ui.C b/cinelerra-5.1/cinelerra/pluginlv2ui.C index 17f072a2..80bf250f 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2ui.C +++ b/cinelerra-5.1/cinelerra/pluginlv2ui.C @@ -114,6 +114,7 @@ bool PluginLV2UI::lv2ui_resizable() return !fs_matches && !nrs_matches; } +//force= 1:ctls(all),gui(all) 0:changed(ctls) -1:gui(all) int PluginLV2UI::update_lv2_input(float *vals, int force) { int ret = 0; @@ -122,9 +123,12 @@ int PluginLV2UI::update_lv2_input(float *vals, int force) int idx = config[i]->idx; float val = vals[idx]; if( !force && ctls[idx] == val ) continue; - ctls[idx] = val; - update_control(idx, sizeof(ctls[idx]), 0, &ctls[idx]); - ++ret; + if( force >= 0 ) { + ctls[idx] = val; + ++ret; + } + if( force ) + update_control(idx, sizeof(val), 0, &val); } return ret; } @@ -328,10 +332,14 @@ int PluginLV2ChildUI::child_iteration(int64_t usec) float *vals = (float *)child_data; update_lv2_input(vals, 1); break; } - case LV2_UPDATE: { + case LV2_CONFIG: { float *vals = (float *)child_data; update_lv2_input(vals, 0); break; } + case LV2_UPDATE: { + float *vals = (float *)child_data; + update_lv2_input(vals, -1); + break; } case LV2_SHOW: { start_gui(); break; } diff --git a/cinelerra-5.1/doc/shortcuts.html b/cinelerra-5.1/doc/shortcuts.html index f55a469d..22ece808 100644 --- a/cinelerra-5.1/doc/shortcuts.html +++ b/cinelerra-5.1/doc/shortcuts.html @@ -129,7 +129,7 @@ DVD Render… - 'Shift-D' + 'Alt-d' Open create dvd disk window @@ -462,6 +462,12 @@ 'd' Delete last track + +
+ Delete first track + 'Shift-D' + Delete first track +
Concatenate trks -- 2.26.2