public function normalizeScalePitches($pitches) {
		if ($this->isHeliotonic()) {
			// first priority rule is that a heliotonic scale - which CAN be represented with
			// a note on every step, MUST be notated that way. Even if there are lots of accidentals.
			$currentStep = $pitches[0]->step;
			for ($i = 1; $i < count($pitches); $i++) {
				$prevstep = $pitches[$i-1]->step;
				$shouldbe = Pitch::stepUp($prevstep);
				if ($pitches[$i] != $shouldbe) {
					$pitches[$i] = $pitches[$i]->enharmonicizeToStep($shouldbe);
				}
			}
		}

		// here we should normalize scales where there is a note and then its sharp on the same step, where
		// the step above is empty. As in scale 1621, 1725, 1755, 2275, 2487, etc

		$currentStep = $pitches[0]->step;
		for ($i = 1; $i < (count($pitches)-1); $i++) {

			if ($pitches[$i-1]->step == $pitches[$i]->step) {
				if ($pitches[$i]->alter == 1) {
					$stepup = Pitch::stepUp($pitches[$i]->step);
					if ($pitches[$i+1]->step != $stepup) {
						$pitches[$i] = $pitches[$i]->enharmonicizeToStep($stepup);
					}
				}
			}
		}

		// another rule: if the note before is on a step and the note after is two steps above, let's
		// put this note on the step between, and alter it to fit.
		// for example, scale 1427

		// rule: a minor third should be more favoured than an augmented second
		//
		// in fact, any major or minor interval should be preferred instead of an augmented or diminished one

		return $pitches;
	}
public function normalizeScalePitches($pitches) {
		if ($this->isHeliotonic()) {
			// first priority rule is that a heliotonic scale - which CAN be represented with
			// a note on every step, MUST be notated that way. Even if there are lots of accidentals.
			$currentStep = $pitches[0]->step;
			for ($i = 1; $i < count($pitches); $i++) {
				$prevstep = $pitches[$i-1]->step;
				$shouldbe = Pitch::stepUp($prevstep);
				if ($pitches[$i] != $shouldbe) {
					$pitches[$i] = $pitches[$i]->enharmonicizeToStep($shouldbe);
				}
			}
		}

		// here we should normalize scales where there is a note and then its sharp on the same step, where
		// the step above is empty. As in scale 1621, 1725, 1755, 2275, 2487, etc

		$currentStep = $pitches[0]->step;
		for ($i = 1; $i < (count($pitches)-1); $i++) {

			if ($pitches[$i-1]->step == $pitches[$i]->step) {
				if ($pitches[$i]->alter == 1) {
					$stepup = Pitch::stepUp($pitches[$i]->step);
					if ($pitches[$i+1]->step != $stepup) {
						$pitches[$i] = $pitches[$i]->enharmonicizeToStep($stepup);
					}
				}
			}
		}

		// another rule: if the note before is on a step and the note after is two steps above, let's
		// put this note on the step between, and alter it to fit.
		// for example, scale 1427

		// rule: a minor third should be more favoured than an augmented second
		//
		// in fact, any major or minor interval should be preferred instead of an augmented or diminished one

		return $pitches;
	}
public function normalizeScalePitches ( $ pitches ) { if ( $ this -> isHeliotonic ( ) ) { // first priority rule is that a heliotonic scale - which CAN be represented with // a note on every step, MUST be notated that way. Even if there are lots of accidentals. $ currentStep = $ pitches [ 0 ] -> step ; for ( $ i = 1 ; $ i < count ( $ pitches ) ; $ i ++ ) { $ prevstep = $ pitches [ $ i - 1 ] -> step ; $ shouldbe = Pitch :: stepUp ( $ prevstep ) ; if ( $ pitches [ $ i ] != $ shouldbe ) { $ pitches [ $ i ] = $ pitches [ $ i ] -> enharmonicizeToStep ( $ shouldbe ) ; } } } // here we should normalize scales where there is a note and then its sharp on the same step, where // the step above is empty. As in scale 1621, 1725, 1755, 2275, 2487, etc $ currentStep = $ pitches [ 0 ] -> step ; for ( $ i = 1 ; $ i < ( count ( $ pitches ) - 1 ) ; $ i ++ ) { if ( $ pitches [ $ i - 1 ] -> step == $ pitches [ $ i ] -> step ) { if ( $ pitches [ $ i ] -> alter == 1 ) { $ stepup = Pitch :: stepUp ( $ pitches [ $ i ] -> step ) ; if ( $ pitches [ $ i + 1 ] -> step != $ stepup ) { $ pitches [ $ i ] = $ pitches [ $ i ] -> enharmonicizeToStep ( $ stepup ) ; } } } } // another rule: if the note before is on a step and the note after is two steps above, let's // put this note on the step between, and alter it to fit. // for example, scale 1427 // rule: a minor third should be more favoured than an augmented second // // in fact, any major or minor interval should be preferred instead of an augmented or diminished one return $ pitches ; }
What this function has got to do is make sure that the C sharp major scale uses an E sharp, not
an F natural. To do that it recognizes scales that are diatonic, and forces each note to be on
consecutive steps. To do that, it assumes that the first note is on the correct step!

TODO: it should handle complex scales like bebop and octotonic properly.
Good luck!

@param  Pitch[] $pitches [description]
@return Pitch[]
What this function has got to do is make sure that the C sharp major scale uses an E sharp not an F natural . To do that it recognizes scales that are diatonic and forces each note to be on consecutive steps . To do that it assumes that the first note is on the correct step!