Subject:
|
Re: Playing music (Was: Auld Lang Syne for RCX)
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Mon, 4 Jan 1999 23:09:57 GMT
|
Viewed:
|
1371 times
|
| |
| |
I recall somebody (Kekoa?) stating that the RCX continues processing
asynchronusly while notes are queued up. Maybe the RCX can only queue 8 notes
at a time thusly you might be able to tell it to play the first 8 all in a
row then wait the amount of time for those 8 to play, THEN send the next 8
this would shorten your code significantly yes?
Ben Kimball wrote:
> > For example, instead of this:
> >
> > PlayNote( A, time );
> > PlayNote( B, time );
> > [...]
> >
> > Do this:
> >
> > PlayNote( A, time );
> > Pause( time );
> > PlayNote( B, time );
> > Pause( time );
> > [...]
>
> Funny, I ran into this exact thing last night. I think there's something
> a little more subtle going on with the timing, however. Maybe someone who
> knows the hardware can help.
>
> I first wrote a little program to play an ascending C Major scale
> starting at C3. No problem, even without the waits. I noted that there
> were only 8 notes in my pattern. When I added seven more, descending back
> down the CM scale, the latter notes did not play at all (i.e., there was
> no change) until I added the waits. The RCX would play 8 and only 8 notes
> of any given pattern if no waits were specified (at this point, I'm only
> testing the case in which every note has the same duration).
>
> So, armed with the newfound knowledge that waits were necessary, I wrote
> another little app to play the opening notes of a simple Bach minuet (NQC
> 1.0b4):
>
> #define TEMPO 120
>
> #define GetSixteenth(n) ((1500 / TEMPO) * n)
>
> #define EIGHTH_NOTE (GetSixteenth (2))
> #define QUARTER_NOTE (GetSixteenth (4))
> #define HALF_NOTE (GetSixteenth (8))
>
> task main
> {
> PlayNote (587, QUARTER_NOTE);
> Sleep (QUARTER_NOTE);
> PlayNote (392, EIGHTH_NOTE);
> Sleep (EIGHTH_NOTE);
> PlayNote (440, EIGHTH_NOTE);
> Sleep (EIGHTH_NOTE);
> PlayNote (494, EIGHTH_NOTE);
> Sleep (EIGHTH_NOTE);
> PlayNote (523, EIGHTH_NOTE);
> Sleep (EIGHTH_NOTE);
> PlayNote (587, QUARTER_NOTE);
> Sleep (QUARTER_NOTE);
> PlayNote (392, QUARTER_NOTE);
> Sleep (QUARTER_NOTE);
> PlayNote (392, QUARTER_NOTE);
> Sleep (QUARTER_NOTE);
> }
>
> If you listen carefully, you'll note that the final two notes do not last
> a full second, as they should. Instead, they're abbreviated. This is
> especially noticeable when you change the note duration of the last two
> notes to EIGHTH_NOTE, leaving the Sleep value at QUARTER_NOTE.
>
> Any ideas?
>
> Cheers,
> Ben
>
> --
> Ben Kimball <mailto:ben@fusiondev.com>
> Fusion Development <http://www.fusiondev.com/>
> Custom Intranet Solutions P.O. Box 204325, Austin TX 78720-4325
> Visit the siphonFAQ! <http://siphon.scripting.org/siphonFAQ/>
--
Technical Support requests should be sent to support@opendisc.com
Joe Greene
Technical Support
OpenDisc Systems, Inc.
Boulder, Colorado, 80301-2442 USA
303-546-0460
Joe_Greene@OpenDisc.Com
|
|
Message is in Reply To:
| | Playing music (Was: Auld Lang Syne for RCX)
|
| (...) Funny, I ran into this exact thing last night. I think there's something a little more subtle going on with the timing, however. Maybe someone who knows the hardware can help. I first wrote a little program to play an ascending C Major scale (...) (26 years ago, 28-Dec-98, to lugnet.robotics)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|