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

[MacPerl] HAL Lives!



Okay, so it's kinda hokey.  It will never do anything useful.

There are parts missing, and you'll need to collect them to make it work.

I've still got Dave Seay's code for singing "Daisy Bell," but neither permission nor inclination to adapt it.

The speech seems to clobber the QuickDraw calls for displaying the PICT, which doesn't get drawn until after the speaking is done (although the color fade works as expected). Is there a work-around for this?  A way to hide the desktop from within MacPerl?

A plainDbox(), instead of the floatProc() would be nice, but until I get an event handler written (or someone else steps forward with one) (click on the "HAL 9000" logo to close?)...

$65,000 question: has anyone ever done anything with SpeechRecognition.pm?

How to detect monitor resolution, and center HAL in the screen, regardless?

HAL's UI has the baleful red camera 'eye' flanked by multiple 'displays.' To get the full effect this will need at least four seperate simultaineous graphics windows two to each side, running various stuff (QuickTime Movies, animations, ideas anyone?). (actually, the Movie has HAL with EIGHT displays, but that's pushing it, I think).

#!perl -w

# hal9000.plx
# Talking HAL 9000 demo
# cobbled together by Brian McNett <brianmc@telebyte.net>
#
# practically guaranteed not to work "out-of-the-box!"
# 
# needs:
#    ColorGamma.pm
#    HAL 9000.pict
#
# ColorGamma.pm only written for MacPPC
# Mac68KCFM users should consult with
# Arved Sandstrom <Arved_37@chebucto.ns.ca> 
#
# ask program author about HAL 9000.pict
#
# or find neat HAL 9000 stuff at:
# http://www.tbid.com/toybox/
# or
# http://www.liv.ac.uk/~nce/personal/hal_9000.htm
#
# this last one has startup screens in various sizes
# which could easily be massaged to take the place
# of HAL 9000.pict (thus insuring that I've violated
# no copyrights (that burden falls to others))
#
# to do:
#
# Event Handling!  Right now, when the opening speech ends
# nothing else really happens.  HAL should do something when
# the user clicks inside the window. What, I don't know yet.
# Maybe HAL should sing "Daisy Bell?"

use Mac::Windows;
use Mac::QuickDraw;
use Mac::Events;
use Mac::Speech;
use ColorGamma;

my $normal = new_GIHdl();
my $grayish = new_GIHdl();

$gray = new RGBColor 0x6666,0x6666,0x6666;
$speech = <<EOS ;
Good morning Doctor Chand-ra. I'm ready for my first lesson.
EOS
$speaker = "Fred";

die "Bad Start" if StartFading($normal);

$grayish = CalcFadeToColor( $normal, $gray, 3, 5 );
FadeToGamma( $grayish, 20, quadraticFade );
DisposeGammaRef( $grayish );
Wait(50);

FadeToColor( $gray, 50, inverseQuadraticFade );	
Wait(10);

FadeToBlack( 30, quadraticFade );

&setup_hal;

&give_speech;

FadeToGamma( $normal, 100, linearFade );
Wait(10);

StopFading( $normal, 1 );

while ($win->window()) {
		WaitNextEvent();
		}

sub setup_hal {
$style = floatProc();
$title = 'HAL 9000';
$winr = Rect->new(350, 100, 470, 450);
$win = MacWindow->new(
		$winr, $title, 1, $style, 1
		);
$win->sethook('redraw' => \&draw_it);
}



sub draw_it {
my($p, $r);
		{
		local $/;  # slurp mode /

# path is hard-coded.  You'll have to change it.

		open(PICT, "MyrmiDonna:Applications:HAL Ÿ:hal9000 Ÿ:HAL 9000.pict") or die $!;
		$p = PicHandle->new(substr(<PICT>, 512));
		$r = $p->picFrame();
		DrawPicture($p, OffsetRect($r,
			($r->left()), ($r->top())
			));
	}
}

sub give_speech {
	if (! $speaker) { $speaker = "Fred" }
	$voice = $Voice{$speaker};
	$channel = NewSpeechChannel($voice) or die $^E;
		SpeakText($channel, $speech) || die $^E;
		while (SpeechBusy()) {}
		DisposeSpeechChannel($channel);
		$speech=$speaker="";
}

sub Wait {
	my $numTicks = shift;

	$start = TickCount();
	1 while (TickCount() - $start < $numTicks);
}

#end block
END {
	$win->dispose() if (defined($win));
	}



# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


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