[Haskell-cafe] music-related problem

Michael Mossey mpm at alumni.caltech.edu
Mon Jul 5 04:43:44 EDT 2010

erik flister wrote:
 >     Michael Mossey wrote:
>     Regarding my use of Rational, it's because I'm representing
>     *notated* durations or positions in time, which are always fractions
>     of integers. Suppose I give the command to my program to play via
>     midi everything from bar 1 beat 1 to bar 2 beat 2 1/2. I want to use
>     Rational so I know 2 1/2 means 2 1/2 and not 2.49999999999. 
> i wasn't suggesting anything Numeric for durations -- those are NoteDurs 
> like (Dotted $ Triplet Half).  you don't need numerics until resolving 
> temporal locations, like milliseconds or subdivisions of a beat.  those 
> may be irrational numbers (consider if the tempo is irrational, or tiny 
> random jitter in timing) -- though it's a totally pedantic point on my 
> part and realistically won't matter.  ;)

We must be addressing different problems. My software doesn't have much 
interest in the concept of eighth notes or dotted notes.

What I want to do is process a musical document to answer questions like this:

   - what notes have onset times between measure 1 beat 1 and measure 1 beat 3?

   - organize the document into verticals: notes that occur at the same 
time in any part

   - what notes finish sounding before measure 4?

In music, the passage of time has two meanings. One meaning is provided by 
the notation: on what beats notes occur and how they last (in terms of 
beats). This is independent of tempo, rit, accel. Call this "score time". 
The other meaning is "real-world" performance in which tempo, rit, accel, 
trills and tremolos are realized. Call this "real time".

For the first meaning, my program will find it simple and useful to 
represent time as measure (Int) and beat (Rational --- or perhaps anything 
in class Fractional (I have to study this more)). If I tried to represent 
"score time" as eighth notes or whatever it would drive me crazy. I have no 
need to do that. (Note that this level of time representation is not 
intended for a human interface.)

Score time can involve fractions composed from numbers greater than 
four---like 7-tuplets. But to my knowledge, there is no way to notate 
something that cannot be represented by a fraction.

"Real time" is better represented as floating point. It is derived from 
tempos and tempo maps.


More information about the Haskell-Cafe mailing list