projects
/
goodguy
/
history.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
merged hv7 mod
[goodguy/history.git]
/
cinelerra-5.1
/
plugins
/
timestretchrt
/
timestretchrt.C
diff --git
a/cinelerra-5.1/plugins/timestretchrt/timestretchrt.C
b/cinelerra-5.1/plugins/timestretchrt/timestretchrt.C
index 5023212e154f121ece897dd3d95c64a99597221b..89b7efa4bc3a47a4b475a8327235d26faa91f080 100644
(file)
--- a/
cinelerra-5.1/plugins/timestretchrt/timestretchrt.C
+++ b/
cinelerra-5.1/plugins/timestretchrt/timestretchrt.C
@@
-42,19
+42,26
@@
REGISTER_PLUGIN(TimeStretchRT);
TimeStretchRTConfig::TimeStretchRTConfig()
{
TimeStretchRTConfig::TimeStretchRTConfig()
{
- scale = 1;
+// scale = 1;
+ num = 1;
+ denom = 1;
size = 40;
}
int TimeStretchRTConfig::equivalent(TimeStretchRTConfig &src)
{
size = 40;
}
int TimeStretchRTConfig::equivalent(TimeStretchRTConfig &src)
{
- return fabs(scale - src.scale) < 0.0001 && size == src.size;
+// return fabs(scale - src.scale) < 0.0001 && size == src.size;
+ return fabs(num - src.num) < 0.0001 &&
+ fabs(denom - src.denom) < 0.0001 &&
+ size == src.size;
}
void TimeStretchRTConfig::copy_from(TimeStretchRTConfig &src)
{
}
void TimeStretchRTConfig::copy_from(TimeStretchRTConfig &src)
{
- this->scale = src.scale;
+ this->num = src.num;
+ this->denom = src.denom;
+// this->scale = src.scale;
this->size = src.size;
}
this->size = src.size;
}
@@
-64,15
+71,19
@@
void TimeStretchRTConfig::interpolate(TimeStretchRTConfig &prev,
int64_t next_frame,
int64_t current_frame)
{
int64_t next_frame,
int64_t current_frame)
{
- this->scale = prev.scale;
+ this->num = prev.num;
+ this->denom = prev.denom;
+// this->scale = prev.scale;
this->size = prev.size;
boundaries();
}
void TimeStretchRTConfig::boundaries()
{
this->size = prev.size;
boundaries();
}
void TimeStretchRTConfig::boundaries()
{
- if(fabs(scale) < 0.01) scale = 0.01;
- if(fabs(scale) > 100) scale = 100;
+ if(num < 0.0001) num = 0.0001;
+ if(denom < 0.0001) denom = 0.0001;
+// if(fabs(scale) < 0.01) scale = 0.01;
+// if(fabs(scale) > 100) scale = 100;
if(size < 10) size = 10;
if(size > 1000) size = 1000;
}
if(size < 10) size = 10;
if(size > 1000) size = 1000;
}
@@
-82,10
+93,10
@@
void TimeStretchRTConfig::boundaries()
TimeStretchRTWindow::TimeStretchRTWindow(TimeStretchRT *plugin)
: PluginClientWindow(plugin,
TimeStretchRTWindow::TimeStretchRTWindow(TimeStretchRT *plugin)
: PluginClientWindow(plugin,
+ 210,
+ 200,
+ 200,
210,
210,
- 160,
- 200,
- 160,
0)
{
this->plugin = plugin;
0)
{
this->plugin = plugin;
@@
-98,19
+109,31
@@
TimeStretchRTWindow::~TimeStretchRTWindow()
void TimeStretchRTWindow::create_objects()
{
int x = 10, y = 10;
void TimeStretchRTWindow::create_objects()
{
int x = 10, y = 10;
+ int margin = plugin->get_theme()->widget_border;
BC_Title *title = 0;
BC_Title *title = 0;
- add_subwindow(title = new BC_Title(x, y, _("
Fraction of original speed
:")));
+ add_subwindow(title = new BC_Title(x, y, _("
Input samples
:")));
y += title->get_h() + plugin->get_theme()->widget_border;
y += title->get_h() + plugin->get_theme()->widget_border;
- scale = new TimeStretchRTScale(this,
- plugin,
- x,
- y);
- scale->create_objects();
-
- y += scale->get_h() + plugin->get_theme()->widget_border;
- add_subwindow(title = new BC_Title(x, y, _("Window size (ms):")));
+ num = new TimeStretchRTScale(this,
+ plugin,
+ x,
+ y,
+ &plugin->config.num);
+ num->create_objects();
+ y += num->get_h() + margin;
+
+ add_subwindow(title = new BC_Title(x, y, _("Output samples:")));
y += title->get_h() + plugin->get_theme()->widget_border;
y += title->get_h() + plugin->get_theme()->widget_border;
+ denom = new TimeStretchRTScale(this,
+ plugin,
+ x,
+ y,
+ &plugin->config.denom);
+ denom->create_objects();
+
+ y += denom->get_h() + margin;
+ add_subwindow(title = new BC_Title(x, y, _("Window size (ms):")));
+ y += title->get_h() + margin;
size = new TimeStretchRTSize(this,
plugin,
x,
size = new TimeStretchRTSize(this,
plugin,
x,
@@
-128,9
+151,10
@@
void TimeStretchRTWindow::create_objects()
TimeStretchRTScale::TimeStretchRTScale(TimeStretchRTWindow *window,
TimeStretchRT *plugin,
int x,
TimeStretchRTScale::TimeStretchRTScale(TimeStretchRTWindow *window,
TimeStretchRT *plugin,
int x,
- int y)
+ int y,
+ double *value)
: BC_TumbleTextBox(window,
: BC_TumbleTextBox(window,
- (float)
(1.0 / plugin->config.scale)
,
+ (float)
*value
,
(float)0.0001,
(float)1000,
x,
(float)0.0001,
(float)1000,
x,
@@
-138,12
+162,14
@@
TimeStretchRTScale::TimeStretchRTScale(TimeStretchRTWindow *window,
100)
{
this->plugin = plugin;
100)
{
this->plugin = plugin;
+ this->value = value;
set_increment(0.01);
}
int TimeStretchRTScale::handle_event()
{
set_increment(0.01);
}
int TimeStretchRTScale::handle_event()
{
- plugin->config.scale = 1.0 / atof(get_text());
+ *value = atof(get_text());
+ plugin->config.boundaries();
plugin->send_configure_change();
return 1;
}
plugin->send_configure_change();
return 1;
}
@@
-213,7
+239,7
@@
int TimeStretchRT::process_buffer(int64_t size,
{
need_reconfigure = load_configuration();
{
need_reconfigure = load_configuration();
- if(!engine) engine = new TimeStretchEngine(config.
scale,
+ if(!engine) engine = new TimeStretchEngine(config.
denom / config.num,
sample_rate,
config.size);
sample_rate,
config.size);
@@
-222,7
+248,6
@@
int TimeStretchRT::process_buffer(int64_t size,
// Get start position of the input.
// Sample 0 is the keyframe position
// Get start position of the input.
// Sample 0 is the keyframe position
-//printf("TimeStretchRT::process_buffer %d %f\n", __LINE__, config.scale);
if(need_reconfigure)
{
int64_t prev_position = edl_to_local(
if(need_reconfigure)
{
int64_t prev_position = edl_to_local(
@@
-234,15
+259,18
@@
int TimeStretchRT::process_buffer(int64_t size,
prev_position = get_source_start();
}
prev_position = get_source_start();
}
- source_start = (int64_t)((start_position - prev_position)
/
- config.
scale
) + prev_position;
+ source_start = (int64_t)((start_position - prev_position)
*
+ config.
num / config.denom
) + prev_position;
engine->reset();
engine->reset();
- engine->update(config.
scale
, sample_rate, config.size);
+ engine->update(config.
denom / config.num
, sample_rate, config.size);
need_reconfigure = 0;
need_reconfigure = 0;
-//printf("TimeStretchRT::process_buffer %d start_position=" _LD
-// " prev_position=%jd scale=%f source_start=%jd\n",
-// __LINE__, start_position, prev_position, config.scale, source_start);
+// printf("TimeStretchRT::process_buffer %d start_position=%lld prev_position=%lld scale=%f source_start=%lld\n",
+// __LINE__,
+// start_position,
+// prev_position,
+// config.scale,
+// source_start);
}
// process buffers until output length is reached
}
// process buffers until output length is reached
@@
-297,7
+325,8
@@
void TimeStretchRT::save_data(KeyFrame *keyframe)
// cause data to be stored directly in text
output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
output.tag.set_title("TIMESTRETCHRT");
// cause data to be stored directly in text
output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
output.tag.set_title("TIMESTRETCHRT");
- output.tag.set_property("SCALE", config.scale);
+ output.tag.set_property("NUM", config.num);
+ output.tag.set_property("DENOM", config.denom);
output.tag.set_property("SIZE", config.size);
output.append_tag();
output.tag.set_title("/TIMESTRETCHRT");
output.tag.set_property("SIZE", config.size);
output.append_tag();
output.tag.set_title("/TIMESTRETCHRT");
@@
-316,7
+345,8
@@
void TimeStretchRT::read_data(KeyFrame *keyframe)
{
if(input.tag.title_is("TIMESTRETCHRT"))
{
{
if(input.tag.title_is("TIMESTRETCHRT"))
{
- config.scale = input.tag.get_property("SCALE", config.scale);
+ config.num = input.tag.get_property("NUM", config.num);
+ config.denom = input.tag.get_property("DENOM", config.denom);
config.size = input.tag.get_property("SIZE", config.size);
}
}
config.size = input.tag.get_property("SIZE", config.size);
}
}
@@
-330,7
+360,8
@@
void TimeStretchRT::update_gui()
{
thread->window->lock_window("TimeStretchRT::update_gui");
{
thread->window->lock_window("TimeStretchRT::update_gui");
- ((TimeStretchRTWindow*)thread->window)->scale->update((float)(1.0 / config.scale));
+ ((TimeStretchRTWindow*)thread->window)->num->update((float)config.num);
+ ((TimeStretchRTWindow*)thread->window)->denom->update((float)config.denom);
((TimeStretchRTWindow*)thread->window)->size->update((int64_t)config.size);
thread->window->unlock_window();
}
((TimeStretchRTWindow*)thread->window)->size->update((int64_t)config.size);
thread->window->unlock_window();
}