Skip to content

Commit 12a3129

Browse files
committed
Added listen button that allows to feed audio sample preview to direct outputs
1 parent bab8ac9 commit 12a3129

6 files changed

Lines changed: 38 additions & 11 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*******************************************************************************
44

55
=== 1.0.33 ===
6+
* Added listen button that allows to feed audio sample preview to direct outputs.
67
* Offline tasks are optimized for better floating-point computing.
78

89
=== 1.0.32 ===

include/private/plugins/sampler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ namespace lsp
4747
enum dm_mode_t
4848
{
4949
DM_APPLY_GAIN = 1 << 0,
50-
DM_APPLY_PAN = 1 << 1
50+
DM_APPLY_PAN = 1 << 1,
51+
DM_APPLY_LISTEN = 1 << 2
5152
};
5253

5354
typedef struct sampler_channel_t
@@ -129,6 +130,7 @@ namespace lsp
129130
plug::IPort *pInstSel; // Instrument selector
130131
plug::IPort *pDOGain; // Direct output gain flag
131132
plug::IPort *pDOPan; // Direct output panning flag
133+
plug::IPort *pDOListen; // Direct output listen flag
132134

133135
protected:
134136
void process_trigger_events();

res/main/ui/sampling/multiple.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<label text="labels.direct_output_" pad.l="12"/>
1616
<button text="labels.gain" id="do_gain" ui:inject="Button_magenta"/>
1717
<button text="labels.panning" id="do_pan" ui:inject="Button_yellow"/>
18+
<button text="labels.listen" id="do_lstn" ui:inject="Button_green"/>
1819
</ui:if>
1920
<void hexpand="true"/>
2021
</hbox>

src/doc/manuals/plugins/multisampler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@
9797
<ul>
9898
<li><b>Bypass</b> - hot bypass switch, when turned on (led indicator is shining), the plugin does not affect the input signal.</li>
9999
<li><b>Workspace</b> - combo box that allows to switch between instrument setup and instrument mixer.</li>
100+
<?php if ($do) { ?>
101+
<li><b>Direct output</b> - set of buttons that allow to control the behaviour of all direct outputs:</li>
102+
<ul>
103+
<li><b>Gain</b> - the loudness of the instrument is also applied to direct output signal.</li>
104+
<li><b>Panning</b> - the panning of the instrument is also applied to direct output signal.</li>
105+
<li><b>Listen</b> - the sound of sample preview is also fed to direct output.</li>
106+
</ul>
107+
<?php } ?>
100108
</ul>
101109

102110
<p><b>'Instrument mixer' section:</b></p>

src/main/meta/sampler.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ namespace lsp
3939
{
4040
namespace meta
4141
{
42+
// Lisf of different revisions for adding controls
43+
#define REV_0 0
44+
#define REV_1 1
45+
4246
//-------------------------------------------------------------------------
4347
// Sampler
4448
static const port_item_t sampler_sample_selectors[] =
@@ -238,7 +242,8 @@ namespace lsp
238242

239243
#define S_DO_CONTROL \
240244
SWITCH("do_gain", "Apply gain to direct-out", "DOut gain on", 1.0f), \
241-
SWITCH("do_pan", "Apply panning to direct-out", "DOut pan on", 1.0f)
245+
SWITCH("do_pan", "Apply panning to direct-out", "DOut pan on", 1.0f), \
246+
ADDON_SWITCH(REV_1, "do_lstn", "Pass listen events to direct-out", "DOut listen on", 0.0f)
242247

243248
#define S_SAMPLE_FILE(gain) \
244249
PATH("sf", "Sample file"), \

src/main/plug/sampler.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ namespace lsp
122122
pInstSel = NULL;
123123
pDOGain = NULL;
124124
pDOPan = NULL;
125+
pDOListen = NULL;
125126
}
126127

127128
sampler::~sampler()
@@ -243,6 +244,7 @@ namespace lsp
243244
{
244245
BIND_PORT(pDOGain);
245246
BIND_PORT(pDOPan);
247+
BIND_PORT(pDOListen);
246248
}
247249

248250
// If number of samplers <= 2 - skip area selector
@@ -421,6 +423,8 @@ namespace lsp
421423
nDOMode |= DM_APPLY_GAIN;
422424
if ((pDOPan != NULL) && (pDOPan->value() >= 0.5f))
423425
nDOMode |= DM_APPLY_PAN;
426+
if ((pDOListen != NULL) && (pDOListen->value() >= 0.5f))
427+
nDOMode |= DM_APPLY_LISTEN;
424428

425429
lsp_trace("muting=%s", (bMuting) ? "true" : "false");
426430
lsp_trace("note_off=%s", (note_off) ? "true" : "false");
@@ -697,27 +701,33 @@ namespace lsp
697701
// Now post-process all channels for sampler
698702
for (size_t j=0; j<nChannels; ++j)
699703
{
700-
sampler_channel_t *c = &s->vChannels[j];
704+
sampler_channel_t * const c1 = &s->vChannels[j];
705+
sampler_channel_t * const c2 = &s->vChannels[j ^ 1];
701706

702707
// Copy data to direct output buffer if present
703708
float gain = (nDOMode & DM_APPLY_GAIN) ? s->fGain : 1.0f;
704-
float pan = (nDOMode & DM_APPLY_PAN) ? c->fPan : 1.0f;
705-
if (s->vChannels[j].vDry != NULL)
706-
dsp::fmadd_k3(s->vChannels[j].vDry, tmp_outs[j], pan * gain, count);
707-
if (s->vChannels[j^1].vDry != NULL)
708-
dsp::fmadd_k3(s->vChannels[j^1].vDry, tmp_outs[j], (1.0f - pan) * gain, count);
709+
float pan = (nDOMode & DM_APPLY_PAN) ? c1->fPan : 1.0f;
710+
711+
if (c1->vDry != NULL)
712+
{
713+
dsp::fmadd_k3(c1->vDry, tmp_outs[j], pan * gain, count);
714+
if (nDOMode & DM_APPLY_LISTEN)
715+
dsp::add2(c1->vDry, tmp_listen[j], count);
716+
}
717+
if (c2->vDry != NULL)
718+
dsp::fmadd_k3(c2->vDry, tmp_outs[j], (1.0f - pan) * gain, count);
709719

710720
// Process output
711-
c->sBypass.process(tmp_outs[j], NULL, tmp_outs[j], count);
721+
c1->sBypass.process(tmp_outs[j], NULL, tmp_outs[j], count);
712722
dsp::add2(tmp_outs[j], tmp_listen[j], count);
713723

714724
// Mix output to common sampler's bus
715725
if (vChannels[j].vOut != NULL)
716-
dsp::fmadd_k3(vChannels[j].vOut, tmp_outs[j], c->fPan * s->fGain, count);
726+
dsp::fmadd_k3(vChannels[j].vOut, tmp_outs[j], c1->fPan * s->fGain, count);
717727

718728
// Apply pan to the other stereo channel (if present)
719729
if (vChannels[j^1].vOut != NULL)
720-
dsp::fmadd_k3(vChannels[j^1].vOut, tmp_outs[j], (1.0f - c->fPan) * s->fGain, count);
730+
dsp::fmadd_k3(vChannels[j^1].vOut, tmp_outs[j], (1.0f - c1->fPan) * s->fGain, count);
721731
}
722732

723733
// Post-process dry channels

0 commit comments

Comments
 (0)