Skip to content

Commit

Permalink
Ratio transpose and Ratio interval (#3936)
Browse files Browse the repository at this point in the history
* use processPitch for all pitch types

* Add support for cents (#3937)

* add support for cents through semi-tone transposition

* add 50 cents macro

* add cents example

* add output frequencies

* fix issue with ratio cents

* add a ratio-cents example

* use processPitch for all pitch types

* convert freq to note before scalar step
  • Loading branch information
walterbender authored Jul 7, 2024
1 parent 55570e8 commit f88955e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 292 deletions.
11 changes: 6 additions & 5 deletions js/turtle-singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,18 @@ class Singer {
* @param {Number} octave
* @returns {Number} inverted value
*/
static calculateInvert(logo, turtle, note, octave) {
static calculateInvert(logo, turtle, note, octave, cents) {
const activity = logo.activity;
const tur = activity.turtles.ithTurtle(turtle);

if (cents === undefined) {
cents = 0;
}
let delta = 0;
const note1 = getNote(
note,
octave,
0,
cents,
tur.singer.keySignature,
tur.singer.movable,
null,
Expand All @@ -405,7 +408,7 @@ class Singer {
const note2 = getNote(
tur.singer.invertList[i][0],
tur.singer.invertList[i][1],
0,
-cents, // this needs to be tested.
tur.singer.keySignature,
tur.singer.movable,
null,
Expand Down Expand Up @@ -951,7 +954,6 @@ class Singer {
for (let i = 0; i < tur.singer.transpositionRatios.length; i++) {
ratio *= tur.singer.transpositionRatios[i];
}

if (ratio != 1) {
const hertz = pitchToFrequency(
noteObj[0],
Expand All @@ -966,7 +968,6 @@ class Singer {
if (noteObj[2] !== 0 && cents === 0) {
cents = noteObj[2];
// eslint-disable-next-line no-console
console.log("applying cents:", cents);
}

if (tur.singer.drumStyle.length > 0) {
Expand Down
Loading

0 comments on commit f88955e

Please sign in to comment.