diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 7971f1ed9..8f733c321 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -2582,13 +2582,17 @@ export const { compressorRelease } = registerControl('compressorRelease'); export const { speed } = registerControl('speed'); /** - * Changes the speed of sample playback, i.e. a cheap way of changing pitch. + * Changes the pitch of the sample without changing its speed. + * The frequencies are multiplied by (factor + 1) for positive numbers + * and by max(factor / 4 + 1, 0) for negative numbers. + * So tuning up by octaves can be done with 1, 3, 7, ... + * and tuning down by octaves with -2, -3, -3.5... * * @name stretch * @tags pitch, samples - * @param {number | Pattern} factor -inf to inf, negative numbers play the sample backwards. + * @param {number | Pattern} factor between `-4` and `inf`. Positive increases pitch, 0 does nothing, negative decreases the pitch. * @example - * s("gm_flute").stretch("1 2 .5") + * s("gm_flute").stretch("<2 1 0 -2>") * */ export const { stretch } = registerControl('stretch'); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 458904baf..7ea844a16 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -12404,18 +12404,10 @@ exports[`runs examples > example "stepcat" example index 1 1`] = ` exports[`runs examples > example "stretch" example index 0 1`] = ` [ - "[ (0/1 → 1/3) ⇝ 1/1 | s:gm_flute stretch:1 ]", - "[ 0/1 ⇜ (1/3 → 2/3) ⇝ 1/1 | s:gm_flute stretch:2 ]", - "[ 0/1 ⇜ (2/3 → 1/1) | s:gm_flute stretch:0.5 ]", - "[ (1/1 → 4/3) ⇝ 2/1 | s:gm_flute stretch:1 ]", - "[ 1/1 ⇜ (4/3 → 5/3) ⇝ 2/1 | s:gm_flute stretch:2 ]", - "[ 1/1 ⇜ (5/3 → 2/1) | s:gm_flute stretch:0.5 ]", - "[ (2/1 → 7/3) ⇝ 3/1 | s:gm_flute stretch:1 ]", - "[ 2/1 ⇜ (7/3 → 8/3) ⇝ 3/1 | s:gm_flute stretch:2 ]", - "[ 2/1 ⇜ (8/3 → 3/1) | s:gm_flute stretch:0.5 ]", - "[ (3/1 → 10/3) ⇝ 4/1 | s:gm_flute stretch:1 ]", - "[ 3/1 ⇜ (10/3 → 11/3) ⇝ 4/1 | s:gm_flute stretch:2 ]", - "[ 3/1 ⇜ (11/3 → 4/1) | s:gm_flute stretch:0.5 ]", + "[ 0/1 → 1/1 | s:gm_flute stretch:2 ]", + "[ 1/1 → 2/1 | s:gm_flute stretch:1 ]", + "[ 2/1 → 3/1 | s:gm_flute stretch:0 ]", + "[ 3/1 → 4/1 | s:gm_flute stretch:-2 ]", ] `;