[LAU] transform midi Control Change 7 into velocity events?

Philippe Hezaine philippe.hezaine at free.fr
Fri Nov 21 07:27:18 EST 2008


Dominic Sacré a écrit :
> On Thursday 20 November 2008 23:49:46 Philippe Hezaine wrote:
>>> I'm not sure mididings is the right tool for the job. The Python code
>>> to transform the events would be quite simple, but mididings doesn't
>>> support reading/writing MIDI files (yet?). You could of course use a
>>> separate MIDI player/recorder, and route the events through mididings,
>>> but you'd lose all meta information (tempo, time signature, etc.) from
>>> the original file.
>> Yes. I was sucessfull to loop a midi file with Jack and Rosegarden. The
>> outputs was routed through mididings and went back to Rg for a new
>> record on a new track. But it was not for this purpose and i didn't look
>> for the meta information.
>> But for now, if i have a copy about these informations may be i can try
>> again this experience? It isn't a piece of music, only a succession of
>> drums patterns. I can organize them to avoid different time signature...
> 
> Recording to a new track in the same Rosegarden session is actually a very 
> good idea, I didn't think of that... You wouldn't lose anything that way.
> 
> As for the transformation, something like this should do the trick (not 
> thoroughly tested):
> 
> from mididings import *
> 
> class Volume2Velocity:
>     def __init__(self):
>         self.vol = {}
>     def __call__(self, ev):
>         if ev.type_ == CTRL and ev.param == 7:
>             self.vol[ev.channel] = ev.value
>             return None
>         elif ev.type_ == NOTEON and ev.channel in self.vol:
>             ev.velocity = self.vol[ev.channel]
>         return ev
> 
> run(Call(Volume2Velocity()))
> 
>>> As far as I can see, all tracks in your MIDI file are on the same
>>> channel, so CC #7 messages on one track will affect the other tracks as
>>> well. You should probably assign a different channel to each track.
>> No. Like i have said these are drums patterns written by Lilypond. After
>> the famous transformation i could join all the tracks in one if i want.
> 
> Yes, but then you need to do the transformation one track at a time. If you 
> play multiple tracks through the same MIDI port on the same channel, some 
> notes will get the wrong velocity (unless every note event is immediately 
> preceded by a volume change).
> 
> 
> Cheers,
> 
> Dominic

Thanks too much for your time and your information.

Bingo! I think it's the first time we get from a Lilypond file a midi 
file with velocities values. But for all you're right. Note that I 
cannot get a clean file with a loop in the same Rosegarden's session. I 
have freezes and even crashes. Hence i output the midi from Rg through 
mididings -> recording in Muse.
The raw outcome is in attach.
1) You could see a little latency in the attacks.
2) I lose the Lilypond header
3) Strangely i can't open the new file with the drum editor in 
Rosegarden though it is on channel 10. (meta information?)

Anyway, thanks so much.

Have fun.
-- 
   Phil.
Superbonus-Project (Site principal) <http://superbonus.project.free.fr>

Superbonus-Project (Plate-forme d'échange):
<http://philippe.hezaine.free.fr>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Merengue-avec-velocite.mid
Type: application/octet-stream
Size: 4093 bytes
Desc: not available
Url : http://lists.linuxaudio.org/pipermail/linux-audio-user/attachments/20081121/a4a1ddbc/attachment.obj 


More information about the Linux-audio-user mailing list