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

[MacPerl] MacPerl plays a round



#!perl

# "Rounds" v1.0
# by David Seay <g-s@navix.net>
#

use Mac::Speech;

@scalePattern = split(",","
0,2,4,5,7,9,11,12,14,16,17,19,21,23,24,26,28,29,31,33,35,36");

@lyrics  = split(",","
Are,,you,,slee,,pingg,,Are,,you,,slee,,pingg,,
Bru,,ther,,John,,,,Bru,,ther,,John,,,,
More,ning,bells,have,spo,,ken,,More,ning,bels,have,spo,,ken,,
Dingg,,dongg,,dingg,,,,Dingg,,dongg,,dingg,,");

@notes  = split(",","
0,,1,,2,,0,,0,,1,,2,,0,,
2,,3,,4,,,,2,,3,,4,,,,
4,5,4,3,2,,0,,4,5,4,3,2,,0,,
0,,-3,,0,,,,0,,-3,,0,,");

if ($#notes != $#lyrics) {
	die "$#lyrics lyrics, $#notes notes (should be equal)";
}

$firstNote = 41;
$parts = 2;
$partStart0 = 0;
$partStart1 = 15;

for $v (0..$parts - 1) {
	$channel[$v] = NewSpeechChannel($Voice{'Zarvox'}) or die $^E;
}

for $note (0..$#notes + $partStart1 + 1) {
 	if ($note < $#notes + 1) {
  		$pitch0 = $scalePattern[$notes[$note] + 7] + $firstNote;
 		if ($pitch0 && $lyrics[$note]) {
 			SetSpeechPitch $channel[0], $pitch0;
 			SpeakText $channel[0], $lyrics[$note];
 		}
 	}
	if ($note > $partStart1) {
		$note1 = $note - $partStart1 - 1;
		$pitch1 = $scalePattern[$notes[$note1] + 14] + $firstNote;
		if ($pitch1 && $lyrics[$note1]) {
			SetSpeechPitch $channel[1], $pitch1;
			SpeakText $channel[1], $lyrics[$note1];
		}
	}

 	select(undef, undef, undef, .22);
}

while (SpeechBusy()) {}
for $v (0..$parts - 1) {
	DisposeSpeechChannel $channel[$v] if $channel[$v];
}




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