Bisqwit's ocarina tabulature generator

For the extended range sweet potato (6-hole)

Song to generate fingering charts for:
Legend: '; echo ''; echo ''; echo ' '; echo '
'; echo ' '; echo '
'; echo '

Result:

'; echo '
'; $best_score = -10000; $mp3name = ''; $highest = 0; $lowest = 0; $score = 0; if($autobase) { ob_start(); $highest = -1000; $lowest = 1000; $octave = 1; $basenote = 0; Compile($script); ob_end_clean(); #print "lowest($lowest),highest($highest)

"; $best=0;$best_score=-10000; $b0 = -$highest; $b1 = min(-$lowest+12, $b0 + 30); #print "checking($b0)through($b1)

"; for($basenote=$b0; $basenote<=$b1; ++$basenote) { ob_start(); $score = 0; $octave = 1; Compile($script); ob_end_clean(); #ob_end_clean(); print "$basenote: $score

"; ob_start(); if($score > $best_score) { $best = $basenote; $best_score = $score; } } $basenote = $best; echo ''; print "Automatically selected transpose value $basenote (score $best_score)

\n"; } $mp3name = ''; $score = 0; $octave = 1; Compile($script); echo '

'; $fn = "{$mp3name}.mp3"; echo 'Listen'; echo '

Note: When the bottom holes are not displayed, they are assumed to be closed. The leftside bottom hole is equivalent to the middle bottom hole in 5-hole ocarinas.'; echo '


'; echo GetEmail('Send feedback: ', 'Bisqwit', 'bisqwit@iki.fi'); function Compile($script) { $rep = Array(); preg_match_all("@[a-gA-G]#?|[<>.*]@", $script, $rep); foreach($rep as $s) preg_replace( Array( '/c(?!#)/e', '/c#/e', '/d(?!#)/e', '/d#/e', '/e(?!#)/e', '/f(?!#)/e', '/f#/e', '/g(?!#)/e', '/g#/e', '/a(?!#)/e', '/a#/e', '/b(?!#)/e', '/C(?!#)/e', '/C#/e', '/D(?!#)/e', '/D#/e', '/E(?!#)/e', '/F(?!#)/e', '/F#/e', '/G(?!#)/e', '/G#/e', '/A(?!#)/e', '/A#/e', '/B(?!#)/e', '//e', '/\./e', '/\*/e'), Array( 'Note(0)', 'Note(1)', 'Note(2)', 'Note(3)', 'Note(4)', 'Note(5)', 'Note(6)', 'Note(7)', 'Note(8)', 'Note(9)', 'Note(10)', 'Note(11)', 'Note(12+0)', 'Note(12+1)', 'Note(12+2)', 'Note(12+3)', 'Note(12+4)', 'Note(12+5)', 'Note(12+6)', 'Note(12+7)', 'Note(12+8)', 'Note(12+9)', 'Note(12+10)', 'Note(12+11)', 'Octave(-1)', 'Octave(1)', 'Dot()', 'Aster()'), $s); } function Note($n) { global $octave, $basenote, $lowest, $highest, $mp3name; $n += $octave * 12; $n += $basenote; if(ereg('[0-9]$', $mp3name)) $mp3name .= 'a'; $mp3name .= $n; if($n < $lowest) $lowest = $n; if($n > $highest) $highest = $n; global $score, $positiot; $p = $positiot[$n ]; if(!isset($p)) { printf (' (%d) ', $n); # Impossible notes are a real turn-down. $score -= 3.0; return; } # Half-open holes are hard to use. if(ereg('[abcdpq]', $p)) $score -= 0.5; # Exposing the thumbholes requires blowing hard, which is not nice if(!ereg('PQ', $p)) $score -= 0.2; #$fn = $p . '.png'; #$fn = 'imgset.png'; #$fn = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; $fn = 'blank.gif'; printf('%s', $fn, $p); } function Octave($inc) { global $octave; $octave += $inc; } function Dot() { global $mp3name; print '   '; $mp3name .= '.'; } function Aster() { global $mp3name; $mp3name .= '+'; print '
'; }