public function getTriads() {
    	if (!$this->isHeliotonic()) {
			return null;
		}
    	$pitches = $this->getPitches(); // this step already does the proper enharmonization for spelling
    	$count = count($pitches);

    	// now get the same pitches up an octave
    	$raised = array();
    	foreach ($pitches as $pitch) {
    		$raised[] = new Pitch($pitch->step, $pitch->alter, $pitch->octave + 1);
    	}

    	$pitches = array_merge($pitches, $raised);
    	// var_dump($pitches);

    	$chords = array();
    	for ($i=0; $i<$count; $i++) {
    		// build a triad on the ith degree
    		$triad = Chord::constructFromArray(
    			array(
    				'notes' => array(
    					array(
    						'pitch' => array(
    							'step' => $pitches[$i]->step,
    							'alter' => $pitches[$i]->alter,
    							'octave' => $pitches[$i]->octave
    						)
    					),
    					array(
    						'pitch' => array(
    							'step' => $pitches[$i+2]->step,
    							'alter' => $pitches[$i+2]->alter,
    							'octave' => $pitches[$i+2]->octave
    						)
    					),
    					array(
    						'pitch' => array(
    							'step' => $pitches[$i+4]->step,
    							'alter' => $pitches[$i+4]->alter,
    							'octave' => $pitches[$i+4]->octave
    						)
    					)
    				)
    			)
    		);
    		$chords[] = $triad;
    	}
    	return $chords;
    }
public function getTriads() {
    	if (!$this->isHeliotonic()) {
			return null;
		}
    	$pitches = $this->getPitches(); // this step already does the proper enharmonization for spelling
    	$count = count($pitches);

    	// now get the same pitches up an octave
    	$raised = array();
    	foreach ($pitches as $pitch) {
    		$raised[] = new Pitch($pitch->step, $pitch->alter, $pitch->octave + 1);
    	}

    	$pitches = array_merge($pitches, $raised);
    	// var_dump($pitches);

    	$chords = array();
    	for ($i=0; $i<$count; $i++) {
    		// build a triad on the ith degree
    		$triad = Chord::constructFromArray(
    			array(
    				'notes' => array(
    					array(
    						'pitch' => array(
    							'step' => $pitches[$i]->step,
    							'alter' => $pitches[$i]->alter,
    							'octave' => $pitches[$i]->octave
    						)
    					),
    					array(
    						'pitch' => array(
    							'step' => $pitches[$i+2]->step,
    							'alter' => $pitches[$i+2]->alter,
    							'octave' => $pitches[$i+2]->octave
    						)
    					),
    					array(
    						'pitch' => array(
    							'step' => $pitches[$i+4]->step,
    							'alter' => $pitches[$i+4]->alter,
    							'octave' => $pitches[$i+4]->octave
    						)
    					)
    				)
    			)
    		);
    		$chords[] = $triad;
    	}
    	return $chords;
    }
public function getTriads ( ) { if ( ! $ this -> isHeliotonic ( ) ) { return null ; } $ pitches = $ this -> getPitches ( ) ; // this step already does the proper enharmonization for spelling $ count = count ( $ pitches ) ; // now get the same pitches up an octave $ raised = array ( ) ; foreach ( $ pitches as $ pitch ) { $ raised [ ] = new Pitch ( $ pitch -> step , $ pitch -> alter , $ pitch -> octave + 1 ) ; } $ pitches = array_merge ( $ pitches , $ raised ) ; // var_dump($pitches); $ chords = array ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { // build a triad on the ith degree $ triad = Chord :: constructFromArray ( array ( 'notes' => array ( array ( 'pitch' => array ( 'step' => $ pitches [ $ i ] -> step , 'alter' => $ pitches [ $ i ] -> alter , 'octave' => $ pitches [ $ i ] -> octave ) ) , array ( 'pitch' => array ( 'step' => $ pitches [ $ i + 2 ] -> step , 'alter' => $ pitches [ $ i + 2 ] -> alter , 'octave' => $ pitches [ $ i + 2 ] -> octave ) ) , array ( 'pitch' => array ( 'step' => $ pitches [ $ i + 4 ] -> step , 'alter' => $ pitches [ $ i + 4 ] -> alter , 'octave' => $ pitches [ $ i + 4 ] -> octave ) ) ) ) ) ; $ chords [ ] = $ triad ; } return $ chords ; }
Returns triads built on each step of a scale. Only works for diatonic scales, and should always
render the chords using the right enharmonic spellings.
Returns triads built on each step of a scale . Only works for diatonic scales and should always render the chords using the right enharmonic spellings .