I need to chuck some conditionals against the samplersounds I have loaded since I have assigned multiple per note, so I’m going to use the name of the samplersound object to try ascertain which one needs to be sent to the voice in noteOn()
When I chuck a breakpoint in there and inspect the sound object, this is what it looks like in my watch:
I can see the text is in there which I need to access, but when I try access it with sound.name.text I get the output class “juce::SynthesiserSound” has no member “name”
I found that SamplerSound should have a getName() member function but I also get the same output when I try run sound.getName()
What kind of object is sound? It seems odd that it’s a SamplerSound object. Did you cast it? If you want it to be a SamplerSound then dynamic cast it I guess.
I haven’t touched the noteOn function yet, I just copied it into my subclass so I can make the modifications I need to make.
You’re right, it does seem to be synthesisersound SynthesiserSound* const sound = sounds.getUnchecked(i); however it definitely contains the name variable! You can see it in the screenshot I included
Just a general side note, if you come into threading issues (and this is a class that has the potential, since loading and bank switching etc. is issued from the message thread, if it is result of a GUI action), using a name is an awful choice, since it is the least atomic changeable variable type.
Strings are for humans, computers don’t like strings.
Floats and doubles are also bad (just for completeness).
Ideally use an integer or the pointer to the object you are referring to, if you can manage the data structures and ownerships properly.
@Rail_Jon_Rogut when I try cast it as SamplerSound instead I get the following error: no suitable conversion function from "juce::ReferenceCountedObjectPtr<juce::SynthesiserSound>" to "juce::SamplerSound *const" exists