Problem with polyphony channel menu

I have a weird issue with the Polyphony menu not working on my module Neutrinode but it works fine on another of my modules, Cosmosis. When I was first building this, the polyphony menu worked fine with Neutrinode but now it doesn’t. I can hard code the number of channels in it, but the right-click menu just doesn’t do anything.

Here’s the relevant code:

I’ve compared it to my Cosmosis code (which works), and can’t really find the issue. Any help would be greatly appreciated. Thanks

I’m completely ignorant of how that code works but I did notice in the Neutrinode code for the ChannelValueItem struct you have

module->setChannels(channels);

whereas in the Cosmosis code you have

module->channels = channels;

Is there a reason for that?

Edit: seems like those should be equivalent and its unlikely that is the problem.

One other thing I noticed is that the code

outputs[GATES_ALL_OUTPUTS].setChannels(channels); outputs[VOLTS_ALL_OUTPUTS].setChannels(channels);

appears earlier than the code setting the voltage for those outputs; I’m not sure if that matters either but in other vcv source that I’ve looked at the setChannels method is called later.

I think polyphony isn’t really part of the VCV module API, is it? The only place I ever run into it is setting the number of channels in my output ports.

outputs[foo].setChannels(n);

I think if you just set the “right” number of channels in each of your output ports it will be fine.

It looks like in process() you’re setting the polyphony for only two of your outputs here, and not the other 8 gate and volt outputs.

I’ve tried that as well. And updated it in this recent commit but still doesn’t work. Have you tried compiling it? The polyphony itself works, it’s just when you use the right-click menu it doesn’t change the number of channels.

I used the code from the fundamental MIDI-CV module: https://github.com/VCVRack/Rack/blob/2db08f15a00f6792bb3a45db31dd13f94966beed/src/core/MIDI_CV.cpp#L462-L488

The issue isn’t whether the outputs[i].setChannels(n); works (it works fine), but the right-click menu doesn’t change the number of channels to whatever the user wants. I’ve hard-coded the number of channels to 16 but if the user wanted to use only 8, for example, it doesn’t work.

If you clone the repo and git checkout dev then build it from that branch, it still works for some reason. I’m at a loss on this one

outputs[GATE_OUTPUTS + i]

i goes from 0 to NUM_OF_NODES, but GATE_OUTPUTS is defined as VOLTS_ALL_OUTPUTS + NUM_OF_NODES.
Same for VOLT_OUTPUTS.

1 Like

That just means that GATE_OUTPUTS = 5 so when I use:

outputs[GATE_OUTPUTS + i].setChannels(channels);

it just means 5+0, 5+1, …,5+(NUM_OF_NODES-1). That’s consistent throughout the code, I don’t see how it’s an issue.

Ok, sorry about that, you’re right.
You’re problem seems to be namespace related. After renaming struct ChannelItem to struct ChannelItem1 and struct ChannelValueItem to struct ChannelValueItem1 everything works as expected.

2 Likes

Ah yes!! Thank you thank you :pray:

I didn’t realize same name structs in multiple files would conflict but I’ll wrap it in a namespace.