function neighbours() {
		$near = array();
		// start at one, because we leave the root alone
		for ($i=1; $i<12; $i++) {
			if ($this->scale & (1 << ($i))) {
				// if this tone is on,
				$copy = $this->scale;

				// turn this tone off,
				$off = $copy ^ (1 << ($i));
				$near[] = $off;

				// move this tone down one semitone
				$copy = $off | (1 << ($i - 1));
				$near[] = $copy;

				// move this tone up one semitone, but be careful not to create an octave
				if ($i != 11) {
					$copy = $off | (1 << ($i + 1));
					$near[] = $copy;
				}
			} else {
				// if this tone is off, then try turning it on
				$copy = $this->scale;
				$copy = $copy | (1 << ($i));
				$near[] = $copy;
			}
		}
		return array_unique($near);
	}
function neighbours() {
		$near = array();
		// start at one, because we leave the root alone
		for ($i=1; $i<12; $i++) {
			if ($this->scale & (1 << ($i))) {
				// if this tone is on,
				$copy = $this->scale;

				// turn this tone off,
				$off = $copy ^ (1 << ($i));
				$near[] = $off;

				// move this tone down one semitone
				$copy = $off | (1 << ($i - 1));
				$near[] = $copy;

				// move this tone up one semitone, but be careful not to create an octave
				if ($i != 11) {
					$copy = $off | (1 << ($i + 1));
					$near[] = $copy;
				}
			} else {
				// if this tone is off, then try turning it on
				$copy = $this->scale;
				$copy = $copy | (1 << ($i));
				$near[] = $copy;
			}
		}
		return array_unique($near);
	}
function neighbours ( ) { $ near = array ( ) ; // start at one, because we leave the root alone for ( $ i = 1 ; $ i < 12 ; $ i ++ ) { if ( $ this -> scale & ( 1 << ( $ i ) ) ) { // if this tone is on, $ copy = $ this -> scale ; // turn this tone off, $ off = $ copy ^ ( 1 << ( $ i ) ) ; $ near [ ] = $ off ; // move this tone down one semitone $ copy = $ off | ( 1 << ( $ i - 1 ) ) ; $ near [ ] = $ copy ; // move this tone up one semitone, but be careful not to create an octave if ( $ i != 11 ) { $ copy = $ off | ( 1 << ( $ i + 1 ) ) ; $ near [ ] = $ copy ; } } else { // if this tone is off, then try turning it on $ copy = $ this -> scale ; $ copy = $ copy | ( 1 << ( $ i ) ) ; $ near [ ] = $ copy ; } } return array_unique ( $ near ) ; }
Returns all the scales that this one can be transformed into by one addition, deletion, or
having one tone shifted up or down by one semitone. In other words, it returns all the scales
with a levenshtein distance of 1.
Returns all the scales that this one can be transformed into by one addition deletion or having one tone shifted up or down by one semitone . In other words it returns all the scales with a levenshtein distance of 1 .