#!perl # "Harmony" v1.1 # by David Seay # # Crank up the volume. # Listen Closely. # use Mac::Events; use Mac::Events qw(@Event $CurrentEvent); use Mac::Speech; @scalePattern = split(",","0,2,4,5,7,9,11,12,14,16,17,19,21,23,24"); @chordPattern = split(",","0,2,4,7,9,11,14,16,18,21"); $speech = 'e e e e ' x 10; $notes = 8; $firstNote = 42; $announcer = $Voice{'Princess'}; for $harmonies (2..$#chordPattern + 1) { $channel = NewSpeechChannel($announcer) or die $^E; SpeakText $channel, "$harmonies Part Harmony"; print "$harmonies Part Harmony\n"; while (SpeechBusy()) {} DisposeSpeechChannel $channel if $channel; for $v (0..$harmonies - 1) { $channel[$v] = NewSpeechChannel($Voice{'Zarvox'}) or die $^E; } if ($harmonies == $#chordPattern + 1) { $notes = $notes + 7; $speech = $speech x 2; } for $pitchX (0..$notes - 1) { for $v (0..$harmonies - 1) { $pitch[$v] = $firstNote + $scalePattern[$pitchX + $chordPattern[$v]]; SetSpeechPitch $channel[$v], $pitch[$v]; } if ($pitchX == 0) { for $v (0..$harmonies - 1) { SpeakText $channel[$v], $speech } } select(undef, undef, undef, .6); } while (SpeechBusy()) { WaitNextEvent(); } for $v (0..$harmonies - 1) { DisposeSpeechChannel $channel[$v] if $channel[$v]; } sleep(1); } $channel = NewSpeechChannel($announcer) or die $^E; SpeakText $channel, "How many harmonies did you really hear?"; while (SpeechBusy()) {} DisposeSpeechChannel $channel if $channel;