Skip to content

Commit

Permalink
remove option for half buffer buffered mode
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Jan 15, 2025
1 parent 1937ede commit 6999ce8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 80 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Ratatouille using parallel processing for the neural models,
so, loading a second neural model wouldn't be remarkable on the dsp load.

Optional, Ratatouille could run the complete process in buffered mode. That reduce the dsp load
even more. Possible been a half (sample buffer) or a full frame. The resulting latency will be reported to the host
so that it could be compensated. For information the resulting latency will be shown on the GUI.
even more. The resulting latency will be reported to the hostso that it could be compensated.
For information the resulting latency will be shown on the GUI.

The "Delay" control could add a small delay to overcome phasing issues,
or to add some color/reverb to the sound.
Expand Down
3 changes: 1 addition & 2 deletions Ratatouille/Ratatouille.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {
asprintf(&ps->ir1.filepicker->filter ,"%s", ".wav");
ps->ir1.filepicker->use_filter = 1;

ui->widget[15] = add_lv2_slider (ui->widget[15], ui->win, 20, "Buffer", ui, 50, 22, 30, 30);
set_adjustment(ui->widget[15]->adj, 0.0, 0.0, 0.0, 1.0, 0.5, CL_CONTINUOS);
ui->widget[15] = add_lv2_switch (ui->widget[15], ui->win, 20, "Buffer", ui, 50, 22, 30, 30);

ui->widget[17] = add_lv2_label (ui->widget[17], ui->win, 22, "Latency", ui, 115, 22, 130, 30);

Expand Down
37 changes: 8 additions & 29 deletions Ratatouille/Ratatouille.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class Xratatouille
int phaseOffset;
bool doit;

uint32_t partialBuffer;

std::string model_file;
std::string model_file1;

Expand Down Expand Up @@ -371,7 +369,6 @@ void Xratatouille::init_dsp_(uint32_t rate)
ir_file1 = "None";
bufsize = 0;
buffersize = 0;
partialBuffer = 0;
phaseOffset = 0;
phase_cor = 0;

Expand Down Expand Up @@ -757,29 +754,11 @@ inline void Xratatouille::runBufferedDsp(uint32_t n_samples)
}

}
if ((*_buffered) < 0.9) {
memcpy(output0, bufferoutput0, partialBuffer*sizeof(float));

// set bufsize for the first part
bufsize = n_samples - partialBuffer;

// process first part buffer in this cycle and append to output
memcpy(bufferoutput0, input0, bufsize*sizeof(float));
processDsp(bufsize, bufferoutput0, bufferoutput0);
memcpy(&output0[partialBuffer], bufferoutput0, bufsize*sizeof(float));

// process second part buffer in background, use in next cycle
// buffered size may have changed, so recalculate it
partialBuffer = n_samples * (*_buffered);
bufsize = n_samples - partialBuffer;
memcpy(bufferoutput0, &input0[bufsize], partialBuffer*sizeof(float));
// set bufsize for the second part processed in background
bufsize = partialBuffer;
} else {
partialBuffer = bufsize = n_samples;
memcpy(output0, bufferoutput0, bufsize*sizeof(float));
memcpy(bufferoutput0, input0, bufsize*sizeof(float));
}

bufsize = n_samples;
memcpy(output0, bufferoutput0, bufsize*sizeof(float));
memcpy(bufferoutput0, input0, bufsize*sizeof(float));

if (par.getProcess()) par.runProcess();
else {
lv2_log_error(&logger,"thread RTBUF missing deadline\n");
Expand All @@ -794,9 +773,9 @@ inline void Xratatouille::runBufferedDsp(uint32_t n_samples)
}

// report latency
if (*(_latency) != static_cast<float>(partialBuffer)) {
*(_latency) = static_cast<float>(partialBuffer);
*(_latencyms) = static_cast<float>(partialBuffer * s_time);
if (*(_latency) != static_cast<float>(bufsize)) {
*(_latency) = static_cast<float>(bufsize);
*(_latencyms) = static_cast<float>(bufsize * s_time);
}

} else {
Expand Down
3 changes: 1 addition & 2 deletions Ratatouille/Ratatouille.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,12 @@ and moves the complete processing into a background thread, that reduce the CPU
a lv2:InputPort ,
lv2:ControlPort ;
lv2:index 20 ;

lv2:portProperty lv2:toggled ;
lv2:symbol "buffered" ;
lv2:name "Buffered" ;
lv2:default 0.0 ;
lv2:minimum 0.0 ;
lv2:maximum 1.0 ;
pprop:rangeSteps 3;
], [
a lv2:InputPort ,
lv2:ControlPort ;
Expand Down
8 changes: 4 additions & 4 deletions Ratatouille/mod/modgui/icon-ratatouille.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div class="mod-pedal mod-pedal-ratatouille{{{cns}}} ">
<div mod-role="drag-handle" class="mod-drag-handle"></div>
{{#controls.14}}
<div class="mod-bufferswitch" title="{{name}}">
<div class="mod-bufferswitch-image" mod-role="input-control-port" mod-port-symbol="{{symbol}}" mod-widget="film"></div>
<div class="mod-switch" title="{{name}}">
<div class="mod-switch-image" mod-role="input-control-port" mod-port-symbol="{{symbol}}" mod-widget="switch"></div>
<span class="mod-switch-title">{{name}}</span>
</div>
{{/controls.14}}
{{#controls.15}}
<div class="mod-phaseswitch" title="{{name}}">
<div class="mod-phaseswitch-image" mod-role="input-control-port" mod-port-symbol="{{symbol}}" mod-widget="switch"></div>
<div class="mod-switch" title="{{name}}">
<div class="mod-switch-image" mod-role="input-control-port" mod-port-symbol="{{symbol}}" mod-widget="switch"></div>
<span class="mod-switch-title">{{name}}</span>
</div>
{{/controls.15}}
Expand Down
47 changes: 6 additions & 41 deletions Ratatouille/mod/modgui/stylesheet-ratatouille.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,41 +55,6 @@
background-position: 0px 0px;
}

/* BUFFER SWITCH ON/OFF
================================================*/
.mod-pedal-ratatouille{{{cns}}} .mod-bufferswitch {
margin-left: 45px ;
margin-top: 12px ;
cursor: pointer;
float: left;
position: absolute;
height: 32px;
width: 30px;
z-index:40;
}

.mod-pedal-ratatouille{{{cns}}} .mod-bufferswitch-image {
background-image: url(/resources/switches/switch3.png{{{ns}}});
background-position: 0px 0px;
background-repeat: no-repeat;
background-size: auto 15px;
height: 15px;
width: 30px;
}

.mod-pedal-ratatouille{{{cns}}} .mod-bufferswitch .mod-switch-title {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 10px;
font-weight: bold;
left: 0;
color:#888;
position: absolute;
right: 0;
margin-top: 17px;
top: 0;
z-index: 1;
}

/* LATENCY REPORT
================================================*/
.mod-pedal-ratatouille{{{cns}}} .buffertext {
Expand All @@ -105,9 +70,9 @@
z-index: 1;
}

/* PHASE SWITCH ON/OFF
/* EFFECT SWITCH ON/OFF
================================================*/
.mod-pedal-ratatouille{{{cns}}} .mod-phaseswitch {
.mod-pedal-ratatouille{{{cns}}} .mod-switch {
margin-left: 95px ;
margin-top: 12px ;
cursor: pointer;
Expand All @@ -118,7 +83,7 @@
z-index:40;
}

.mod-pedal-ratatouille{{{cns}}} .mod-phaseswitch-image {
.mod-pedal-ratatouille{{{cns}}} .mod-switch-image {
background-image: url(/resources/switches/powerswitch.png{{{ns}}});
background-position: 0px 0px;
background-repeat: no-repeat;
Expand All @@ -127,15 +92,15 @@
width: 30px;
}

.mod-pedal-ratatouille{{{cns}}} .mod-phaseswitch-image.on {
.mod-pedal-ratatouille{{{cns}}} .mod-switch-image.on {
background-position: -30px 0px;
}

.mod-pedal-ratatouille{{{cns}}} .mod-phaseswitch-image.off {
.mod-pedal-ratatouille{{{cns}}} .mod-switch-image.off {
background-position: 0px 0px;
}

.mod-pedal-ratatouille{{{cns}}} .mod-phaseswitch .mod-switch-title {
.mod-pedal-ratatouille{{{cns}}} .mod-switch .mod-switch-title {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 10px;
font-weight: bold;
Expand Down

0 comments on commit 6999ce8

Please sign in to comment.