From: Art Hunkins ()
Date: Apr 2, 2005
Subject:
Re: monophonic instrument in one instrument
Yes, this does work - in an interesting way.
It works fine when only two keys are pressed simultaneously. It doesn't know
what to do with more than two. If three are down and you lift one (leaving
two down), there is silence; but when you lift the second (leaving one), the
first reenters!
Regarding maxalloc: starting with the *third* key down simultaneously,
maxalloc eliminates events. So, two notes are allowed with maxalloc = 1, but
no more!
Time for some sleep.
Art Hunkins
----- Original Message -----
From: "John Harrison"
To:
Sent: Saturday, April 02, 2005 9:24 PM
Subject: Re: [Csnd] monophonic instrument in one instrument
> I got curious about all this and came up with what I think is a
> solution. Here's the orc file, which runs with the sco file which
> started this email thread.
>
> I only have Midi-OX to test stuff with, so...hopefully it works. Anyway,
> I commented it so if there's a flaw in my logic, it should be apparent.
>
> You'll see in my code I ask this question too...why doesn't maxalloc 1,1
> solve the problem? I'm using CsoundAV, BTW.
>
> Anyway, it ain't a pretty solution...but it's all in one instrument...
>
> -John
>
> Richard Dobson wrote:
>
> > I wonder whether, this being a subset of the general problem of
> > polyphonic voice allocation, the proper solution will require an
> > architectural extension to Csound to provide a global voice
> > assignment framework, which can implement what we expect from MIDI,
> > from a monophonic instrument as requested here, to a general
> > voice-stealing algorithm allowing up to N instances of an instrument
> > (or shared between all instruments in an orch) to be running
> > simultaneously?
> >
> > Even if a solution can be found which requires "merely" the custom
> > programming of instruments, it is likely to be less transparent,
> > elegant or general than a solution at the architectural level.
> >
> > I appreciate that this does not answer the question in the short term!
> >
> > Richard Dobson
> >
> >
> >
> > Art Hunkins wrote:
> >
> >> I wondered this too. Unfortunately, it doesn't solve the problem. I
> >> think
> >> the truth of the matter is that Atte really doesn't want certain
> >> notes to
> >> play *at all.* And in this case, I expect it would be the least trouble
> >> never to trigger them in the first place (i.e., not have them
> >> scheduled by
> >> an always-on instrument).
> >>
> >> Art Hunkins
> >>
> > ...
> >
>
----------------------------------------------------------------------------
----
> sr = 44100 ; sample rate
> ksmps = 20 ; sr/kr
> nchnls = 2 ; number of channels
>
> ;maxalloc 1,1 ; WHY DIDN'T THIS SOLVE THE PROBLEM?
>
> instr 1
> start: ; LABEL BEGINNING OF CODE FOR REINIT PASS
>
> iamp = 7000
> ifreq cpsmidi
>
> kwait init 0
>
> iactive active 1 ; GET # OF ACTIVE INSTANCES OF THIS INSTRUMENT AT i TIME
> ckgoto (iactive == 1), SkipWait
> kwait = 1 ; IF MORE THAN ONE INSTANCE AT i time, FLAG THIS CONDITION
> SkipWait:
> ckgoto (kwait == 1), CheckWait ; IF MORE THAN ONE INSTANCE FLAGGED, UPDATE
CONDITION
> ; ELSE, PLAY THE NOTE
> aampenv expsegr .0001, .02, 1, .2, .001
> aosc1 oscili iamp, ifreq, 1
> outs aosc1 * aampenv, aosc1 * aampenv
> kgoto end ; SKIP UPDATE OF FLAGS IF THIS IS INSTANCE OF NOTE BEING PLAYED
> CheckWait:
> kactive active 1
> ckgoto (kactive > 1), end
> reinit start ; IF THIS IS THE ONLY INSTANCE LEFT, REINIT
> end:
> endin
-- [EMAIL REMOVED] (or to http://www.cs.bath.ac.uk/cgi-bin/csound ) [EMAIL REMOVED]