finding the length of a note

Discuss all kind of algorithms and data structures from their mathematical and programming sides.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

finding the length of a note

Postby schloob » Sat Apr 24, 2004 10:17 am

if i have the tempo, and the note (1/4, 1/8, whole, half, etc) how do i find the length of a note in milleseconds

time=(tempo/60.0) * (1.0/note) * 1000;

thats all i have but, you guess it, it doesnt work..

btw, note = 4,8,16,1,2 so i do 1.0/note

im searching as we speak/type so dont say im not doing anything, thanks!
:]
User avatar
schloob
 
Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

Postby devil_slayer » Sat Apr 24, 2004 10:42 am

You're calculations are a bit wrong.

Now, the tempo can be expressed in severa ways. One of the more common ways is to represent it as the ammount of 1/4 notes per minute.

The one quarter note has a length of:
t=60000/tempo miliseconds

the 1/8 is a half of that and 1/2 is double that:
t=(note/0.25)*60000/tempo

However, if you have the tempo expressed as a multiplicity of a note of some other type, like 1/2 note the eq. changes.

The final equation:
t=(note/temponote)*60000/tempo miliseconds
User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND

Postby schloob » Sat Apr 24, 2004 11:13 am

hmm

this seems to work every time.. o_O

time=((60.0/tempo)) * (1.0/note*4) * 1000;
:]
User avatar
schloob
 
Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

Postby devil_slayer » Sat Apr 24, 2004 11:31 am

That is because they are practiaclly equivelet, except for the fact that you use a constant value 1/4 in place of my variable temponote. It is okay if you wish to express the tempo in terms of one-quarter notes only.
User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND


Return to Algorithms & Data Structures

Who is online

Users browsing this forum: Exabot [Bot] and 0 guests