Re: pythonAPI: passing midi
Date | 2006-03-18 21:37 |
From | "Michael Gogins" |
Subject | Re: pythonAPI: passing midi |
This example DOES use the dynamic voice allocation facility, which is automatic. Regards, Mike ----- Original Message ----- From: "Atte André Jensen" |
Date | 2006-03-20 08:04 |
From | Atte André Jensen |
Subject | Re: pythonAPI: passing midi |
Michael Gogins wrote: > This example DOES use the dynamic voice allocation facility, which is > automatic. Ok, my fault. What I meant was that AFAICS it will take at least some coding to get the same behaviour with score events that is automatically there with midi events. For instance that "press note A, press note B, release note A, release note B" works "as expected" that is like on a piano. But I very rarely use score events so maybe I should play a bit with it and see what happens... -- peace, love & harmony Atte http://www.atte.dk |
Date | 2006-03-20 09:55 |
From | Oeyvind Brandtsegg |
Subject | Re: pythonAPI: passing midi |
The following is my simplified csound code to do polyphonic instrument on/off. You asked about how to do this from the host (e.g. python), the example does show how I can treat midi events and score events in a relatively similar way. The instrument to be played contains an amp envelope that uses e.g. linenr to create a release segment for the envelope. The linenr opcode gently allows both score (defined p3) and realtime (infinite p3). The midi note number is used to set a fractional instr number, and this give you control over which specific note you want to turn off when you release a midi key. I would expect a click problem to occur when playing rapid notes on the same key, but it does not sound like that is happening for me. If this becoes a problem, you might use an additional fractonal "counter" to separate different instances of the same key on the same instrument. Also, the example does not differentiate between midi channels (e.g. all midi channels are routed to the same instr. This could easily be coded.. csound code below. best Oeyvind ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; instrNum = 1004 ; instrument to play midi notes kstatus, kchan, kdata1, kdata2 midiin if kstatus == 144 kgoto noteon kgoto end noteon: knum = kdata1 kvel = kdata2 if kvel == 0 kgoto noteoff ; fractional instrument number, poly voice handling id kinstrNum = instrNum + (kdata1*0.001) event "i", kinstrNum, 0, -1, knum, kvel kgoto end noteoff: knum = kdata1 kvel = kdata2 ; fractional instrument number, poly voice handling id kinstrNum = instrNum + (kdata1*0.001) event "i", -kinstrNum, 0, 0.1, knum, kvel kgoto end end: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Date | 2006-03-20 11:49 |
From | Atte André Jensen |
Subject | Re: pythonAPI: passing midi |
Oeyvind Brandtsegg wrote: > csound code below. Thanks. That looks interresting, will have a look! -- peace, love & harmony Atte http://www.atte.dk |
Date | 2006-03-21 03:45 |
From | Iain Duncan |
Subject | Re: pythonAPI: passing midi |
> The instrument to be played contains an amp envelope that uses e.g. linenr to create a release segment for the envelope. The linenr opcode gently allows both score (defined p3) and realtime (infinite p3). That is similar to how I do my instruments as well. > The midi note number is used to set a fractional instr number, and this give you control over which specific note you want to turn off when you release a midi key. > I would expect a click problem to occur when playing rapid notes on the same key, > but it does not sound like that is happening for me. > If this becoes a problem, you might use an additional fractonal "counter" to separate different instances of the same key on the same instrument. The way I solve is a bit hackish but works very well for pianistic and legato sounds. By having one voice per potential note of polyphony, you can have an amp envelope instrument always on for each voice. A release triggers the release phase of the envelope. The amp envelope keeps track of what is happening and if it is getting clobbered by a subsequent note ( the desired behaviour ) instead of just starting a new note, it's amp envelope can very quickly go to zero and then back on. I use this technique to make monosynths, but it could easily be adapted for piano like sounds. You would have the overhead of 88 amp envelopes constantly running, but if this is meant to be an ideal situation for one player, I don't think that would be a big deal. It would mean that your cpu load would not spike no matter what you did on the piano, so perhaps that would be good. I think I may muck about with that scheme and pormidi to make an api example for realtime pianistic playing, it would be an interesting example in a number of ways and probably useful. Iain |