[Csnd] "virtual kalimba" problem...help, anyone?
Date | 2010-12-20 05:55 |
From | Aaron Krister Johnson |
Subject | [Csnd] "virtual kalimba" problem...help, anyone? |
Hi all, I'm stuck on how to pull something off in Csound. I want to have a fractional instrument definition so that I can embed a pitch in use that would represent an individual 'tine' on a kalimba. This way, Csound can detect that when a tine is playing ti goes on playing unless it is struck again (a reinit). I've fleshed it out as two instruments: the sound producing 'virtual FM kalimba', and the 'helper instrument' which send event_i events to the sound-engine. I'm trying unsuccesfully to use 'turnoff2' to control envelope release, but I'm getting unexpected results---the engine only plays two notes. Of course, I'm telling it to only allow one note at a time, sensed by the 'active' opcode, but I'm wondering why the fractional instrument thing isn't working as designated in the active/turnoff2 combination....here's my current code, any help will be appreciated: instr 7 iamp = p4*p4 ipch = p5 ;; panning was implemented as a modulus function of pitch ;; this is just a way for us to get fancy stereo automatically, based on pitch ;; as if we are really small standing on the kalimba and hearing the tines ;; coming from all around us. ipanoffset = (log(ipch/64)/log(2)/20) - .1 if (ipanoffset > .1) then ipanoffset = .1 elseif (ipanoffset < -.1) then ipanoffset = -.1 endif ipanr = sqrt(p6 + ipanoffset) ipanl = sqrt(1- (p6+ ipanoffset)) imix = p7 kmodenv oscil1 0, 4+rnd(1), .1, 51 kenv expsegr (.001), .01, (1), ((2200/ipch)*1.6), (.001), .7, (.001) ;;;added last two terms for 'helper inst' 97 aosc foscil kenv, ipch, 1, 5.873, kmodenv, 1 zawm aosc*kenv*iamp*ipanl*imix, 1 zawm aosc*kenv*iamp*ipanr*imix, 2 endin instr 97 ;;; kalimba helper iamp = p4 ipch = p5 ipan = p6 imix = p7 Sinsnum sprintf "7.%d", int(p5) iinsnum strtod Sinsnum iact active iinsnum if iact > 1 then turnoff2 iinsnum, 12, 1 endif event_i "i", iinsnum, 0, -1, iamp, ipch, ipan, imix endin -- Aaron Krister Johnson http://www.akjmusic.com http://www.untwelve.org |
Date | 2010-12-20 06:39 |
From | Justin Glenn Smith |
Subject | [Csnd] Re: "virtual kalimba" problem...help, anyone? |
What are the p5 values you are using? you know that i2.1 is the same as i2.10 i2.100 etc, right? Also, you don't need to use sprintf and strtod, you can just add the fraction to the instrument number (ie. iinsnum = 2 + p5/1000, which generates i2.001 i2.002 ... i2.010 (equal to i2.01) i2.012 etc. which takes 1000 instances to start wrapping, rather than 10). Also, active does not pay any attention to subinstrument arguments, the following lines: active 2.1 active 2.2 active 2 All will return the same result. Aaron Krister Johnson wrote: > Hi all, > > I'm stuck on how to pull something off in Csound. > > I want to have a fractional instrument definition so that I can embed a > pitch in use that would represent an individual 'tine' on a kalimba. > > This way, Csound can detect that when a tine is playing ti goes on playing > unless it is struck again (a reinit). > > I've fleshed it out as two instruments: the sound producing 'virtual FM > kalimba', and the 'helper instrument' which send event_i events to the > sound-engine. I'm trying unsuccesfully to use 'turnoff2' to control envelope > release, but I'm getting unexpected results---the engine only plays two > notes. Of course, I'm telling it to only allow one note at a time, sensed by > the 'active' opcode, but I'm wondering why the fractional instrument thing > isn't working as designated in the active/turnoff2 combination....here's my > current code, any help will be appreciated: > > instr 7 > iamp = p4*p4 > ipch = p5 > ;; panning was implemented as a modulus function of pitch > ;; this is just a way for us to get fancy stereo automatically, based on > pitch > ;; as if we are really small standing on the kalimba and hearing the tines > ;; coming from all around us. > ipanoffset = (log(ipch/64)/log(2)/20) - .1 > if (ipanoffset > .1) then > ipanoffset = .1 > elseif (ipanoffset < -.1) then > ipanoffset = -.1 > endif > ipanr = sqrt(p6 + ipanoffset) > ipanl = sqrt(1- (p6+ ipanoffset)) > imix = p7 > kmodenv oscil1 0, 4+rnd(1), .1, 51 > kenv expsegr (.001), .01, (1), ((2200/ipch)*1.6), (.001), .7, (.001) > ;;;added last two terms for 'helper inst' 97 > aosc foscil kenv, ipch, 1, 5.873, kmodenv, 1 > zawm aosc*kenv*iamp*ipanl*imix, 1 > zawm aosc*kenv*iamp*ipanr*imix, 2 > endin > > instr 97 ;;; kalimba helper > iamp = p4 > ipch = p5 > ipan = p6 > imix = p7 > Sinsnum sprintf "7.%d", int(p5) > iinsnum strtod Sinsnum > iact active iinsnum > if iact > 1 then > turnoff2 iinsnum, 12, 1 > endif > event_i "i", iinsnum, 0, -1, iamp, ipch, ipan, imix > endin > 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 | 2010-12-20 06:51 |
From | Justin Glenn Smith |
Subject | [Csnd] Re: "virtual kalimba" problem...help, anyone? |
oh, the other thing is that only one i2.n can exist with a p3 of -1, if you make a new one it will replace the old this csd should be helpful in figuring out these behaviors: |
Date | 2010-12-20 13:42 |
From | Aaron Krister Johnson |
Subject | [Csnd] Re: Re: "virtual kalimba" problem...help, anyone? |
HI Justin, On Mon, Dec 20, 2010 at 12:39 AM, Justin Glenn Smith <noisesmith@gmail.com> wrote: What are the p5 values you are using? you know that i2.1 is the same as i2.10 i2.100 etc, right? Yeah, this doesn't seem to be the issue, b/c the pitches are unique.... Also, you don't need to use sprintf and strtod, you can just add the fraction to the instrument number (ie. iinsnum = 2 + p5/1000, which generates i2.001 i2.002 ... i2.010 (equal to i2.01) i2.012 etc. which takes 1000 instances to start wrapping, rather than 10). Neat trick...I'll try this. Thanks! Also, active does not pay any attention to subinstrument arguments, the following lines: This is an annoying bug....there ought to be an option for measuring how many active voices of a fractional instrument there are....developers? Best, AKJ
-- Aaron Krister Johnson http://www.akjmusic.com http://www.untwelve.org |
Date | 2010-12-20 18:58 |
From | Justin Glenn Smith |
Subject | [Csnd] Re: "virtual kalimba" problem...help, anyone? |
I think you can use the implicit tying behavior with held notes, tival, and tigoto to fix your current problem. If your durations of subinstruments are always -1 (as it appears from your current code), you don't have to worry about subinstrument count, because the next one with the same subinstrument will always replace the previous. Rather than triggering a release in the previous instrument, this will trigger a tie in the newly initialized one (whether the next note has a negative p3 or not). The tival opcode and the tigoto command can be used to detect whether a previous note is being tied onto by the current instance, and the release opcode can be used to detect if the note is currently being truncated via turnoff2 or a negative p1 value (allowing you to fade out your envelope etc). You could use tival for example to skip reinitializing an oscillator or filter. You could also insert some other sonic change on a tie, based on the value from tival. For example a buzz as one would get from hitting an already vibrating tine with a thumbnail seems appropriate in your case (perhaps from a temporary increase in the index and clipping of the modulating waveform; the latter can only be done with two separate oscils in fm configuration instead of foscil). As a semantic issue, pitch usually indicates a logarithmic notation (for example an index into a scale table, or a value to be converted by cpspch or cpsoct), while the terms frequency, cps, or hertz are used more often for raw cycles per second value. Since you are feeding ipch directly into the oscillator with no conversion, I cannot tell if you have a bug or if you are just using unconventional naming. Aaron Krister Johnson wrote: > HI Justin, > > On Mon, Dec 20, 2010 at 12:39 AM, Justin Glenn Smith > |
Date | 2010-12-20 19:45 |
From | Aaron Krister Johnson |
Subject | [Csnd] Re: Re: "virtual kalimba" problem...help, anyone? |
Hey Justin, On Mon, Dec 20, 2010 at 12:58 PM, Justin Glenn Smith <noisesmith@gmail.com> wrote: I think you can use the implicit tying behavior with held notes, tival, and tigoto to fix your current problem. Hey, sorry you're not getting what I want to do---I understand about Csound tying, etc. But the kalimba is not a monophonic tying instrument _per-se_. I only want to 'tie' (actually stop and reinit with a virtual thumb :) ) notes of the *same* pitch, provided that pitch is actually still sounding. Actually, this kind of thing would really work well with piano samples, too---saving CPU resources from hoggy polyphony by not calling new instruments when sustain pedal is on, but stopping and restriking an already sounding intsrument with envelopes...perhaps with brief noisy "hammer sounds" as well? This would be the equivalent of the very brief thumb noise stopping and replucking the tine on a kalimba. Anyway, this kind of thing seems very very tricky to pull off in Csound without a lot of gum and glue engineering. .... <snip> You could use tival for example to skip reinitializing an oscillator or filter. You could also insert some other sonic change on a tie, based on the value from tival. For example a buzz as one would get from hitting an already vibrating tine with a thumbnail seems appropriate in your case (perhaps from a temporary increase in the index and clipping of the modulating waveform; the latter can only be done with two separate oscils in fm configuration instead of foscil). This is what I was thinking, but I'm now more convinced than ever that I need to use samples fro realism--my FM model will just remain for figuring out the issues involved. Maybe I can make it sound more real by some means as you describe...
Actually, I'm using my own coded frontend which always converts directly to hz (microcsound takes Just intonation and EDOs and turns them directly into HZ, saving Csound from doing the overhead---besides which, Csound doesn't have a good enough resolution in it's pitch converters.... what this means is that perhaps there is a bug with converting p5 (pitch) to '7.%d' with printf in my original code. No time right now to think about this, but we'll discuss later. Thanks for your feedback! Best, AKJ
-- Aaron Krister Johnson http://www.akjmusic.com http://www.untwelve.org |
Date | 2010-12-21 11:02 |
From | Justin Glenn Smith |
Subject | [Csnd] Re: Re: Re: "virtual kalimba" problem...help, anyone? |
Aaron Krister Johnson wrote: ... > Hey, sorry you're not getting what I want to do---I understand about Csound > tying, etc. > > But the kalimba is not a monophonic tying instrument _per-se_. I only want > to 'tie' (actually stop and reinit with a virtual thumb :) ) notes of the > *same* pitch, provided that pitch is actually still sounding. As I said, this is how tying works. Only identical subinstruments are tied. 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 | 2010-12-21 13:34 |
From | Aaron Krister Johnson |
Subject | [Csnd] Re: Re: Re: Re: "virtual kalimba" problem...help, anyone? |
On Tue, Dec 21, 2010 at 5:02 AM, Justin Glenn Smith <noisesmith@gmail.com> wrote: Aaron Krister Johnson wrote: I thought so too, but it doesn't seem to work in my orchestra, and I can't find the error. I'm going to try a completely brute force, inelegant solution to my problem: each note is an instrument.....ugly hack, but it might work a lot better and be a straighter line to my goal. RIght now, I'm working against Csound and vice-versa to get what I need.... After all, to simulate my 15-note alto kalimba, I only need 15 intruments! I can script the code for this in Python, and cut and paste into the .orc file. AKJ
-- Aaron Krister Johnson http://www.akjmusic.com http://www.untwelve.org |
Date | 2010-12-21 19:48 |
From | Aaron Krister Johnson |
Subject | [Csnd] Re: Re: Re: Re: "virtual kalimba" problem...help, anyone? |
Justin (and any lurkers on this thread), Thanks for all your help on this -- I had a big 'duh' moment when it dawned on me what you are saying about sub-instrument tying...I was doing it all along, but making it too complicated, methinks! :) Anyway, I have a workable solution right now. I can mess around with FM parameters to try to get a more realistic kalimba timbre, or I can use samples for more realism. Eventually, I'm going to go the latter route. Cheers, AKJ On Tue, Dec 21, 2010 at 7:34 AM, Aaron Krister Johnson <aaron@akjmusic.com> wrote:
-- Aaron Krister Johnson http://www.akjmusic.com http://www.untwelve.org |
Date | 2010-12-21 19:53 |
From | Justin Glenn Smith |
Subject | [Csnd] Re: Re: Re: Re: Re: "virtual kalimba" problem...help, anyone? |
Your problem is that you are using active and turnoff2, and you should be using neither. Automatic tying of indefinitely playing subinstruments does exactly what you want. Run this csd, and tell me if the output is different from mine: |
Date | 2010-12-22 06:12 |
From | Aaron Krister Johnson |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: "virtual kalimba" problem...help, anyone? |
Yeah, got it, makes sense....if you're interested, and have an interest or use for such a thing, I'll share the setup with you once I'm done tweaking. I'm always interested to see where others take such a thing either musically, or tweaking the orchestra to their own liking. Cheers, AKJ On Tue, Dec 21, 2010 at 1:53 PM, Justin Glenn Smith <noisesmith@gmail.com> wrote: Your problem is that you are using active and turnoff2, and you should be using neither. Automatic tying of indefinitely playing subinstruments does exactly what you want. Run this csd, and tell me if the output is different from mine: -- Aaron Krister Johnson http://www.akjmusic.com http://www.untwelve.org |