Advice for programming polyphony into a VSTi?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Are you sure it's two NoteOffs and not one noteOff and one noteOn with 0 velocity?

Post

Rock Hardbuns wrote:Are you sure it's two NoteOffs and not one noteOff and one noteOn with 0 velocity?
Data0 = $80
Data1 = 62
Data2 = 0

This is sendt twice on release in vstevents with no changes on status or velocity...
Strange if you ask me :shrug:
Image

Post

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.
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.

Anyway, my other two cents is that I actually mostly represent my voices an array of structures of the different modules
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).
But you probably don't wanna hear my O(N) solution for monophonic last-note priority?
it's something you at event-rate, not at sample-rate, so i'd say O(N) is acceptable.
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Leslie Sanford wrote: I use linked lists to store the voices.
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?

Post

farmer wrote:
Leslie Sanford wrote: I use linked lists to store the voices.
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?
STL is fine these days (though not all my implementations use it).
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.

Post

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?
I rely on STL in my plugins (std::list, std::vector, std::map, and algorithms and stuff) and have had no problem so far.

Post

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:

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;
		}
}
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):

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;
		}
}

Please help anyone, i will owe you very much and be grateful to the sky

:shock:

Post

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

Post

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

Post

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
LOL XD yes both are actual code, but now i realized that each code works in toybear minihost and didn't work in FL????


.... must say i am pretty confused right now :?:

Post Reply

Return to “DSP and Plugin Development”