Synthesise Question


#1

I’m wondering what does this line exactly do and why is it necessary. Can I not just have return true; ?

return dynamic_cast<SynthSound*>(sound) != nullptr;

#include “SynthVoice.h”

SynthVoice::SynthVoice(){

}

SynthVoice::~SynthVoice(){

}

bool SynthVoice::canPlaySound (SynthesiserSound* sound){
return dynamic_cast<SynthSound*>(sound) != nullptr;
}


#2

Yeah, you could just return true if you can be sure your synthesiser only deals with one particular synth sound type.


#3

Thanks. What do you mean by synth type? like if I’m using several synth sound classes? would you ever need to use more than one?


#4

Maybe, if you would be doing a synth that can play different sounds on the bass notes and different sounds on the treble notes or something. But it doesn’t seem to be a particularly common thing to need to use multiple sound classes.


#5

I see thank you