So I’m working on blaster stuff, and additional images for OLED.
Particularly, Self-destruct. I thought it would make sense to have the duration listen to the file length instead of a fixed ProffieOSDestructImageDuration
for example, because different fonts can have different sounds.
Having a hard time figuring this out.
I guess I just don’t know the right things to call.
GetCurrentEffectLength(); seems to return a different file’s time than the one triggered in the prop’s SB_EFFECT, and I can’t figure out how to print the current effect to see which it’s getting from.
I can print the length, but not which effect.
This is what I’ve tried in ssd1306.h:
void SB_Effect(EffectType effect, float location) override {
switch (effect) {
// other cases are all here
case EFFECT_USER1: {
float len = hybrid_font.GetCurrentEffectLength();
ShowFile(&IMG_destruct, len * 1000);
STDOUT.println(len);
// ShowFile(&IMG_destruct, font_config.ProffieOSDestructImageDuration);
return;
}
break;
default: break;
}
}
The triggered sound, destruct.wav, is 10 seconds long. But I’m getting a returned len
of like 1.2 or .82… and whatison
shows the last few played might be getting chosen (like boot or out, which are more like those lengths).
Best I can think is that GetCurrentEffectLength(); is too early and not picking up the destruct.wav from EFFECT_USER1. Would it need to wait a moment?
Other attempts like:
STDOUT.println(current_effect_);'
STDOUT.println(GetEffect());
STDOUT.println(GetName());`
don’t work due to template parameters and other errors.
Other ways involve too specific things that would depend on the user having the file defined in a prop with EFFECT(destruct); and susequently play the wav directly, like I tried something like:
if (SFX_destruct) { // cant depend on this being declared in prop
ShowFile(&IMG_destruct, 1000 * hybrid_font.PlayPolyphonic(&SFX_destruct)->length());
} else {
ShowFile(&IMG_destruct, font_config.ProffieOSDestructImageDuration);
}
Just missing a piece or two to this puzzle, while trying to keep in mind that it needs to be kept generic enough that any blaster prop can still work with it,
and doesn’t take up memory for all users if not needed.
Any insight would be appreciated to get cool stuff working!