public function noteNumberToPitch($noteNumber, $preferredAlteration = 1) {
        $chroma = $this->_truemod($noteNumber, 12); // chroma is the note pitch independent of octave, eg C = 0, Eb/D# = 3, E = 4
        $octave = (($noteNumber - $chroma) / 12) + 4;
        $this->octave = $octave;

        if (is_array(self::$chromas[$chroma])) {
            if ($preferredAlteration == 1) {
                $this->step = self::$chromas[$chroma][1]['step'];
                $this->alter = self::$chromas[$chroma][1]['alter'];
            } else {
                $this->step = self::$chromas[$chroma][-1]['step'];
                $this->alter = self::$chromas[$chroma][-1]['alter'];
            }
        } else {
            $this->step = self::$chromas[$chroma];
            $this->alter = 0;
        }
    }
public function noteNumberToPitch($noteNumber, $preferredAlteration = 1) {
        $chroma = $this->_truemod($noteNumber, 12); // chroma is the note pitch independent of octave, eg C = 0, Eb/D# = 3, E = 4
        $octave = (($noteNumber - $chroma) / 12) + 4;
        $this->octave = $octave;

        if (is_array(self::$chromas[$chroma])) {
            if ($preferredAlteration == 1) {
                $this->step = self::$chromas[$chroma][1]['step'];
                $this->alter = self::$chromas[$chroma][1]['alter'];
            } else {
                $this->step = self::$chromas[$chroma][-1]['step'];
                $this->alter = self::$chromas[$chroma][-1]['alter'];
            }
        } else {
            $this->step = self::$chromas[$chroma];
            $this->alter = 0;
        }
    }
public function noteNumberToPitch ( $ noteNumber , $ preferredAlteration = 1 ) { $ chroma = $ this -> _truemod ( $ noteNumber , 12 ) ; // chroma is the note pitch independent of octave, eg C = 0, Eb/D# = 3, E = 4 $ octave = ( ( $ noteNumber - $ chroma ) / 12 ) + 4 ; $ this -> octave = $ octave ; if ( is_array ( self :: $ chromas [ $ chroma ] ) ) { if ( $ preferredAlteration == 1 ) { $ this -> step = self :: $ chromas [ $ chroma ] [ 1 ] [ 'step' ] ; $ this -> alter = self :: $ chromas [ $ chroma ] [ 1 ] [ 'alter' ] ; } else { $ this -> step = self :: $ chromas [ $ chroma ] [ - 1 ] [ 'step' ] ; $ this -> alter = self :: $ chromas [ $ chroma ] [ - 1 ] [ 'alter' ] ; } } else { $ this -> step = self :: $ chromas [ $ chroma ] ; $ this -> alter = 0 ; } }
accepts a note number and sets the pitch properties

@param  integer $noteNumber          signed integer with origin zero as middle C4
@param  integer $preferredAlteration 1 for sharp or -1 for flats
@return array                       returns a pitch array, containing step and alter elements.
accepts a note number and sets the pitch properties