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

Re: [MacPerl] MacPerl sings a 'Camptown Races' in its native language, almost



Note that in MacPerl 5.2.0r4, this:

$count = CountVoices();
for ($i = 0; $i++ < $count; ) {
 	$voice = GetIndVoice($i);
 	$desc  = ${GetVoiceDescription($voice)};
 	# some voices won't change pitch
 	# try 'Zarvox' or 'Pipe Organ' or 'Cellos' or 'Bad News'
	if ($desc =~ /Zarvox/) {
		$channel = NewSpeechChannel($voice)         or die $^E;

		for ($n = 0; $n < $songNotes; $n++) {
			($word,$note,$sharp,$dur) = split(" ",$song[$n]);

			SetSpeechPitch $channel, $pitch{$note}+$acc{$sharp};
			SpeakText $channel, $word               or die $^E;
			$d = int($tempo * $dur{$dur});
			for ($w = 0; $w < $d; $w++) { }
		}
		DisposeSpeechChannel $channel;
	}
}



can be changed to this:

# some voices won't change pitch
# try 'Zarvox' or 'Pipe Organ' or 'Cellos' or 'Bad News'
$voice = $Voice{Zarvox};
$channel = NewSpeechChannel($voice)         or die $^E;

for ($n = 0; $n < $songNotes; $n++) {
	($word,$note,$sharp,$dur) = split(" ",$song[$n]);

	SetSpeechPitch $channel, $pitch{$note}+$acc{$sharp};
	SpeakText $channel, $word               or die $^E;
	$d = int($tempo * $dur{$dur});
	for ($w = 0; $w < $d; $w++) { }
}
DisposeSpeechChannel $channel;


That is, %Voice is a tied hash that does the searching for a voice for you
(and caches the result, so it saves time if you use multiple voices in one
program).

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch