Audio rate poly~ voice triggering

Vincenzo Johnson's icon

Relatively new max user here. I'm trying tying to create a granular patch based on Curtis Roads' Microsound. I am having a particularly hard time figuring out how to target poly~ voices at the audio rate. It looks like many patches use the thispoly~ object to offset the phasors between voices, but I don't think this approach will work for me since it ties the grain emission rate to the number of voices and I would like to be able to control the grain emission rate independently. It seems like something in gen~ might be the best solution. Can anyone offer any guidance? Any help would be greatly appreciated! I'm in a little over my head!

Thanks

Vincenzo

Roman Thilenius's icon

you can use different inlets, funnel, or mc. ... how many voices?

Ernest's icon

What I can contribute is a few javascript methods from my multitimbral javascript synth. Sadly js buffer peek and poke methods do not compile to standalone, so I dropped it. But it could provide a starting point. This is an LRU voice allocator for multiple voices on different channels with age-based voice indexing for best performance. This is part of 3,000 lines of JS code and I haven't got a simpler version at hand, apologies.

function storenote(pon, velon, chan){    //add note to buffer
    var a = anum[chan];
    if(a < vmax) anum[chan] = a +1;
    apitch[chan][a] = pon;
    aveloc[chan][a] = velon;
}
function deletenote(ageoff, chan){    //remove note from buffer
    var a = anum[chan];
    var b;
    var c;
    var d = 0;
    for(var i = ageoff; i < numv; i++){
        c = aveloc[chan][i];
        if(c){
            b = d + 1;
            apitch[chan][d] = apitch[chan][b];
            aveloc[chan][d] = aveloc[chan][b];
            d++;
        }
    }
    apitch[chan][a] = 0;
    aveloc[chan][a] = 0;
    anum[chan] = a -1;
}
if(vel>0){
            storenote(p, vel, chan);
            numv++;
        }else{
            for(var a = numv; a >0; a--){
                v = age.indexOf(a);
                if(p == pitch[v] && chan == channel[v]){
                    pitch[v] = 0;
                    channel[v] = 0;
                    deletenote(a, chan);
                    numv--;
                    return;
                }
            }
        }

Vincenzo Johnson's icon

Thanks for your replies, I managed to figure out the issue!

Vincenzo Johnson's icon

After much head scratching

.quasar's icon

As always when granular synthesis is involved, I'm a bit curious... What solution did you find out ?