Skip to content

Commit cfde8ae

Browse files
committed
Mono samples are now played as stereo samples with duplicated left channel.
1 parent 8c2979f commit cfde8ae

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

CHANGELOG

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

55
=== 1.0.23 ===
6+
* Mono samples are now played as stereo samples with duplicated left channel.
67
* Updated build scripts and dependencies.
78

89
=== 1.0.22 ===

include/private/plugins/trigger_kernel.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2021 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2021 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-plugins-trigger
66
* Created on: 31 июл. 2021 г.
@@ -93,7 +93,7 @@ namespace lsp
9393
protected:
9494
struct afile_t
9595
{
96-
size_t nID; // ID of sample
96+
uint32_t nID; // ID of sample
9797
AFLoader *pLoader; // Audio file loader task
9898
AFRenderer *pRenderer; // Audio file renderer task
9999
dspu::Toggle sListen; // Listen toggle
@@ -102,8 +102,8 @@ namespace lsp
102102
dspu::Sample *pProcessed; // Processed sample
103103
float *vThumbs[meta::trigger_metadata::TRACKS_MAX]; // List of thumbnails
104104

105-
size_t nUpdateReq; // Update request
106-
size_t nUpdateResp; // Update response
105+
uint32_t nUpdateReq; // Update request
106+
uint32_t nUpdateResp; // Update response
107107
bool bSync; // Sync flag
108108
float fVelocity; // Velocity
109109
float fPitch; // Pitch (st)

src/main/plug/trigger_kernel.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2021 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2021 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-plugins-trigger
66
* Created on: 31 июл. 2021 г.
@@ -614,7 +614,7 @@ namespace lsp
614614
lsp_trace("load failed: status=%d (%s)", status, get_status(status));
615615
return status;
616616
}
617-
size_t channels = lsp_min(nChannels, source->channels());
617+
const size_t channels = lsp_min(nChannels, source->channels());
618618
if (!source->set_channels(channels))
619619
{
620620
lsp_trace("failed to resize source sample to %d channels", int(channels));
@@ -738,6 +738,11 @@ namespace lsp
738738
{
739739
lsp_trace("id=%d, gain=%f, delay=%d", int(af->nID), gain, int(delay));
740740

741+
// Obtain the sample that will be used for playback
742+
dspu::Sample *s = vChannels[0].get(af->nID);
743+
if (s == NULL)
744+
return;
745+
741746
// Scale the final output gain
742747
gain *= af->fMakeup;
743748

@@ -751,18 +756,22 @@ namespace lsp
751756
for (size_t i=0; i<nChannels; ++i)
752757
{
753758
size_t j=i^1; // j = (i + 1) % 2
759+
const size_t channel = i % s->channels();
760+
754761
lsp_trace("channels[%d].play(%d, %d, %f, %d)", int(i), int(af->nID), int(i), gain * af->fGains[i], int(delay));
755-
vChannels[i].play(af->nID, i, gain * af->fGains[i], delay);
762+
vChannels[i].play(af->nID, channel, gain * af->fGains[i], delay);
756763
lsp_trace("channels[%d].play(%d, %d, %f, %d)", int(j), int(i), int(af->nID), gain * (1.0f - af->fGains[i]), int(delay));
757-
vChannels[j].play(af->nID, i, gain * (1.0f - af->fGains[i]), delay);
764+
vChannels[j].play(af->nID, channel, gain * (1.0f - af->fGains[i]), delay);
758765
}
759766
}
760767
else
761768
{
762769
for (size_t i=0; i<nChannels; ++i)
763770
{
771+
const size_t channel = i % s->channels();
772+
764773
lsp_trace("channels[%d].play(%d, %d, %f, %d)", int(i), int(af->nID), int(i), gain * af->fGains[i], int(delay));
765-
vChannels[i].play(af->nID, i, gain * af->fGains[i], delay);
774+
vChannels[i].play(af->nID, channel, gain * af->fGains[i], delay);
766775
}
767776
}
768777
}
@@ -1017,7 +1026,7 @@ namespace lsp
10171026
if (af->sListen.pending())
10181027
{
10191028
// Play sample
1020-
play_sample(af, 0.5f, 0); // Listen at mid-velocity
1029+
play_sample(af, 1.0f, 0);
10211030

10221031
// Update states
10231032
af->sListen.commit();
@@ -1078,7 +1087,7 @@ namespace lsp
10781087

10791088
// Store file thumbnails to mesh
10801089
plug::mesh_t *mesh = reinterpret_cast<plug::mesh_t *>(af->pMesh->buffer());
1081-
if ((mesh == NULL) || (!mesh->isEmpty()) || (!af->bSync) || (!af->pLoader->idle()))
1090+
if ((mesh == NULL) || (!mesh->isEmpty()) || (!af->bSync) || (!af->pLoader->idle()) || (!af->pRenderer->idle()))
10821091
continue;
10831092

10841093
if ((channels > 0) && (af->vThumbs[0] != NULL))

0 commit comments

Comments
 (0)