Skip to content

Commit

Permalink
Drum tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jonikorpi committed Dec 19, 2024
1 parent 309e27a commit d7a34d6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
32 changes: 20 additions & 12 deletions instrumentPresets.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,35 +894,41 @@ export const taikoDrum = {
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
...Float32Array.of(1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.618), // 2.1 (~2.11), 2.9 (~2.92)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.236, 0.0, 0.0, 0.0), // 3.7 (~3.75)
...Float32Array.of(0.0, 0.0, 0.0, 0.146, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), // 4.4 (~4.40)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.09, 0.0, 0.0, 0.0, 0.0), // 5.6 (~5.57)
...Float32Array.of(0.0, 0.0, 0.0, 0.09, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), // 4.4 (~4.40)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.056, 0.0, 0.0, 0.0, 0.0), // 5.6 (~5.57)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.056, 0.0, 0.0, 0.0, 0.0), // 7.6 (~7.6)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.034, 0.0, 0.0, 0.0, 0.0, 0.0), // 8.5
...Float32Array.of(0.0, 0.0, 0.021, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), // 9.3 (~9.3)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.034, 0.0, 0.0, 0.0, 0.0), // 7.6 (~7.6)
...Float32Array.of(0.0, 0.0, 0.0, 0.0, 0.021, 0.0, 0.0, 0.0, 0.0, 0.0), // 8.5
...Float32Array.of(0.0, 0.0, 0.013, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), // 9.3 (~9.3)
),
},
getPitch: (pitch) => pitch / 10.0 / 8.0,
getPitch: (pitch) => pitch / 10.0,
gain: 1.0,
},
{
type: "custom",
periodicWave: getNoise(),
getPitch: () => 11.0,
gain: 2.0,
periodicWave: getNoise(
(value, index) => (value * Math.min(1.0, Math.max(0.0, index - 8.0))) / Math.max(1.0, index - 8.0),
),
getPitch: () => 11.0 + 3.0 * Math.random(),
gain: 1.0,
attack: 0.008,
decay: 0.056,
decay: 0.034,
durationImpactOnDecay: 0.005,
},
],
decayImpactOnDuration: 1.0,
durationImpactOnDecay: 0.382,
durationImpactOnDecay: 0.333333,

attack: 0.013,
filterAttack: 0.013,
decay: 0.382,
filterDecay: 0.618,
sustain: 0.0,
release: 0.0,

highPassFrequency: 22.0,
lowPassFrequency: 2200.0,
};

/** @param {Instrument} instrument */
Expand All @@ -948,7 +954,9 @@ export const timpani = {
},
{
...taikoDrum.oscillators[1],
periodicWave: getNoise(),
periodicWave: getNoise(
(value, index) => (value * Math.min(1.0, Math.max(0.0, index - 12.0))) / Math.max(1.0, index - 12.0),
),
},
],
};
Expand Down
22 changes: 21 additions & 1 deletion noise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Coefficients from https://github.com/looshi/wavetable-synth-2
export const getNoise = (
shaper = (/** @type {number} */ value, /** @type {number} */ index, /** @type {Float32Array} */ _array) =>
value / Math.max(1.0, index ** Math.SQRT2),
value / Math.max(1.0, Math.sqrt(index)),
) => {
const real0 = 51.22724533081055;
const imag0 = 0;
Expand Down Expand Up @@ -44,6 +44,16 @@ export const getNoise = (
...real,
...real,
...real,
...real,
...real,
...real,
...real,
...real,
...real,
...real,
...real,
...real,
...real,
).map(shaper),
imag: Float32Array.of(
imag0,
Expand All @@ -57,6 +67,16 @@ export const getNoise = (
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
...imag,
).map(shaper),
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuoro/pelimanni",
"version": "0.9.17",
"version": "0.9.18",
"type": "module",
"main": "./instruments.js",
"exports": {
Expand Down

0 comments on commit d7a34d6

Please sign in to comment.