name, 0, 1), whiteNotes); $place2 = array_search(substr($previousNote->name, 0, 1), whiteNotes); // For reference, white notes array is as follows: // 'whiteNotes', array('F', 'G', 'A', 'B', 'C', 'D', 'E') // 0 1 2 3 4 5 6 // CHANGE BACKTO 5? if(substr($duration, -1) != 'r') { //if($isAscending == 1) { if(($place2 <= 3 && $place2 >= 2) && ($place1 >= 4 && $place1 <= 6)) { //if($place2 <= 3 && $place1 >= 4) { $register++; } // } //else { if(($place1 <= 3 && $place1 >= 2) && ($place2 >= 4 && $place2 <= 6)) { //if($place2 >= 4 && $place1 <= 3) { $register--; } //} } // Only change stem direction on downbeats! // if($subdivision == 1) { if($clef == 'treble') { if(($note->letter == 'B' && $register == 4) || $register > 4) { $stem = -1; } else { $stem = 1; } } elseif($clef == 'bass') { if(($note->letter == 'C' && $register == 3) || $register < 3) { $stem = 1; } else { $stem = -1; } } } $returnText .= "\n".'new ' . $id . '.StaveNote({clef: "' . $clef . '", keys: ["' . $note->name . '/' . $register. '"], duration: "'.$duration.'" , stem_direction: ' . $stem . '})'; $found = 0; $compareNote = $note->name; if($note->accidental == 'n') { $compareNote .= 'n'; } if(substr($duration, -1) != 'r') { for($q=sizeof($accidentalsInBar)-1; $q >= 0; $q--) { // FIND THE LAST INSTANCE OF THE SAME NOTE NAME if(substr($accidentalsInBar[$q], 0, 1)==substr($compareNote,0,1)) { // IF IT IS NOTE THE SAME PITCH if($accidentalsInBar[$q] != $compareNote) { $returnText .= '.addAccidental(0, new ' . $id . '.Accidental("' . $note->accidental . '"))'; // Keep track of accidentals that need to be cancelled $accidentalsInBar[] = $compareNote; } $q = -1; // EXIT FOR LOOP $found++; } } if($found == 0) { if($note->inKey == 0) { $returnText .= '.addAccidental(0, new ' . $id . '.Accidental("' . $note->accidental . '"))'; $accidentalsInBar[] = $compareNote; } } } $returnText .= ','; $allNotes[] = $note->name . $register; $previousNote = $note; return $returnText; } // // ///////////////////////////////////////////////////////////////////// // function inKey($note, $notesInKey){ if (in_array($note, $notesInKey)) { return 1; } else { return 0; } } // ////////////////////////////////////////////////////////////////////////// // function getNotes($startingNote, $mode, $key, $notesInKey=array(), $simplify=0){ $simpleArray = array(); // Find where tonic lies in the scheme of the allNotes and whiteNotes array list($allNotesIndex, $trash) = findNeedle($startingNote[0], allNotes); $comparisonLetter = substr($startingNote[0], 0, 1); $inKey = ''; if(sizeof($notesInKey) > 0) { $inKey = inKey($startingNote[0], $notesInKey); } $accidental = substr($startingNote[0],1); if ($accidental == '') { $accidental = 'n'; } $tonic = new pitch($startingNote[0], $comparisonLetter, $accidental,'', $inKey); $simpleArray[] = $startingNote[0]; $notes = array ( 'ascending' => array($tonic), 'descending' => array($tonic) ); foreach($mode->ascendingIntervals as $semitones) { $allNotesIndex += $semitones; $whiteNotesIndex = array_search(substr($comparisonLetter,0,1), whiteNotes); $whiteNotesIndex = ($whiteNotesIndex + 1) % sizeof(whiteNotes); $options = allNotes[$allNotesIndex % sizeof(allNotes)]; $best = '?'; if($simplify == 1) { $lengths = array_map('strlen', $options); $shortest = min($lengths); // CHECK THIS BLOCK OF CODE for($i=0; $i $shortest) { //echo "Removing " . $options[$i] . "
"; array_splice($options, $i, $i+1); } } if(sizeof($options) == 1) { $best = $options[0]; } } if($best == '?' || $best == '') { foreach($options as $possibility) { if(substr($possibility, 0, 1) == whiteNotes[$whiteNotesIndex]) { $best = $possibility; //echo "CHOSEN $best

"; } } } if($best == '?' || $best == '') { $best = array_rand($options); } $comparisonLetter = substr($best, 0, 1); // CHECK IF OUR NEWLY SELECTED NOTE IS IN THE KEY ONLY IF AN ARRAY // CONTAINING ALL THE NOTES IN THE KEY ARE PROVIDED // $inKey = ''; if(sizeof($notesInKey) > 0) { $inKey = inKey($best, $notesInKey); } $simpleArray[] = $best; $accidental = substr($best,1); if ($accidental == '') { $accidental = 'n'; } $notes['ascending'][] = new pitch($best, $comparisonLetter, $accidental,'',$inKey); // NEED TO FILL IN inKey } $notes['ascending'][] = $tonic; if(sizeof($notesInKey) == 0) { return $simpleArray; } // Find where tonic lies in the scheme of the allNotes and whiteNotes array list($allNotesIndex, $trash) = findNeedle($startingNote[0], allNotes); $comparisonLetter = substr($startingNote[0], 0, 1); foreach($mode->descendingIntervals as $semitones) { $allNotesIndex += $semitones; $whiteNotesIndex = array_search(substr($comparisonLetter,0,1), whiteNotes); $whiteNotesIndex = ($whiteNotesIndex + 1) % sizeof(whiteNotes); $options = allNotes[$allNotesIndex % sizeof(allNotes)]; $best = '?'; if($simplify == 1) { $lengths = array_map('strlen', $options); $shortest = min($lengths); // CHECK THIS BLOCK OF CODE for($i=0; $i $shortest) { //echo "Removing " . $options[$i] . "
"; array_splice($options, $i, $i+1); } } if(sizeof($options) == 1) { $best = $options[0]; } } if($best == '?' || $best == '') { foreach($options as $possibility) { if(substr($possibility, 0, 1) == whiteNotes[$whiteNotesIndex]) { $best = $possibility; //echo "CHOSEN $best

"; } } } if($best == '?' || $best == '') { $best = array_rand($options); } $comparisonLetter = substr($best, 0, 1); // CHECK IF OUR NEWLY SELECTED NOTE IS IN THE KEY ONLY IF AN ARRAY // CONTAINING ALL THE NOTES IN THE KEY ARE PROVIDED // $inKey = ''; if(sizeof($notesInKey) > 0) { $inKey = inKey($best, $notesInKey); } $accidental = substr($best,1); if ($accidental == '') { $accidental = 'n'; } $notes['descending'][] = new pitch($best, $comparisonLetter, $accidental,'',$inKey); // NEED TO FILL IN inKey } $notes['descending'][] = $tonic; return $notes; //print_r($notes['ascending']); echo "
"; //print_r($notes['descending']); } // ///////////////////////////////////////////////////////////////////// // function getKey($noteName, $keyData) { $semitones = $keyData[0]; list($index, $trash) = findNeedle(substr($noteName,0,1), allNotes); $options = allNotes[($index + $semitones) % sizeof(allNotes)]; //echo "The starting pitch is $noteName at index $index in the allNotes array. Add $semitones semitones to that provides the following options
"; //print_r($options); $whiteNotesIndex = array_search(substr($noteName,0,1), whiteNotes); //echo "

The stating pitch is at $whiteNotesIndex in the whiteNotes array. Add " . $keyData[1] . " letters brings us to number "; $whiteNotesIndex = ($whiteNotesIndex + $keyData[1]) % sizeof(whiteNotes); //echo "$whiteNotesIndex which is " . whiteNotes[$whiteNotesIndex] . "

"; $best = '?'; if($best == '?' || $best == '') { foreach($options as $possibility) { if(substr($possibility, 0, 1) == whiteNotes[$whiteNotesIndex]) { $best = $possibility; //echo "CHOSEN $best

"; } } } if($best == '?' || $best == '') { $best = array_rand($options); } $accidental = substr($best,1); if ($accidental == '') { $accidental = 'n'; } //$note = new pitch($best, substr($best, 0,1), $accidental,'', $inKey); // NEED TO FILL IN inKey $note = new pitch($best, substr($best, 0,1), $accidental,'', 0); //print_r($note); return $note->name; } // // ///////////////////////////////////////////////////////////////////// // function generateScale($notes,$key,$startingOctave,$patternName, $patternFunction, $directions, $clef) { $d = reset($notes); $divName = 'q' . generateRandomString(); setup($divName, '2800'); eval($patternFunction($divName, $d[0]->name, $key, $notes, $startingOctave, 0, $directions, $clef, $patternName)); finishRender(); } // ///////////////////////////////////////////////////////////////////// // ?> Warmup/Routine Generator

Scale Routine Randomizer

Joel Brennan

Each time this page is loaded, a new collection of scales is displayed. You can change which modes you want to include and can customise scale direction and patterns.

Options (change | reset)
Instrument: Trumpet (treble clef)
Modes: Major, Natural Minor, Harmonic Minor, Melodic Minor
Routine:Expansion 1 (Trumpet)
Patterns: Single Tongue, Slur, Staccato Control
F Natural Minor - Staccato Control