Skip to content

Commit

Permalink
add support for loop mode release and fix selector menu
Browse files Browse the repository at this point in the history
  • Loading branch information
spessasus committed Oct 6, 2024
1 parent 1a7a410 commit 0d769f6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SpessaSynth",
"version": "3.20.40",
"version": "3.20.41",
"type": "module",
"scripts": {
"start": "node src/website/server/server.js"
Expand Down
14 changes: 7 additions & 7 deletions src/spessasynth_lib/synthetizer/worklet_processor.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export function getSampleLinear(voice, outputBuffer)
}
else
{
if(sample.loopingMode === 2 && !voice.isInRelease)
{
return;
}
for (let i = 0; i < outputBuffer.length; i++)
{

Expand Down Expand Up @@ -119,6 +123,10 @@ export function getSampleNearest(voice, outputBuffer)
}
else
{
if(sample.loopingMode === 2 && !voice.isInRelease)
{
return;
}
for (let i = 0; i < outputBuffer.length; i++)
{

Expand Down Expand Up @@ -198,6 +206,10 @@ export function getSampleCubic(voice, outputBuffer)
}
else
{
if(sample.loopingMode === 2 && !voice.isInRelease)
{
return;
}
for (let i = 0; i < outputBuffer.length; i++)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ class WorkletSample
* Looping mode of the sample:
* 0 - no loop
* 1 - loop
* 2 - loop then play when released
* @type {0|1|2}
* 2 - UNOFFICIAL: polyphone 2.4 added start on release
* 3 - loop then play when released
* @type {0|1|2|3}
*/
loopingMode = 0;

Expand Down Expand Up @@ -372,15 +373,6 @@ export function getWorkletVoices(channel,
let loopStart = (sampleAndGenerators.sample.sampleLoopStartIndex / 2);
let loopEnd = (sampleAndGenerators.sample.sampleLoopEndIndex / 2);
let loopingMode = generators[generatorTypes.sampleModes];
const sampleLength = sampleAndGenerators.sample.getAudioData().length;
// clamp loop
loopStart = Math.min(Math.max(0, loopStart), sampleLength);
// clamp loop
loopEnd = Math.min(Math.max(0, loopEnd), sampleLength);
if (loopEnd - loopStart < 1)
{
loopingMode = 0;
}
/**
* create the worklet sample
* offsets are calculated at note on time (to allow for modulation of them)
Expand Down
20 changes: 12 additions & 8 deletions src/website/js/synthesizer_ui/methods/synthui_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,16 @@ export class Selector
if(program !== lastProgram)
{
lastProgram = program;
// create the header
const headerRow = document.createElement("tr");
const header = document.createElement("th");
header.colSpan = "3";
header.textContent = midiPatchNames[lastProgram];
headerRow.appendChild(header);
table.appendChild(headerRow);
// create the header (not for drums
if(preset.bank !== 128)
{
const headerRow = document.createElement("tr");
const header = document.createElement("th");
header.colSpan = "3";
header.textContent = midiPatchNames[lastProgram];
headerRow.appendChild(header);
table.appendChild(headerRow);
}
}
const programText = `${preset.program.toString().padStart(3, "0")}`;
const bankText = `${preset.bank.toString().padStart(3, "0")}`;
Expand Down Expand Up @@ -270,8 +273,9 @@ export class Selector
this.isReloaded = false;
return;
}
this.mainButton.innerHTML = "";
this.isReloaded = true;
if(this.elements.length > 0)
this.mainButton.textContent = this.getString(`${this.elements[0].bank}:${this.value.split(":")[1]}`);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/website/minified/demo_main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/website/minified/local_main.min.js

Large diffs are not rendered by default.

0 comments on commit 0d769f6

Please sign in to comment.