Merge pull request 'Feat: Hook up octave and fix example' (#1773) from glossing/hook-up-octave into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1773
This commit is contained in:
commit
743e239e52
3 changed files with 17 additions and 17 deletions
|
|
@ -1865,12 +1865,12 @@ export const { nudge } = registerControl('nudge');
|
||||||
* Sets the default octave of a synth.
|
* Sets the default octave of a synth.
|
||||||
*
|
*
|
||||||
* @name octave
|
* @name octave
|
||||||
|
* @synonyms oct
|
||||||
* @param {number | Pattern} octave octave number
|
* @param {number | Pattern} octave octave number
|
||||||
* @example
|
* @example
|
||||||
* n("0,4,7").s('supersquare').octave("<3 4 5 6>").osc()
|
* n("0,4,7").scale("F:minor").s('supersaw').octave("<0 1 2 3>")
|
||||||
* @superDirtOnly
|
|
||||||
*/
|
*/
|
||||||
export const { octave } = registerControl('octave');
|
export const { octave, oct } = registerControl('octave', 'oct');
|
||||||
|
|
||||||
// ['ophatdecay'],
|
// ['ophatdecay'],
|
||||||
// TODO: example
|
// TODO: example
|
||||||
|
|
|
||||||
|
|
@ -540,7 +540,7 @@ export const getDistortion = (distort, postgain, algorithm) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFrequencyFromValue = (value, defaultNote = 36) => {
|
export const getFrequencyFromValue = (value, defaultNote = 36) => {
|
||||||
let { note, freq } = value;
|
let { note, freq, octave = 0 } = value;
|
||||||
note = note || defaultNote;
|
note = note || defaultNote;
|
||||||
if (typeof note === 'string') {
|
if (typeof note === 'string') {
|
||||||
note = noteToMidi(note); // e.g. c3 => 48
|
note = noteToMidi(note); // e.g. c3 => 48
|
||||||
|
|
@ -549,7 +549,7 @@ export const getFrequencyFromValue = (value, defaultNote = 36) => {
|
||||||
if (!freq && typeof note === 'number') {
|
if (!freq && typeof note === 'number') {
|
||||||
freq = midiToFreq(note); // + 48);
|
freq = midiToFreq(note); // + 48);
|
||||||
}
|
}
|
||||||
|
freq *= Math.pow(2, octave);
|
||||||
return Number(freq);
|
return Number(freq);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7302,18 +7302,18 @@ exports[`runs examples > example "nrpv" example index 0 1`] = `
|
||||||
|
|
||||||
exports[`runs examples > example "octave" example index 0 1`] = `
|
exports[`runs examples > example "octave" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/1 | n:0 s:supersquare octave:3 ]",
|
"[ 0/1 → 1/1 | note:F3 s:supersaw octave:0 ]",
|
||||||
"[ 0/1 → 1/1 | n:4 s:supersquare octave:3 ]",
|
"[ 0/1 → 1/1 | note:C4 s:supersaw octave:0 ]",
|
||||||
"[ 0/1 → 1/1 | n:7 s:supersquare octave:3 ]",
|
"[ 0/1 → 1/1 | note:F4 s:supersaw octave:0 ]",
|
||||||
"[ 1/1 → 2/1 | n:0 s:supersquare octave:4 ]",
|
"[ 1/1 → 2/1 | note:F3 s:supersaw octave:1 ]",
|
||||||
"[ 1/1 → 2/1 | n:4 s:supersquare octave:4 ]",
|
"[ 1/1 → 2/1 | note:C4 s:supersaw octave:1 ]",
|
||||||
"[ 1/1 → 2/1 | n:7 s:supersquare octave:4 ]",
|
"[ 1/1 → 2/1 | note:F4 s:supersaw octave:1 ]",
|
||||||
"[ 2/1 → 3/1 | n:0 s:supersquare octave:5 ]",
|
"[ 2/1 → 3/1 | note:F3 s:supersaw octave:2 ]",
|
||||||
"[ 2/1 → 3/1 | n:4 s:supersquare octave:5 ]",
|
"[ 2/1 → 3/1 | note:C4 s:supersaw octave:2 ]",
|
||||||
"[ 2/1 → 3/1 | n:7 s:supersquare octave:5 ]",
|
"[ 2/1 → 3/1 | note:F4 s:supersaw octave:2 ]",
|
||||||
"[ 3/1 → 4/1 | n:0 s:supersquare octave:6 ]",
|
"[ 3/1 → 4/1 | note:F3 s:supersaw octave:3 ]",
|
||||||
"[ 3/1 → 4/1 | n:4 s:supersquare octave:6 ]",
|
"[ 3/1 → 4/1 | note:C4 s:supersaw octave:3 ]",
|
||||||
"[ 3/1 → 4/1 | n:7 s:supersquare octave:6 ]",
|
"[ 3/1 → 4/1 | note:F4 s:supersaw octave:3 ]",
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue