Saturday 19 January 2013

Adding dynamics to MIDI files

My current setting for creating a MIDI file for practicing duets was not very good, and the resulting files were always poor in dynamics, because it was quite a long and tedious process. So I asked in LAU the following:

"[...] I'm looking for an alternative way for note input. I am hoping for something like the following:

1. I just enter the notes, regardless of the duration of each of them.
2. Then I go into a second phase, where (using the PC keyboard or a MIDI
   keyboard) I just worry about the rhythm (the note durations). Every
   time I press a new key in the keyboard the program would play the
   next note from the ones entered in step 1. and record its duration. I
   don't care about how the score will look with these durations. I just
   want an easy way to create a more musical accompaniment. This way, at
   this step I only have to worry about the durations of each note.
[...]

Is there any MIDI editor that would let me do something like this?"

I ended up following the suggestion of using Pure Data. Despite never having used it, the YouTube tutoring videos by Rafael Hernandez are great, and after viewing the first 10 (about 90 minutes), the impatient guy in me had to code something and I managed to get a proof-of-concept implementation of the above. The code is horrible, and I'm sure it can be done much more efficiently and in a more elegant way (if any reader has suggestions, they are very welcome!), but for the moment this works.

The code itself is available, and  it looks like this:



I'm sure it hurts the eyes of any PureData programmer, but bear in mind that my exposure to PureData has been about two-three hours.


So, how does it work?  First, let's get everything connected (the MIDI keyboard to Pure Data, and Pure Data both to Midi Through and to FluidSynth):



Then, in step 1 (by clicking the toggle "To get notes from keyboard") and "Initialize list", we enter the notes of a melody, without worrying about rhythm or velocities. Then, in step 2, by selecting the other toggle (without a name), the notes will be played in the order of the notes just recorded, regardless of which keys I press, but recording their rhythm and velocities. A mini-demo can be seen below (also uploaded to https://vimeo.com/57762697):


If I send that to, for example, MusE, the resulting score is quite different to the original score, but it has the rhythm and the velocities as entered in the second step:



Then, the tweaks to do are much less than for my original setting, and it involves writing chords, and perhaps changing a few note durations using the piano roll.

This is certainly a big improvement in my MIDI recording from my previous ways.



3 comments:

ygro said...

Hi, That's seems to be lot of hard work. Have you heard of the abc notation? abc notation support harmony as well. check out

http://abcnotation.com/forums/viewtopic.php?f=2&t=43

i.e., http://www.lesession.co.uk/abc/abc_extensions.htm#voices

ygro said...

of course, Abc2midi program can be used to convert abc music notation files to MIDI files,

http://ifdo.pugmarks.com/~seymour/runabc/abcguide/abc2midi_guide.html

angelv said...

Hi ygro,

I've never used abcnotation, though I was aware of it. But I don't see how ABC notation can help with adding dynamics to MIDI files.