Type Casting SynthesiserSound::Ptr


#1

How would I properly subclass SynthesiserSound::Ptr to something more specific, e.g. MySound::Ptr?

I am having difficulties type casting the return value of Synthesiser::getSound( ) to the more specific MySound::Ptr. I was using plain pointers and dynamic_cast<> until recently, which seems no longer possible with the latest version of Juce.

Probably I’m getting the purpose of Ptr entirely wrong and there is some way of still using plain pointers, so any help is much appreciated.


#2

You don’t need to be concerning yourself with the ::Ptr at all, just inherit from SynthesiserSound and use dynamic_cast<MySynthSound*> when you need to cast to your own sound type.


#3

Thanks, but Synthesiser::getSound(int index) returns a SynthesiserSound::Ptr that I can’t seem to cast to MySound*


#4

Try casting the result of get() from the ::Ptr.


#6

Thanks (slap on my forehead). Sometimes I fail to see the obvious.