[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] MacPerl Harmonizes



#!perl

# "Harmonizer" v1.0
# by David Seay <g-s@navix.net>
#
# Crank up the volume.
#
# Listen Closely.
#

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";
	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()) {}
	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;



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org