diff --git a/src/pitch_generation/getProceduralPitches.js b/src/pitch_generation/getProceduralPitches.js index 51ec6e5..f2c4ed1 100644 --- a/src/pitch_generation/getProceduralPitches.js +++ b/src/pitch_generation/getProceduralPitches.js @@ -28,10 +28,6 @@ export const getProceduralPitches = () => { let pitchNames = pitches.map(x => extractPitchName(x)); let pitchNums = pitchNames.map(x => musicalPitches.indexOf(x)); - - // console.log(pitches); - // console.log(pitchNames); - // console.log(pitchNums); // this value is assigned true only if the loop below finds an interval value // which corresponds to a dissonance, 1 or 6 diff --git a/src/pitch_generation/getRandomPitches.js b/src/pitch_generation/getRandomPitches.js index 185d085..8b87c10 100644 --- a/src/pitch_generation/getRandomPitches.js +++ b/src/pitch_generation/getRandomPitches.js @@ -25,8 +25,5 @@ export const getRandomPitches = () => { } } } - - console.log(formattedPitches); - console.log(pitches); return pitches; } diff --git a/src/pitch_generation/helper.js b/src/pitch_generation/helper.js index 3b73200..3c1ad59 100644 --- a/src/pitch_generation/helper.js +++ b/src/pitch_generation/helper.js @@ -1,3 +1,3 @@ import { melodicGeneration } from "./melodicGeneration.js"; -melodicGeneration(['C3', 'G3', 'A3', 'G4']); +melodicGeneration(['C3', 'G3', 'A3', 'E5']); diff --git a/src/pitch_generation/melodicGeneration.js b/src/pitch_generation/melodicGeneration.js index afcd29a..673f462 100644 --- a/src/pitch_generation/melodicGeneration.js +++ b/src/pitch_generation/melodicGeneration.js @@ -35,37 +35,64 @@ export const melodicGeneration = (prevPitches) => { let pitchNumOne = musicalPitches.indexOf(pitchNameOne); let pitchNumTwo = musicalPitches.indexOf(pitchNameTwo); - let interval = pitchNumTwo - pitchNumOne; + let interval = pitchNumOne - pitchNumTwo; console.log(prevSoprano, newSoprano); console.log(pitchNumOne, pitchNumTwo); + // when the octave number is the same if (octaveOne === octaveTwo) { console.log("OCTAVE: same"); - if (pitchNumOne > pitchNumTwo || pitchNumTwo === 0) { + + if (pitchNumOne === pitchNumTwo) { + interval = 0; + } else if (pitchNumTwo === 0) { + interval = 12 - pitchNumOne; + } else if (pitchNumOne > pitchNumTwo) { console.log("WRAP"); - interval += 12; + interval = pitchNumTwo - pitchNumOne; + } else if (pitchNumOne < pitchNumTwo) { + interval *= -1; } } - // accounts for when the octave marker is different between pitches + // when the first octave number is higher if (octaveOne > octaveTwo) { console.log('OCTAVE: first is higher'); - if (pitchNumOne > pitchNumTwo) { - console.log("WRAP"); - interval = Math.abs(interval) + 12; + if (pitchNumOne === pitchNumTwo) { + interval = 0; + } else if (pitchNumTwo === 0) { + interval = pitchNumOne * -1; + } else if (pitchNumOne > pitchNumTwo) { + const wrapperCheckOne = (pitchNumOne + 9) % 12; + const wrapperCheckTwo = (pitchNumTwo + 9) % 12; + + console.log("---------------"); + console.log("PROBLEMS HERE"); + console.log(`interval: ${interval}`); + console.log(`adjusted pitch idx of first pitch: ${wrapperCheckOne}`); + console.log(`adjusted pitch idx of second pitch: ${wrapperCheckTwo}`); + console.log("---------------"); + + interval = pitchNumTwo - pitchNumOne - 12; + } else if (pitchNumOne < pitchNumTwo) { + console.log("caught"); + interval = (interval + 12) * -1; + } else { + console.log("NO CONDITION APPLIES"); } + // when the second octave number is higher } else if (octaveOne < octaveTwo) { console.log('OCTAVE: second is higher'); - if (pitchNumTwo === 0) { - console.log("Edge case: pitch two = 0"); - interval = Math.abs(interval - 12) + 12; - } - if (pitchNumOne > pitchNumTwo) { console.log("WRAP"); interval = 12 - Math.abs(interval); + } else if (pitchNumOne < pitchNumTwo) { + interval *= -1; + } else if (pitchNumTwo === 0) { + console.log("Edge case: pitch two = 0"); + interval = (12 - pitchNumOne) + 12; } } diff --git a/src/styleUtils.js b/src/styleUtils.js index 1b8dcfc..3b7a4a0 100644 --- a/src/styleUtils.js +++ b/src/styleUtils.js @@ -24,7 +24,6 @@ showMore.onclick = () => { } startButton.onclick = async () => { - // @ts-expect-error - namespace again, failed import from Tone await Tone.start() .then(() => { appReady = true;