Is this possible? Pan the audio on a specific SynthesizerVoice? I tried using Synthesizervoice.ControllerMoved(10,0) (CC10 is supposed to be the panning?) for example, and also Midimessage.controllerEvent(channel, 10, 0), where channel = either 1 and also tried the channel where the happening note happens…
But no panning effect.
Samples are mono-audio, and synthesizer-channels are set to stereo-pairs(multi-channel).
I tried that and it gives loads of "cannot access private member declared in class ‘juce::SamplerSound’.
Now this leads me thinking I’d need to Derive loads of classes and soon the whole API(except the parents that has pure virtual methods…) to override 1 method… So, I’m thinking there must be a better way? What am I doing wrong?..
Yeah, I understood that, but I lack a bit C++ knowledge to derive the Synthvoice Class properly into my own, SamplerVoice-alike, class that has the RenderNextBlock overridden… I tried and I’m having a nightmare with the private members of the SynthesizerVoice class that are needed in overridden RenderNextBlock…
I tried also just copying all the stuff in SamplerVoice and re-naming it to my own class named SamplerVoicePan, and it did the same trouble, SamplerSound’s private members couldn’t get access. 2 of those private variables are needed to run the renderNextBlock…
I understand that private cannot be accessed, but what’s the workaround? I know of getter or similar functions but without rewriting the API source to include getter methods, I don’t know how to get those variables to work… And I’d believe writing the source code is kinda wrong way to do it?
Edit: To define more clearly, errors are:
error C2248: ‘juce::SamplerSound::data’ : cannot access private member declared in class 'juce::SamplerSound’
error C2248: ‘juce::SamplerSound::length’ : cannot access private member declared in class ‘juce::SamplerSound’
I needed to also override StartNote and StopNote methods since they’re pure virtual ones without definitions(I guess?)… Did you try yours in practice or just came up with “from the top of your hat” ?
I still didn’t got sound out of it and so I’m thinking did I add the voice the right way into my synthesiser…? Now it’s:
synth[midiChannel]->addVoice (new PannableSynthesiserVoice(new SamplerVoice()));
Aggregates seem just a tiny bit confusing but I think I got it…
I’m glad it worked…
it was a completely theoretical idea, I haven’t tried it.
Just wanted to point you to aggregation as alternative to inheritance, as you actually don’t need access to the internals.
Yeah but I didn’t get it to play anything yet so it almost worked Do you think I add the voice & create the aggregate the right way to my synthesiser? (code above how I did it)…
Ah sorry, I thought after you used another method to initialise it worked, misunderstood that.
I am no expert with the Synthesiser classes.
Do you call the aggregated object, when you override noteOn etc.? Like the one example I gave for canPlaySound? To be safe, you might do that for ALL virtual methods.
Aggregate didn’t work for some reason but I ended up deriving the whole SamplerVoice-class, and finalyl I got Samples out & ability to affect Voice’s rendernextblock.