|
Hi List,
So I'm trying to make a simple audio file manipulation instrument that will "sustain" a note when a MIDI CC crosses a certain threshold. I was using the ihold opcode in an attempt to sustain rt midi data, but I noticed in the manual it says "a note of finite duration" so I added an event opcode instead. Still, however it doesn't seem to like that. I have tested it in MacCsound 1.2a5 (synchronized to CsoundLib 4.23f12 built on Mar 9 2005) and Csound5 on OS X (built from CVS May 16 2005). It performs identically on both with the exception of diskin/diskin2, respectively. The idea is that you can trigger a rt midi event using the keys, and at some point just make it "sustain" so as to have your hands free to mix it into something else. Every other function works as I would like it to, so it leads me to believe that I am misusing the program to some extent; hence why I am posting here at present. Here's my example: ( If you need some audiofile quickly, one can be found at http://nujazzbeats.spymac.net/audio/sample.aif ) <CsoundSynthesizer> <CsInstruments> sr = 44100 kr = 44100 ksmps = 1 nchnls = 2 maxalloc 1, 1 strset 6969, "/* audio file goes here */" gilen filelen 6969 instr 1 ;live audiofile dj ; init kpch ctrl7 1, 1, -12, 12 ;mod wheel controls pitch kpch = 2 ^ (kpch / 12) kbend pchbend ;pitchbend is the intended trigger kcue ctrl7 1, 7, 0, gilen ;volume slider controls index into audiofile ktrig trigger kbend, -1, 0 ; synth a1, a2 diskin 6969, kpch, i(kcue), 1 ;if Csound5, use diskin2 if (kbend == -3) then turnoff endif if (kbend >= 0) then event "i", 1, 0, gilen ;"a note of finite duration" ihold endif printks "\\nCue inSecs %f\\nTrigger %d\\nPitch %f\\n\\n", .5, kcue, kbend, kpch outs a1, a2 endin </CsInstruments> <CsScore> f0 600 e </CsScore> </CsoundSynthesizer> Any help / ideas / criticisms / pointers to relevant manual pages appreciated! -David -- Send bugs reports to [hidden email] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) To unsubscribe, send email to [hidden email] |
|
On 5/27/05 1:54 AM, David Akbari <[hidden email]> etched in stone:
> So I'm trying to make a simple audio file manipulation instrument that > will "sustain" a note when a MIDI CC crosses a certain threshold. I was > using the ihold opcode in an attempt to sustain rt midi data, but I > noticed in the manual it says "a note of finite duration" so I added an > event opcode instead. According to my copy of the manual, "[ihold is] Effective at i-time only; no-op during a reinit pass." So, sounds like ihold will only work in the initial init pass for a note. (I don't use Midi, so I do not know how it interacts with that). Also, I suspect your conditional statement is not working as you want: > if (kbend >= 0) then > event "i", 1, 0, gilen ;"a note of finite duration" > ihold > endif The if ... then condition is ignored during initialization but all opcodes inside the if block are inited anyways. (At least that is the way that I read the manual -- a simple test seems to confirm this). So the ihold is always executed. The correct way to do an i-time conditional is "if ... igoto". But I think what you really want is for a "khold" opcode to exist. What you might try is using the xtratim opcode to extend a midi note for some very long time. Then use turnoff as you are to end it later. (xtratim probably also only runs at i-time -- maybe it works with reinit though). Anthony Kozar [hidden email] http://akozar.spymac.net/ -- Send bugs reports to [hidden email] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) To unsubscribe, send email to [hidden email] |
|
> Also, I suspect your conditional statement is not working as you want: > >> if (kbend >= 0) then >> event "i", 1, 0, gilen ;"a note of finite duration" >> ihold >> endif > > The if ... then condition is ignored during initialization but all opcodes > inside the if block are inited anyways. (At least that is the way that I > read the manual -- a simple test seems to confirm this). So the ihold is > always executed. > > The correct way to do an i-time conditional is "if ... igoto". But I think > what you really want is for a "khold" opcode to exist. just to clarify on the if/then it works the same way as if/goto. if you have only i-rate variables in the if statement, then the if/then DOES do the conditional at i-time, but otherwise it is ignored and initializes everything inside the if/endif block i have recently added an 'ithen' to make an i-time only if/endif block, which can be useful in situations where you do set a k-rate or a-rate variable at i-time - and it makes things clearer as the if/igoto does -m -- Send bugs reports to [hidden email] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) To unsubscribe, send email to [hidden email] |
|
In reply to this post by David Akbari
David Akbari wrote:
> The idea is that you can trigger a rt midi event using the keys, and at > some point just make it "sustain" so as to have your hands free to mix > it into something else. Every other function works as I would like it > to, so it leads me to believe that I am misusing the program to some > extent; hence why I am posting here at present. Not sure if this is suitable for your purpose, but you may try using the sustain pedal controller (controller #64): when it is non-zero, all MIDI notes are held until the controller is reset to zero again. You cannot hold MIDI notes with 'ihold' because such notes already have indefinite duration, and it is not possible to make them finite either (that would conflict with the normal mechanism of turning off the note when a note-off event is received) - setting p3 to some positive value would have no effect. Also, the event opcode just creates another note, but the original one triggered from MIDI is not affected. -- Send bugs reports to [hidden email] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) To unsubscribe, send email to [hidden email] |
|
In reply to this post by David Akbari
I know there has been discussion about if statements and their
behavior on this list, but I haven't had a chance to catch up on them yet. However, I always seem to find myself having trouble with it, but that things work more like I want them to if I use the "if ( ) kgoto" and then put the code I want in a goto block such as if (kbend == -3) then kgoto off if (kbend >= 0) then kgoto sustain else kgoto done off: turnoff goto done etc. etc. having the 'done' lable right before the outs for the instr. another way I've tried to do something like you're suggesting is to just make each key hit change a flag for a note, so it just switches from on to off or off to on each time you hit a key. more work for when you don't want it to sustain, but pretty sold for the sustaining. A On 5/27/05, David Akbari <[hidden email]> wrote: > Hi List, > > So I'm trying to make a simple audio file manipulation instrument that > will "sustain" a note when a MIDI CC crosses a certain threshold. I was > using the ihold opcode in an attempt to sustain rt midi data, but I > noticed in the manual it says "a note of finite duration" so I added an > event opcode instead. Still, however it doesn't seem to like that. I > have tested it in MacCsound 1.2a5 (synchronized to CsoundLib 4.23f12 > built on Mar 9 2005) and Csound5 on OS X (built from CVS May 16 2005). > It performs identically on both with the exception of diskin/diskin2, > respectively. > > The idea is that you can trigger a rt midi event using the keys, and at > some point just make it "sustain" so as to have your hands free to mix > it into something else. Every other function works as I would like it > to, so it leads me to believe that I am misusing the program to some > extent; hence why I am posting here at present. > > Here's my example: > > ( If you need some audiofile quickly, one can be found at > http://nujazzbeats.spymac.net/audio/sample.aif ) > > <CsoundSynthesizer> > <CsInstruments> > > > sr = 44100 > kr = 44100 > ksmps = 1 > nchnls = 2 > > maxalloc 1, 1 > strset 6969, "/* audio file goes here */" > gilen filelen 6969 > > instr 1 ;live audiofile dj > > ; init > > kpch ctrl7 1, 1, -12, 12 ;mod wheel controls pitch > kpch = 2 ^ (kpch / 12) > > kbend pchbend ;pitchbend is the intended trigger > kcue ctrl7 1, 7, 0, gilen ;volume slider controls index into audiofile > > ktrig trigger kbend, -1, 0 > > ; synth > > a1, a2 diskin 6969, kpch, i(kcue), 1 ;if Csound5, use diskin2 > > if (kbend == -3) then > turnoff > endif > > if (kbend >= 0) then > event "i", 1, 0, gilen ;"a note of finite duration" > ihold > endif > > printks "\\nCue inSecs %f\\nTrigger %d\\nPitch %f\\n\\n", .5, kcue, > kbend, kpch > > outs a1, a2 > > endin > > </CsInstruments> > <CsScore> > f0 600 > > e > </CsScore> > > </CsoundSynthesizer> > > Any help / ideas / criticisms / pointers to relevant manual pages > appreciated! > > > -David > > -- > Send bugs reports to [hidden email] > (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) > To unsubscribe, send email to [hidden email] > Send bugs reports to [hidden email] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) To unsubscribe, send email to [hidden email] |
| Powered by Nabble | See how NAML generates this page |
