Matt Lester <[EMAIL PROTECTED]>
> I'm looking for some feedback on the 'most' accurate & consistant
> method of playing a click sound at a set tempo for a metronome style
> application.
> I've ... had the most success with the milliseconds. If anyone has
> any ideas of the best way to do this that would be great.

Hi Matt,

All methods are likely to break down if there is any other activity on
your computer.  Director regularly gives control back to the System, and
the System may be irregular about how long it takes to return control.
This means that, from time to time, you will experience a
longer-than-usual pause.  This is true even with Director 8's timeOut
objects.

(An extreme example occurred to me yesterday : at precisely midnight, a
dialog box opened asking me to register a program that I had installed
two weeks ago.  My Director movie was interrupted until I had dismissed
the dialog).

To ensure a strict beat, you might want to use a tight repeat loop.
This will prevent any other activity from occurring (except from an
occasional check from Director that you have not pressed the Control-.
key combination which halts playback).

Normally, using a tight repeat loop is not good practice.  In this case
it might be unavoidable.  The rest of your movie should be designed to
be compatible with this.  In particular, the movie will receive no frame
events (stepFrame, prepareFrame, enterFrame, exitFrame) while the
metronome is running.

If you need animation, this should be controlled from within the repeat
loop itself.  The more animation you require, the less regular your beat
is likely to be, since you will be re-introducing other activity.
However, you will be able to control exactly what other activity occurs,
and so you should be able to ensure that this activity is completed
before the next click is due.

I include a first draft approach below.  I have not used the D8 sound
Lingo, since you do not mention whether you are using D7 or D8.

Cheers,

James

------------------------------------------------------------------------

global gNextClick
global gClickDelay

on startMovie
  gNextClick  = the milliseconds
  gClickDelay = 200              -- 300 beats per minute
end

on startMetronome
  repeat while TRUE
    if the mouseDown then exit
    timeElapsed = the milliseconds - gNextClick
    if timeElapsed > 0 then
      gNextClick = gNextClick + gClickDelay
      puppetSound 1, "Click"
    end if
  end repeat
end startMetronome



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to