I'm implementing a voice synthesizer chip. To build a phrase, I create a list of phonemes like this:
static const uint8_t PROGMEM heybuddy[] = {
pPA5, pHH1, pEY, pPA5,
pBB2, pAX, pDD2, pIY, pPA5,pPA5,pPA5,
};
And to play them I do this:
for (size_t i=0; i<sizeof(heybuddy); i++){
say(pgm_read_byte(heybuddy+i));
}
So what I'd like to do is create a function where I can just pass the array to a function that can take care of the loop and do some other maintenance stuff.
//what I've tried:
void sayPhrase(const uint8_t *phrase){
int open = 0;
for (size_t i=0; i<sizeof(*phrase); i++){
if(pgm_read_byte(*phrase) != 4 && open == 0){
Serial.println("mouth open");
open = 1;
} else if(pgm_read_byte(*phrase) == 4 && open == 1){
Serial.println("mouth closed");
open = 0;
}
say(pgm_read_byte(*phrase+i));
}
}
But when it comes to passing a static const I'm lost I've tried passing it as a reference with *
but nothing I do seems to work - I just don't know the proper way to do this in C.
What I have compiles, but it seems to only get one phoneme and repeat it over and over. The rest are lost.