Difference between revisions of "Sound.duration"

From MiniScript Wiki
Jump to navigation Jump to search
m
m (→‎Musician's Note: Renamed section to "Usage Notes")
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<c>[[Sound]].duration</c> controls for how long a sound will play in seconds.
+
<c>[[Sound]].duration</c> controls how long a sound will play in seconds.
  
== Musician's Note ==
+
=== Usage Notes ===
 
Mini Micro does not by default give you duration in musical terms. A good function for calculating this is:
 
Mini Micro does not by default give you duration in musical terms. A good function for calculating this is:
 
      
 
      
Line 69: Line 69:
  
 
See also: <c>[[Sound.init]]</c>
 
See also: <c>[[Sound.init]]</c>
 +
 +
[[Category:Mini Micro]]

Latest revision as of 16:15, 7 May 2020

Sound.duration controls how long a sound will play in seconds.

Usage Notes

Mini Micro does not by default give you duration in musical terms. A good function for calculating this is:

CalculateNote = function(tempo, noteValue)
    60 / tempo * noteValue
end function

For tempo, use the standard tempo in beats per minute (BPM) for how fast you want your music to be (for example, a march is typically 120 BPM, Adagio would be around 66-76 BPM, and Allegro would be around 120-168 BPM.)

Note value can be determined by the type of note you want to reproduce:

Note Type Value
Sixteenth Note 0.25
Eighth Note 0.5
Quarter Note 1.0
Half Note 2.0
Whole Note 4.0

Dotted notes take the value of the original note and adds half to it:

Note Type Value
Dotted Sixteenth Note 0.375
Eighth Note 0.75
Dotted Quarter Note 1.5
Dotted Half Note 3.0
Dotted Whole Note 6.0

Triplets, likewise, are 1/3 of the value above it (so a triplet eighth note is a third the value of a quarter note):

Note Type Value
Triplet Sixteenth Note 0.165
Triplet Eighth Note 0.333
Triplet Quarter Note 0.667
Triplet Half Note 1.333

See also: Sound.init