Csound Csound-dev Csound-tekno Search About

Re: MIDI event duration

Date1999-02-05 15:23
Fromthe Physicist
SubjectRe: MIDI event duration
> Hi,
> Id like to know if there is any way to get the duration of a MIDI event
> from a MIDI file from Csound itself (without MIDI2Csound...) to be used
> as a p3 field in the orchestra. Thanks in advance!

I would say that's not possible. MIDI just sends NOTE_ON, then
NOTE_OFF, no duration time. Why exactly do you need this duration time ?
For my MIDI instruments, I always use 'madsr' in combination with
'xtratim':

instr xxy
   kenvelope  madsr  ,,,
   xtratim 

   asignal oscil ... etc

   out  kenvelope*asignal
endin;

the note is turned on by the MIDI note_on event, runs through the
attack-decay cycle and stays on the volume given by sustain. It stays
there until it gets the MIDI note_off event. Then it decays for the time
given in release. Note that the instrument keeps running for the time
given in the 'xtratim' (extra time) opcode, then it's turned off.
Without the xtratim opcode, the instrument it switched off (with a
click...) as soon as it receives note_off.