diff --git a/CHANGELOG b/CHANGELOG
index d6ca1dd..840efd6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,7 +3,7 @@
*******************************************************************************
=== 1.0.24 ===
-
+* Added Stop button for stopping audio file preview.
=== 1.0.23 ===
* Updated build scripts and dependencies.
diff --git a/include/private/plugins/impulse_reverb.h b/include/private/plugins/impulse_reverb.h
index bc895ea..6dd4d6d 100644
--- a/include/private/plugins/impulse_reverb.h
+++ b/include/private/plugins/impulse_reverb.h
@@ -98,6 +98,7 @@ namespace lsp
typedef struct af_descriptor_t
{
dspu::Toggle sListen; // Listen toggle
+ dspu::Toggle sStop; // Stop toggle
dspu::Sample *pOriginal; // Original audio file
dspu::Sample *pProcessed; // Processed audio file for sampler
float *vThumbs[meta::impulse_reverb_metadata::TRACKS_MAX]; // Thumbnails
@@ -120,6 +121,7 @@ namespace lsp
plug::IPort *pFadeIn;
plug::IPort *pFadeOut;
plug::IPort *pListen;
+ plug::IPort *pStop;
plug::IPort *pReverse; // Reverse
plug::IPort *pStatus; // Status of file loading
plug::IPort *pLength; // Length of file
@@ -155,6 +157,7 @@ namespace lsp
dspu::Bypass sBypass;
dspu::SamplePlayer sPlayer;
dspu::Equalizer sEqualizer; // Wet signal equalizer
+ dspu::Playback vPlaybacks[meta::impulse_reverb_metadata::FILES]; // Playbacks
float *vOut;
float *vBuffer; // Rendering buffer
diff --git a/res/main/ui/convolution/impulse_reverb/mono.xml b/res/main/ui/convolution/impulse_reverb/mono.xml
index 85d2937..a986205 100644
--- a/res/main/ui/convolution/impulse_reverb/mono.xml
+++ b/res/main/ui/convolution/impulse_reverb/mono.xml
@@ -117,7 +117,14 @@
- |
+
+
+
+
+
+
+
+ |
diff --git a/res/main/ui/convolution/impulse_reverb/stereo.xml b/res/main/ui/convolution/impulse_reverb/stereo.xml
index cfddef5..a36ff9a 100644
--- a/res/main/ui/convolution/impulse_reverb/stereo.xml
+++ b/res/main/ui/convolution/impulse_reverb/stereo.xml
@@ -125,7 +125,14 @@
- |
+
+
+
+
+
+
+
+ |
diff --git a/src/doc/manuals/plugins/impulse_reverb.php b/src/doc/manuals/plugins/impulse_reverb.php
index cfbea18..c2c5de0 100644
--- a/src/doc/manuals/plugins/impulse_reverb.php
+++ b/src/doc/manuals/plugins/impulse_reverb.php
@@ -55,7 +55,8 @@
Tail cut - cut amount of milliseconds from the end of the impulse files, can be used to remove large reverberation tail.
Fade in - adds additional fading at the beginning of the impulse file.
Fade out - adds additional fading at the end of the impulse file.
- Listen - this button allows to listen contents of the audio file.
+ Listen - this button allows to listen preview of the audio file.
+ Stop - this button allows to stop preview of the audio file.
'Processors' section:
diff --git a/src/main/meta/impulse_reverb.cpp b/src/main/meta/impulse_reverb.cpp
index 261ab82..9b676b0 100644
--- a/src/main/meta/impulse_reverb.cpp
+++ b/src/main/meta/impulse_reverb.cpp
@@ -121,7 +121,8 @@ namespace lsp
CONTROL("itc" id, "Tail cut" label, U_MSEC, impulse_reverb_metadata::CONV_LENGTH), \
CONTROL("ifi" id, "Fade in" label, U_MSEC, impulse_reverb_metadata::CONV_LENGTH), \
CONTROL("ifo" id, "Fade out" label, U_MSEC, impulse_reverb_metadata::CONV_LENGTH), \
- TRIGGER("ils" id, "Impulse listen" label), \
+ TRIGGER("ils" id, "Impulse listen preview" label), \
+ TRIGGER("ilc" id, "Impulse stop preview" label), \
SWITCH("irv" id, "Impulse reverse" label, 0.0f), \
STATUS("ifs" id, "Load status" label), \
METER("ifl" id, "Impulse length" label, U_MSEC, impulse_reverb_metadata::CONV_LENGTH), \
diff --git a/src/main/plug/impulse_reverb.cpp b/src/main/plug/impulse_reverb.cpp
index d6c4fb4..31b418d 100644
--- a/src/main/plug/impulse_reverb.cpp
+++ b/src/main/plug/impulse_reverb.cpp
@@ -227,6 +227,7 @@ namespace lsp
af->pFadeIn = NULL;
af->pFadeOut = NULL;
af->pListen = NULL;
+ af->pStop = NULL;
af->pReverse = NULL;
af->pStatus = NULL;
af->pLength = NULL;
@@ -289,6 +290,9 @@ namespace lsp
destroy_samples(gc_list);
c->sEqualizer.destroy();
+ for (size_t i=0; ivPlaybacks[i].destroy();
+
c->vOut = NULL;
c->vBuffer = NULL;
}
@@ -370,6 +374,7 @@ namespace lsp
af_descriptor_t *f = &vFiles[i];
f->sListen.init();
+ f->sStop.init();
f->pOriginal = NULL;
f->pProcessed = NULL;
@@ -399,6 +404,7 @@ namespace lsp
f->pFadeIn = NULL;
f->pFadeOut = NULL;
f->pListen = NULL;
+ f->pStop = NULL;
f->pReverse = NULL;
f->pStatus = NULL;
f->pLength = NULL;
@@ -499,6 +505,7 @@ namespace lsp
BIND_PORT(f->pFadeIn);
BIND_PORT(f->pFadeOut);
BIND_PORT(f->pListen);
+ BIND_PORT(f->pStop);
BIND_PORT(f->pReverse);
BIND_PORT(f->pStatus);
BIND_PORT(f->pLength);
@@ -748,6 +755,8 @@ namespace lsp
// Listen button pressed?
if (f->pListen != NULL)
f->sListen.submit(f->pListen->value());
+ if (f->pStop != NULL)
+ f->sStop.submit(f->pStop->value());
}
}
@@ -879,22 +888,44 @@ namespace lsp
void impulse_reverb::process_listen_events()
{
+ const size_t fadeout = dspu::millis_to_samples(fSampleRate, 5.0f);
+ dspu::PlaySettings ps;
+
for (size_t i=0; isListen.pending())
- continue;
+ // Need to start audio preview playback?
+ if (f->sListen.pending())
+ {
+ lsp_trace("Submitted listen toggle");
+ dspu::Sample *s = vChannels[0].sPlayer.get(i);
+ const size_t n_c = (s != NULL) ? s->channels() : 0;
+ if (n_c > 0)
+ {
+ for (size_t j=0; j<2; ++j)
+ {
+ channel_t *c = &vChannels[j];
+ ps.set_channel(i, j % n_c);
+ ps.set_playback(0, 0, GAIN_AMP_0_DB);
- lsp_trace("Submitted listen toggle");
- dspu::Sample *s = vChannels[0].sPlayer.get(i);
- size_t n_c = (s != NULL) ? s->channels() : 0;
- if (n_c > 0)
+ c->vPlaybacks[i].cancel(fadeout, 0);
+ c->vPlaybacks[i] = c->sPlayer.play(&ps);
+ }
+ }
+ f->sListen.commit();
+ }
+
+ // Need to cancel audio preview playback?
+ if (f->sStop.pending())
{
for (size_t j=0; j<2; ++j)
- vChannels[j].sPlayer.play(i, j%n_c, 1.0f, 0);
+ {
+ channel_t *c = &vChannels[j];
+ c->vPlaybacks[i].cancel(fadeout, 0);
+ }
+ f->sStop.commit();
}
- f->sListen.commit();
}
}
@@ -1240,6 +1271,7 @@ namespace lsp
v->write_object("sBypass", &c->sBypass);
v->write_object("sPlayer", &c->sPlayer);
v->write_object("sEqualizer", &c->sEqualizer);
+ v->write_object_array("vPlaybacks", c->vPlaybacks, meta::impulse_reverb_metadata::FILES);
v->write("vOut", c->vOut);
v->write("vBuffer", c->vBuffer);
@@ -1296,6 +1328,7 @@ namespace lsp
v->begin_object(af, sizeof(af_descriptor_t));
{
v->write_object("sListen", &af->sListen);
+ v->write_object("sStop", &af->sStop);
v->write_object("pOriginal", af->pOriginal);
v->write_object("pProcessed", af->pProcessed);
@@ -1320,6 +1353,7 @@ namespace lsp
v->write("pFadeIn", af->pFadeIn);
v->write("pFadeOut", af->pFadeOut);
v->write("pListen", af->pListen);
+ v->write("pStop", af->pStop);
v->write("pReverse", af->pReverse);
v->write("pStatus", af->pStatus);
v->write("pLength", af->pLength);