Advice for programming polyphony into a VSTi?
-
- KVRAF
- 1718 posts since 3 Sep, 2003
Are you sure it's two NoteOffs and not one noteOff and one noteOn with 0 velocity?
-
- KVRist
- 186 posts since 16 May, 2004 from Norway
-
Music Engineer Music Engineer https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=15959
- KVRAF
- 4379 posts since 8 Mar, 2004 from Berlin, Germany
yes, i do that too. works for multi-breakpoint envelopes which use nowadays equally well. as for audibility...maybe its even beneficial to the sound because otherwise one could have two voices playing the same note which would be prone to comb filtering artifacts.mystran wrote: I also find this nicely reduces audible clicking, especially if you don't mind slightly altered attacks on stolen voices, and instead of fully reseting the envelopes, just set 'em back to attack phase (assuming something like ADSR) with whatever value they have. Especially with exponential (with "reverse-exponential" attack) envelopes this usually doesn't have much audible result, and while the loss of a voice is often audible (but that's gonna happen with any limited-polyphony solution), otherwise it gives quite nice results.
i have the voice as class and i have base classes PolyphonicInstrument and PolyphonicInstrumentVoice where the former implements the note logic and calls virtual member functions noteOn, noteOff etc. of an array of instances of subclasses of the latter. that way i can have my note logic implemented once and re-use it for any instrument i'll be doing. yes, i know virtual function calls create some overhead, but in a moderately complex voice architetcture, the bulk of the CPU load will be done in the actual dsp code, such that the relative overhead is probably negligable (must do measuresments, though).Anyway, my other two cents is that I actually mostly represent my voices an array of structures of the different modules
it's something you at event-rate, not at sample-rate, so i'd say O(N) is acceptable.But you probably don't wanna hear my O(N) solution for monophonic last-note priority?
-
- KVRist
- 46 posts since 7 Sep, 2007 from Zagreb, Croatia
I have a question about using linked lists to implement polyphony. Is it OK to use STL type list to store voices, or would it be better to implement my own functions for manipulating lists?Leslie Sanford wrote: I use linked lists to store the voices.
- KVRAF
- 2187 posts since 25 Jan, 2007 from the back room, away from his wife's sight (or so he thinks)
STL is fine these days (though not all my implementations use it).farmer wrote:I have a question about using linked lists to implement polyphony. Is it OK to use STL type list to store voices, or would it be better to implement my own functions for manipulating lists?Leslie Sanford wrote: I use linked lists to store the voices.
Cakewalk by Bandlab / FL Studio
Squire Stratocaster / Chapman ML3 Modern V2 / Fender Precision Bass
Formerly known as arke, VladimirDimitrievich, bslf, and ctmg. Yep, those bans were deserved.
Squire Stratocaster / Chapman ML3 Modern V2 / Fender Precision Bass
Formerly known as arke, VladimirDimitrievich, bslf, and ctmg. Yep, those bans were deserved.
-
Leslie Sanford Leslie Sanford https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=131095
- KVRAF
- 1640 posts since 4 Dec, 2006
I rely on STL in my plugins (std::list, std::vector, std::map, and algorithms and stuff) and have had no problem so far.farmer wrote: I have a question about using linked lists to implement polyphony. Is it OK to use STL type list to store voices, or would it be better to implement my own functions for manipulating lists?
-
- KVRist
- 46 posts since 7 Sep, 2007 from Zagreb, Croatia
Thank you for your response, before applying STL i have stumped upon another problem. It could be phrased: Why in the name of Lord?
This chunk of code works:
where currentNote, currentVelocity and currentDelta are private members of the class VstXSynth.
But, this chunk of code doesn't work (the synth becomes silent as a brick wall):
Please help anyone, i will owe you very much and be grateful to the sky

This chunk of code works:
Code: Select all
void VstXSynth::noteOn (VstInt32 note, VstInt32 velocity, VstInt32 delta)
{
currentNote = note;
currentVelocity = velocity;
currentDelta = delta;
int i;
for (i=0;i<NUM_VOICES;i++)
if (!voices[i].active)
{
voices[i].note_on(currentNote, currentVelocity, currentDelta);
break;
}
}
But, this chunk of code doesn't work (the synth becomes silent as a brick wall):
Code: Select all
void VstXSynth::noteOn (VstInt32 note, VstInt32 velocity, VstInt32 delta)
{
int i;
for (i=0;i<NUM_VOICES;i++)
if (!voices[i].active)
{
voices[i].note_on(note, velocity, delta);
break;
}
}
-
- KVRist
- 241 posts since 29 Sep, 2007 from Europe
One possibility here is that your note_on is receiving note,velocity and delta not by value but by reference (&) and that it changes the actual values.
//Daniel
//Daniel
-
- KVRist
- 241 posts since 29 Sep, 2007 from Europe
Argh. sorry - assignments are outside of the loop so this should make no difference. I suggest you do another sanity check and be 100% sure that both of these are the actual code and not an example which shows the principle.
//Daniel
//Daniel
-
- KVRist
- 46 posts since 7 Sep, 2007 from Zagreb, Croatia
LOL XD yes both are actual code, but now i realized that each code works in toybear minihost and didn't work in FL????Resplendence wrote:Argh. sorry - assignments are outside of the loop so this should make no difference. I suggest you do another sanity check and be 100% sure that both of these are the actual code and not an example which shows the principle.
//Daniel
.... must say i am pretty confused right now

