Re: bell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hmmm...

Well, sometimes the speaker doesn't work as it should.
Sound() is a very tricky function to call, not to say
crappy.
Sometimes your sound keeps playing even when you tell
it to stop, etc.

But what I'd suggest you'd do, is get rid of 'sleep()'
because it's not that usefull for idling the cpu (ie.
for doing nothing for some time).
What you should do is write a routine like this:

procedure wait(atom howlong)

atom t
t = time()
while t+howlong >= time() do
end while

end procedure


And then use it like this:

global procedure bell()
sound(600)
wait(0.5)
sound(0)
end procedure


Why is this better than using sleep() or something?
Well, because what if you'd like to do something else
while playing the sound?

With your own routine you can easily rewrite it to
this;

procedure wait(atom howlong,sequence proc,sequence
args)

atom t
t = time()
while t+howlong >= time() do
    call_proc(routine_id(proc),args)
end while

end procedure

See?
Now you can use it like this:

global procedure bell()
sound(600)
wait(0.5,"renderFrame",{Screen,1,1})
sound(0)
end procedure

It's calling procedure 'renderFrame' while playing the
sound...

This would be usefull in a game or simulation...


Heh, hope I helped.

Mike The Spike


> On Tuesday 24 July 2001 12:17, gwalters at sc.rr.com
> wrote:
> 
> > Should this not work? I get no sound from my
> computer..thanks for your help
> >
> > global procedure bell()
> >  sound(600)
> >  sleep(.5)
> >  sound(0)
> > end procedure
> 
> It shouldn't even 'compile' - sleep takes an
> integer.
> 
> If you change that to sleep(1), it will run on DOS,
> but not on Windows 
> or Linux.
> 
> Regards,
> Irv
> 
> 


>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu