mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-20 18:18:32 +00:00
Merge pull request #762 from tidalcycles/fix-addivite-synthesis-phases
Fix addivite synthesis phases
This commit is contained in:
commit
1c7c82358d
@ -73,13 +73,13 @@ export function waveformN(partials, type) {
|
|||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
const osc = ac.createOscillator();
|
const osc = ac.createOscillator();
|
||||||
|
|
||||||
const amplitudes = {
|
const terms = {
|
||||||
sawtooth: (n) => 1 / n,
|
sawtooth: (n) => [0, -1 / n],
|
||||||
square: (n) => (n % 2 === 0 ? 0 : 1 / n),
|
square: (n) => [0, n % 2 === 0 ? 0 : 1 / n],
|
||||||
triangle: (n) => (n % 2 === 0 ? 0 : 1 / (n * n)),
|
triangle: (n) => [n % 2 === 0 ? 0 : 1 / (n * n), 0],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!amplitudes[type]) {
|
if (!terms[type]) {
|
||||||
throw new Error(`unknown wave type ${type}`);
|
throw new Error(`unknown wave type ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +87,9 @@ export function waveformN(partials, type) {
|
|||||||
imag[0] = 0;
|
imag[0] = 0;
|
||||||
let n = 1;
|
let n = 1;
|
||||||
while (n <= partials) {
|
while (n <= partials) {
|
||||||
real[n] = amplitudes[type](n);
|
const [r, i] = terms[type](n);
|
||||||
imag[n] = 0;
|
real[n] = r;
|
||||||
|
imag[n] = i;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export function drawTimeScope(
|
|||||||
|
|
||||||
for (let i = triggerIndex; i < bufferSize; i++) {
|
for (let i = triggerIndex; i < bufferSize; i++) {
|
||||||
const v = dataArray[i] + 1;
|
const v = dataArray[i] + 1;
|
||||||
const y = (scale * (v - 1) + pos) * canvas.height;
|
const y = (1 - (scale * (v - 1) + pos)) * canvas.height;
|
||||||
|
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
ctx.moveTo(x, y);
|
ctx.moveTo(x, y);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user