To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 1848
1847  |  1849
Subject: 
Playing music (Was: Auld Lang Syne for RCX)
Newsgroups: 
lugnet.robotics
Date: 
Mon, 28 Dec 1998 18:40:03 GMT
Original-From: 
Ben Kimball <BEN@FUSIONDEV.stopspammersCOM>
Viewed: 
1062 times
  
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/>



Message has 1 Reply:
  Re: Playing music (Was: Auld Lang Syne for RCX)
 
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 (...) (25 years ago, 4-Jan-99, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR