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

[MacPerl] MacPerl sings a 'Camptown Races' in its nativelanguage, almost



I have a PowerCenter 120 (604). The tempo of the song is set on line 14.
It's a bit sluggish on my computer. How is it on faster or slower computers?

David Seay
http://www.mastercall.com/g-s


#!perl

use Mac::Speech;

$noteNames =    "c  d  e  f  g  a  b  C  D  E  F  G  A  B  C1";
$scalePitches = "48,50,52,53,55,57,59,60,62,64,65,67,69,71,72";
@noteNames = split("  ",$noteNames);
@scalePitches = split(",",$scalePitches);
$pitches = @scalePitches;
for ($p = 0; $p < $pitches; $p++) {
	$pitch{$noteNames[$p]} = $scalePitches[$p];
}

$tempo = 85000; # increase the value if song is too fast or ends of words
are clipped

# NOTE DURATIONS
$dur{e}   = .5;   # eighth note
$dur{de}  = .75;  # dotted eighth note
$dur{q}   = 1;    # quarter note
$dur{dq}  = 1.5;  # dotted quarter note
$dur{h}   = 2;    # half note
$dur{he}  = 2.5;  # half note + an eighth
$dur{dh}  = 3;    # dotted half note
$dur{dhe} = 3.5;  # dotted half note + an eighth
$dur{w}   = 4;    # whole note


# FORMAT FOR '$song' = syllable pitch duration
$song = ". c h"; # helps reduce sluggishness of first note
$song.= ",camp g q,townn g q,ray e q,sis g q,sing a q,this g q,sonnng e h,";
$song.= "do e q,daa d dh,do e q,daa d dh,";
$song.= "five g q,mile g q,ray e de,sis g q,all a q,day g q,lonnng e h,";
$song.= "oh d dq,do e de,da d q,day c w,";

$song.= "go c q,na c e,run e q,all g q,night C w,";
$song.= "go a dq,na a e,run C q,all a q,day g w,";
$song.= "bet g q,my g q,muh e e,nee e e,on g e,the g e,bob a q,tail g q,nag
e dh,";
$song.= "some d de,bah d e,dee d e,bet e dq,on d e,the d e,bay c w";

@song = split(",",$song);
$songNotes = @song;

$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,$dur) = split(" ",$song[$n]);

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



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