[Csnd] MIDI Monophonic Legato?
Date | 2011-09-11 05:04 |
From | Jim Aikin |
Subject | [Csnd] MIDI Monophonic Legato? |
I'm trying to debug one of the examples in QuteCsound. This example (Formant_Synth.csd) pretends to play monophonically; that is, only one pitch is heard at any given time. But in fact, each new keyboard note triggers a new Csound event 3 seconds long. So if you play several notes in succession, there's a buildup of sound and also a buildup of CPU usage, leading to overload. Very bad. I'm at a loss how to write a Csound instrument that will respond to MIDI input in monophonic legato mode. That is, new MIDI notes should not create new instances of the instrument; there should be a take-over of an existing note if one is still sounding, and a new instrument instance only if NO instance is currently active. Doing this from the score is easy. But how would I do it in real time in response to MIDI input? Something involving xtratim and release, perhaps ... but what? Or something involving schedkwhen's kmaxnum argument? Suggestions would be welcome. --Jim Aikin -- View this message in context: http://csound.1045644.n5.nabble.com/MIDI-Monophonic-Legato-tp4790887p4790887.html Sent from the Csound - General mailing list archive at Nabble.com. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-11 06:37 |
From | "Colman O'Reilly" |
Subject | Re: [Csnd] MIDI Monophonic Legato? |
Credit for this definitely goes to Iain McCurdy... I could only find an example that I derived from his original. I tried to cut out all but what was helpful - sorry if there is some oversight. I think something like this would get the traditional Monophonic synth quality that you are looking for. I hope it is of some help.
<CsoundSynthesizer> <CsOptions> </CsOptions> <CsInstruments> sr = 44100 kr = 4410 ksmps = 10 nchnls = 2 0dbfs = 1
instr 1 gkbend pchbend 0, 2 imidinn notnum gkfrq = cpsmidinn(imidinn+gkbend) giampmidi ampmidi 1 gkporttime = 0 ;; Glide Time gkenv madsr .1, 1, 1, 0 schedkwhen 1, 0, 1, 2, 0, 3600 endin
instr 2 kporttime linseg 0, (.01), 1, (1), 1 kporttime = kporttime * gkporttime kfrq1 portk gkfrq, kporttime kreltrig release gkinstrcount active 1 if gkinstrcount!=0||kreltrig=1 kgoto GO turnoff GO: aout oscili giampmidi, kfrq1, 1 outs aout, aout endin </CsInstruments> <CsScore> f1 0 16384 10 1 i1 0 9999 </CsScore> </CsoundSynthesizer> On Sun, Sep 11, 2011 at 12:04 AM, Jim Aikin <midiguru23@sbcglobal.net> wrote: I'm trying to debug one of the examples in QuteCsound. This example Colman O'Reilly | colman@csoundforlive.com | www.colmanoreilly.com
|
Date | 2011-09-11 10:52 |
From | Victor Lazzarini |
Subject | Re: [Csnd] MIDI Monophonic Legato? |
Attachments | moogm.csd |
Jim, the way to do this is to pick up all MIDI note messages in one instrument and then control another one. Ian's example shows one way of doing this. The attached CSD works using the same principle, but in a different way. Note that if you also want to add a typical analogue ADSD envelope, you can also use this UDO I proposed here a while ago (in response to one of your questions): http://www.csounds.com/udo/displayOpcode.php?opcode_id=131 Regards Victor Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" On 11 Sep 2011, at 05:04, Jim Aikin wrote: > I'm trying to debug one of the examples in QuteCsound. This example > (Formant_Synth.csd) pretends to play monophonically; that is, only > one pitch > is heard at any given time. But in fact, each new keyboard note > triggers a > new Csound event 3 seconds long. So if you play several notes in > succession, > there's a buildup of sound and also a buildup of CPU usage, leading to > overload. Very bad. > > I'm at a loss how to write a Csound instrument that will respond to > MIDI > input in monophonic legato mode. That is, new MIDI notes should not > create > new instances of the instrument; there should be a take-over of an > existing > note if one is still sounding, and a new instrument instance only if > NO > instance is currently active. > > Doing this from the score is easy. But how would I do it in real > time in > response to MIDI input? Something involving xtratim and release, > perhaps ... > but what? Or something involving schedkwhen's kmaxnum argument? > > Suggestions would be welcome. > > --Jim Aikin > > > -- > View this message in context: http://csound.1045644.n5.nabble.com/MIDI-Monophonic-Legato-tp4790887p4790887.html > Sent from the Csound - General mailing list archive at Nabble.com. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2011-09-11 17:10 |
From | Jim Aikin |
Subject | [Csnd] Re: MIDI Monophonic Legato? |
That's a good first approximation, Colman. Thanks! There are still a few issues, which I'm going to try to tackle. The oscillator phase is reset with each new note-on, which causes clicks. And the portamento doesn't work, because the pitch glides up from and back down to 0Hz at the beginning and end of a line of notes. I'l have to study the code to see how to fix that. I'm surprised -- this file uses global values without defining them in the orchestra header. I didn't think that was legal. --JA -- View this message in context: http://csound.1045644.n5.nabble.com/MIDI-Monophonic-Legato-tp4790887p4791812.html Sent from the Csound - General mailing list archive at Nabble.com. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-11 19:10 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Re: MIDI Monophonic Legato? |
My design should have no clicks due to phase reset, because the oscillator is always on (as you would have in an analogue synth). It does lack an envelope, but that can be added on. Victor On 11 Sep 2011, at 17:10, Jim Aikin wrote: > That's a good first approximation, Colman. Thanks! > > There are still a few issues, which I'm going to try to tackle. The > oscillator phase is reset with each new note-on, which causes > clicks. And > the portamento doesn't work, because the pitch glides up from and > back down > to 0Hz at the beginning and end of a line of notes. I'l have to > study the > code to see how to fix that. > > I'm surprised -- this file uses global values without defining them > in the > orchestra header. I didn't think that was legal. > > --JA > > -- > View this message in context: http://csound.1045644.n5.nabble.com/MIDI-Monophonic-Legato-tp4790887p4791812.html > Sent from the Csound - General mailing list archive at Nabble.com. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-12 01:27 |
From | Jim Aikin |
Subject | [Csnd] Re: MIDI Monophonic Legato? |
Thanks, Victor. I took your concept and ran with it. I simplified it by getting rid of the control panel, but then I added a monophonic filter envelope and velocity response. Here's what I ended up with: sr = 44100 ksmps = 4 nchnls = 2 0dbfs = 1 alwayson "ToneGenerator" giSaw ftgen 0, 0, 8192, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 gkCheck init 0 gkPitch init 260 instr 1 ; activated from MIDI channel 1, tracks the pitch gkPitch cpsmidib 2 gkCheck = 1 endin instr ToneGenerator kon active 1 ; check whether any instances of instr 1 are active ; velocity sensing -- only accept a new velocity input if ; there's no note overlap (if kon == 1) -- scale the velocity ; to a range of 0.2 - 1.0 kvel init 0 kstatus kchan kdata1 kdata2 midiin if kstatus == 144 && kdata2 != 0 && kon == 1 then kvel = kdata2 * 0.006 + 0.2 endif ; amplitude control kampraw init 0 if kon != 0 then kampraw = 0.5 * kvel kenvramp = 50 ; fast attack else kampraw = 0 kenvramp = 1 ; slow release endif kamp tonek kampraw, kenvramp ipitchglide = 4 ; higher numbers cause faster glide kpitch tonek gkPitch, ipitchglide ; oscillators idetune = 0.3 asig1 oscil kamp, kpitch + idetune, giSaw asig2 oscil kamp, kpitch, giSaw asig3 oscil kamp, kpitch - idetune, giSaw asig = asig1 + asig2 + asig3 ; if no MIDI keys are pressed, reinit the filter envelope if gkCheck == 1 && kon == 0 then reinit filtenv endif ifiltdec1 = 1.5 ifiltdec2 = 3 filtenv: kfilt expseg 500, 0.01, 8000, ifiltdec1, 2000, ifiltdec2, 500, 1, 500 rireturn ; smooth the filter envelope so a reinit won't cause it to jump -- ; also have the cutoff track the keyboard and velocity kfilt tonek (kfilt * (0.6 + kvel * 0.5)) + kpitch, kenvramp afilt lpf18 asig, kfilt, 0.3, 0.1 outs afilt, afilt endin |