[Haskell-cafe] music-related problem
Michael Mossey
mpm at alumni.caltech.edu
Sun Jul 4 20:58:00 EDT 2010
erik flister wrote:
>
> That's what I want to do. I'm asking about a good way to write the
> algorithm that traverses the notes and reconstructs the document
> with the correct duration in each note.
>
>
> why isn't this as simple as
Erik,
I'm learning from your code examples, but I don't understand how this
turned into an argument about simplicity. I never said it was complex. I do
admit it's probably simpler than my initial approach.
Maybe I should take a step back and describe my goals. I am experimenting
with algorithms for putting a "human touch" on midi playback. I will use
Finale to enter the music, then export as MusicXML to my software. Getting
from MusicXML---which is a complex format that encompasses everything from
notational subtleties to performance subtleties---into a relatively simple
internal representation is truly the easy part. The real meat of my project
is the code to perform the music.
> foldr'ing something like this over the xml
> notes (assuming monophony and that they are listed in order of start time)?
In a MusicXML document, you can't assume
- that the notes are in order of start time
- monophony
- that two tied notes are immediately adjacent in the data
None of that is true. I conceive of this problem as multiple passes. On the
first pass, I translate XML notes into a convenient internal
representation, on the second pass sort them, then make a pass to figure
out ties. Whether this is the best approach, I do not know. I am here to learn.
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. (*) However, *performed* times are a
matter of tempo, accel, rit, trills, tremolo, arpeggio etc., and are
probably best conceived as Real.
I don't quite get this:
> forall x. (Real x, Fractional x) => x if you're picky.
Thanks,
Mike
(*) I may want to use the location of a note (bar and beat) as the key in a
Map, which I believe should be done with Rational and not Float.
More information about the Haskell-Cafe
mailing list