creation of i control for tune and xen functions
This commit is contained in:
parent
4439599117
commit
cbf472fe0a
5 changed files with 163 additions and 110 deletions
|
|
@ -8,23 +8,23 @@ import Tune from './tunejs.js';
|
|||
import { register } from '@strudel/core';
|
||||
|
||||
/**
|
||||
* Assumes a numerical pattern of EDO steps. Accepts a scale name or list of frequencies (see all available names at the link on the reference). Returns a new pattern with all values mapped to a frequency ratio. Similar to `xen`.
|
||||
* Assumes pattern contains numerical scale degrees on the `i` control (see examples below). Accepts a scale name or list of frequencies (see all available names at the link on the reference). Returns a new pattern with all values mapped to a frequency ratio. Similar to `xen`.
|
||||
* @name tune
|
||||
* @returns Pattern
|
||||
* @memberof Pattern
|
||||
* @param {(string | number[] )} scale
|
||||
* @example
|
||||
* "0 1 2 3 4 5".tune("hexany15").mul("220").freq()
|
||||
* i("0 1 2 3 4 5").tune("hexany15").mul("220").freq()
|
||||
* @example
|
||||
* // You can set your root to be a
|
||||
* // particular note with getFreq:
|
||||
* "4 8 9 10 - - 5 7 9 11 - -".tune("tranh3")
|
||||
* i("4 8 9 10 - - 5 7 9 11 - -").tune("tranh3")
|
||||
* .mul(getFreq('c3'))
|
||||
* .freq().clip(.5).room(1)
|
||||
* @example
|
||||
* // You can also give tune a list of
|
||||
* // frequencies to use as the scale:
|
||||
* "0 1 2 3 4".tune([
|
||||
* i("0 1 2 3 4").tune([
|
||||
* 261.6255653006,
|
||||
* 302.72962012827,
|
||||
* 350.29154279212,
|
||||
|
|
@ -32,6 +32,7 @@ import { register } from '@strudel/core';
|
|||
* 469.00678383895,
|
||||
* 523.2511306012
|
||||
* ]).mul(220).freq();
|
||||
*
|
||||
* @tags tonal
|
||||
*/
|
||||
|
||||
|
|
@ -45,6 +46,12 @@ export const tune = register('tune', (scale, pat) => {
|
|||
// if the tonic is a frequency, why are we putting in "1"
|
||||
tune.tonicize(1);
|
||||
return pat.withHap((hap) => {
|
||||
return hap.withValue(() => tune.note(hap.value));
|
||||
if (typeof hap.value !== 'object') {
|
||||
throw new Error(`Expected hap to have control 'i' set, but received ${hap.value.i}, try wrapping input in i()`)
|
||||
}
|
||||
// const { i, ...otherValues } = hap.value;
|
||||
// hap.value = { ...otherValues, freq: tune.note(i)}
|
||||
// return hap
|
||||
return hap.withValue(() => tune.note(hap.value.i));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue