# Multi\_prop.h, I feel I am getting closer to something usable but

**URL:** <https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793>\
**Category:** Props\
**Created:** [September 5, 2024, 2:58am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793 "2024-09-05T02:58:27Z")\
**Posts on this page:** 19\
**Page:** 4

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 13, 2024, 11:41pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/61 "2024-09-13T23:41:31Z")

</div>

> [@NoSloppy](#):
>
> I think the question meant did YOU try it and it worked for you.

It DID work for me or I would not have posted it. Specially not after my miserable first attempt at posting a non-working version of it.

> [@NoSloppy](#):
>
> I suggest making a free Github account.  
> It will have every change you ever made, and it’s off site so if your computer falls out a window, you’ll be fine.

I did make a Github account. I have branches from profezzorn, you NoSloppy (that’s where I found your blaster\_BC\_buttons.h - last week), ryryog25 & more.

I tried to add as draft a previous version of multi\_prop.h but when I look for it to update, I couln’t find it ? I think I need a Github tutorial. Do you know of a good Youtube video ?

> [@NoSloppy](#):
>
> if your computer falls out a window

It didn’t fall from anywhere or go in the washing machine or dish-washer neither.

I must apologize again for wasting your time for a dumb finger-trouble mistake.

I also apologize if I seem frustrated, because I know I am. It is not at anyone of you, you have all been more than helpful and I thank you for it, but it is at me.

I will take a break now, and hopefully I find the working version tomorrow.

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 14, 2024, 12:07am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/62 "2024-09-14T00:07:38Z")

</div>

> [@profezzorn](#):
>
> SaberBase

Good to know, my first guess was “Sound Blaster” but I know that couldn’t be it.

> [@profezzorn](#):
>
> I’m not sure what that means.

Imagine you would try to explain it to your grand-parents. Or to my parents who are almost 80. (They both can use a computer to check their emails or browse the internet, and they both “think” they know “a lot” about their computer compared to some of their friends who can only use a land line to make a phone call!)

> [@profezzorn](#):
>
> Ops, I meant the type of _EFFECT_ that was requested.

So same question: what “kind of type” of _EFFECT_ “can be requested” ?

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [September 14, 2024, 12:37am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/63 "2024-09-14T00:37:54Z")

</div>

> [@olivierflying747-8](#):
>
> So same question: what “kind of type” of _EFFECT_ “can be requested” ?

Meaning that because it’s in SB\_Effect, it expects EFFECT\_X, Like EFFECT\_BLAST or something that’s an effect.  
I can’t really comment further because the posted multi\_props.h file is not available to examine.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 14, 2024, 1:06am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/64 "2024-09-14T01:06:56Z")

</div>

> [@olivierflying747-8](#):
>
> > [@profezzorn](#):
> >
> > I’m not sure what that means.
> 
> Imagine you would try to explain it to your grand-parents. Or to my parents who are almost 80. (They both can use a computer to check their emails or browse the internet, and they both “think” they know “a lot” about their computer compared to some of their friends who can only use a land line to make a phone call!)

Ok, it uses magic to do magic, magically!

Seriously though, I’m not sure what you’re asking for makes sense. I would have to use imprecise language, approximate what is actually happening and unless you have some basic level of understanding of programming, you still wouldn’t be able to use that information for anything.

Let’s try to make it as simple as I think it makes sense to make it:

The point of SB\_Effect is generally to play sounds. It is a function. It is called when things happen. One of the arguments to the function is called “effect” which specifies _what_ happened. There are several SB\_Effect functions, and each is responsible for playing some effects. Most SB\_Effect() functions start with a switch statement based on the “effect”, with cases for each of the events that they care about. Each case leads to a bit of code that plays a sound.

Is this still too complicated?

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 14, 2024, 9:38am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/65 "2024-09-14T09:38:19Z")

</div>

> [@NoSloppy](#):
>
> I can’t really comment further because the posted multi\_props.h file is not available to examine.

Edit: file deleted, see further down for the latest one.  
This is my previous working (compiling) version (revision 30) but “buttons mapping is not yet fully handled”. I will retrace my steps of yesterday and hopefully I find my working revision 31. I just tested the above and it does compile.

> [@profezzorn](#):
>
> If you would like to get the code added to proffieOS eventually, you should stick to the same style as the rest of the code. For instance, do not put `}` after other stuff, and only one per line.

Unless I missed one, this is done.

> [@profezzorn](#):
>
> Is this still too complicated?

No it is much better, at least a lot “less obscure”.

I will keep on working at it until I get it right.

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 14, 2024, 5:43pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/66 "2024-09-14T17:43:47Z")

</div>

> [@olivierflying747-8](#):
>
> This is my previous working (compiling) version (revision 30)

I finally found my version31 which I thought was working but I guess I must have tested version30 instead. I don’t know for now, how to handle the buttons mapping that is what is causing the problem. Last night I had nothing working because I had also messed-up my config which was causing all sorts of error messages.

So if I understand the (re-)mapping correctly: only the blaster needs the mapping & re-mapping functions & this needs to happen before event2.

I am guessing that the mapping to blaster will also affect the behavior of my “dual botton extra long push” which expects “power+aux for 4 sec” but instead it will receive “fire+mode\_select for 4sec”.

I starting writing this message this morning. Just saying in case the above doesn’t match the bellow.

I think I figured out the “mapping” and where to put it (yes it compiles) here is version 32:  
Eddit: file deleted, new one further down.

> [@profezzorn](#):
>
> Your SB\_Effect() only checks the mode, not what type of request was requested, which means that every effect will play the mode change sound.

So guess I need to put the sound effects somewhere else, where they will only be played once ? Correct ?

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 14, 2024, 6:54pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/67 "2024-09-14T18:54:35Z")

</div>

> [@olivierflying747-8](#):
>
> So guess I need to put the sound effects somewhere else, where they will only be played once ? Correct ?

I think what you want is to:

1. Add a new event in common/saber\_base.h
2. have switchMode call SaberBase::DoEvent using the new event as the argument.
3. Have SB\_Event do nothing unless it’s the right event.

What you want is similar to EFFECT\_MODE, but since that event is already used by the blaster prop AND you are also using the blaster prop, I think you need a new one…

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 15, 2024, 12:03am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/68 "2024-09-15T00:03:10Z")

</div>

> [@profezzorn](#):
>
> Add a new event in common/saber\_base.h

I am guessing you mean a new EFFECT in the `#define DEFINE_ALL_EFFECTS() \` “list”  
~~So I added~~ : (EDIT: I removed it because I would rather not modify Proffie OS for now)

```auto
    /* Multi prop effects */ \
    DEFINE_EFFECT(BLASTERMODE) \
    DEFINE_EFFECT(SABERMODE) \
    DEFINE_EFFECT(DETMODE) \
    DEFINE_EFFECT(JETMODE) \
    DEFINE_EFFECT(DROIDMODE) \

```

~~At the bottom of the list.~~

> [@profezzorn](#):
>
> have switchMode call SaberBase::DoEvent using the new event as the argument.

Would this in multi\_prop.h

```auto
EFFECT(blastermode); 
EFFECT(sabermode); 
EFFECT(detmode);
EFFECT(jetmode);

```

With `(!hybrid_font.PlayPolyphonic(&SFX_blastermode)), !hybrid_font.PlayPolyphonic(&SFX_sabermode)), ...` in the switch not work ? It does compile and I didn’t have to add anything to saber\_base.h

> [@profezzorn](#):
>
> Have SB\_Event do nothing unless it’s the right event.

Done, that was easy. 😁

> [@profezzorn](#):
>
> What you want is similar to EFFECT\_MODE, but since that event is already used by the blaster prop AND you are also using the blaster prop, I think you need a new one…

If I understand correctly, I need to create a new effect named “EFFECT\_XYZ”, I’ll replace “XYZ” with a more appropriate name when I think of a good one, that work identicaly as EFFECT\_MODE ?  
What is wrong with `EFFECT(blastermode);` in multi\_prop.h or with `DEFINE_EFFECT(BLASTERMODE) \` in saber\_base.h ?  
The wav’s made by NoSloppy say “Blaster mode”, “Saber mode”, “Detonator mode”, … They do not say “Blaster” & then I need to add “mode” to it.

You can find all 5 sound files (created by NoSloppy) on my dropbox here:  
[https://www.dropbox.com/scl/fi/p2pj9os5v4seel0wmzwcz/Multi\_prop\_sounds\_by\_NoSloppy.zip?rlkey=hi6589mexymnx4jmxhtwqjfu0&st=3klofs5m&dl=0](https://www.dropbox.com/scl/fi/p2pj9os5v4seel0wmzwcz/Multi_prop_sounds_by_NoSloppy.zip?rlkey=hi6589mexymnx4jmxhtwqjfu0&st=3klofs5m&dl=0)

Here is my latest multi\_prop.h it compiles but since I have no way (yet) to test it, I should probably give it a rest and continue on soldering to finish my build.  
[multi\_prop.h](https://crucible.hubbe.net/uploads/short-url/bwqR16JTUKCta1ufM3qsrIoz9SD.h) (17.0 KB)

Please if you have any more comments, I will work on them as soon as possible.

Cheers

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 15, 2024, 1:51am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/69 "2024-09-15T01:51:07Z")

</div>

> [@olivierflying747-8](#):
>
> What is wrong with `EFFECT(blastermode);` in multi\_prop.h or with `DEFINE_EFFECT(BLASTERMODE) \` in saber\_base.h ?

Unfortunately, there is some confusing terminology in ProffieOS.  
There is the effect enum, defined in common/saber\_base.h using DEFINE\_EFFECT(…).

Then there is the Effect class, which is is used to scan and keep track of files on the SD card. Using the EFFECT(something) define creates one of these, usually named SFX\_something.

They are not interchangeable, and your SB\_Effect function is likely to use both of them, so…

> [@olivierflying747-8](#):
>
> What is wrong with `EFFECT(blastermode);` in multi\_prop.h

Nothing, but it doesn’t help with the effect enum.

> [@olivierflying747-8](#):
>
> or with `DEFINE_EFFECT(BLASTERMODE) `

1. It doesn’t exist
2. If it did exist, you probably shouldn’t use it, because then the prop that used that effect wouldn’t work well with multi\_prop.h
3. What you need isn’t really a “blaster mode”, more of a “prop mode”…

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 15, 2024, 11:34am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/70 "2024-09-15T11:34:26Z")

</div>

> [@profezzorn](#):
>
> SB\_Effect function is likely to use both of them,

How can it use both if only one exists, I did not add anything in saber\_base.h, I only have `EFFECT_(something)` in multi\_prop.h and they are only used in the switch mode as `!hybrid_font.PlayPolyphonic(&SFX_something)` (\<-- doesn’t this plays the sound ?) like this:

```auto
        case PropMode::BLASTER:
            if (!hybrid_font.PlayPolyphonic(&SFX_detmode)) { //auto beepers
                beeper.Beep(0.05, 2000);
                beeper.Silence(0.05);
                beeper.Beep(0.05, 2000);
                };
            currentMode = PropMode::DETONATOR;
            break;

```

And SB\_Effect is empty as you suggested earlier:

```auto
    void SB_Effect(EffectType effect, float location) override {
        switch (currentMode) {
            case PropMode::SABER:
                Saber::SB_Effect(effect, location);
                break;
            case PropMode::BLASTER:
                Blaster::SB_Effect(effect, location);
                break;

```

So how could/would SB\_Effect use both if:

- only one exists
- and it is not used by SB\_Effect

Also

> [@profezzorn](#):
>
> > [@olivierflying747-8](#):
> >
> > or with `DEFINE_EFFECT(BLASTERMODE) `
> 
> 1. It doesn’t exist

But it would exist if I add it. Which I choose not to for now, but if I do, I would remove the `EFFECT_(something)` from multi\_prop.h and only use the `DEFINE_EFFECT(SOMETHING) \` from saber\_base.h

> [@profezzorn](#):
>
> If it did exist, you probably shouldn’t use it, because then the prop that used that effect wouldn’t work well with multi\_prop.h

It would be added for multi\_prop.h to use not for the other props.

> [@profezzorn](#):
>
> What you need isn’t really a “blaster mode”, more of a “prop mode”…

You mean a “prop mode” “blaster” ? & why not a “prop mode blaster” ?

Personally, I prefer “blaster mode” to “prop mode blaster” or “prop mode” “blaster”. It rolls better off the Edit: ~~thong~~ tongue (I was informed it was miss-spelled) & sounds better too.

I need to know more of the why, because I am more confused now. It might be more obvious once I finish my build to test it on, but for now there is a big “fog of war” surrounding the sound effects.

I prefer not to touch saber\_base.h because that is yours, now if you want me to add to saber\_base.h for the purpose to add multi\_prop.h to ProffieOS, that is fine by me. You can take multi\_prop.h & make it yours, if you like it ? I have no problem with that. I don’t even mind doing whatever modifications you want me to do and push them on Github for your approval.

For now I just want something that works without touching your code, unless you give me the go-ahead because you are interested in it. And if it never makes the cut to be part of ProffieOS because you don’t like it, that is fine by me too. I completely understand that you don’t want a stranger to come and “mess with your stuff”, I am the same.

---

<div class="post-metadata">

**Author:** ![ryryog25](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/ryryog25/32/1812_2.png) [@ryryog25](https://crucible.hubbe.net/u/ryryog25)\
**Post date:** [September 15, 2024, 4:43pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/71 "2024-09-15T16:43:41Z")

</div>

> [@olivierflying747-8](#):
>
> You mean a “prop mode” “blaster” ? & why not a “prop mode blaster” ?
> 
> Personally, I prefer “blaster mode” to “prop mode blaster” or “prop mode” “blaster”. It rolls better off the thong & sounds better too.

Fredrik can correct me if I’m wrong, but I believe the idea is to have a “prop mode” effect which is triggered generally to indicate a switch? And then logic would be implemented based off that premise? So it’s more of a general-purpose switch effect than it is specific to the blaster mode.

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [September 15, 2024, 5:51pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/72 "2024-09-15T17:51:00Z")

</div>

Ah, that makes sense, I was unable to understand it like that, but will multi\_prop not work as intended without it ?

For now I will be very happy if it works (and not just compile). It can always be improved later.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [September 15, 2024, 7:49pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/73 "2024-09-15T19:49:29Z")

</div>

> [@olivierflying747-8](#):
>
> I prefer not to touch saber\_base.h because that is yours, now if you want me to add to saber\_base.h for the purpose to add multi\_prop.h to ProffieOS, that is fine by me

Unfortunately, making new props sometimes means making changes outside of the prop file. The effect enum is one place that often needs modifications when new functionality is added.

THe good news is that adding new entries to effect enum doesn’t have any CPU or memory overhead unless you actually use that entry.

> [@olivierflying747-8](#):
>
> You mean a “prop mode” “blaster” ? & why not a “prop mode blaster” ?

You’re mixing up what the final output will be and the structure of the code.  
I was talking about the name of the entry in the effect enum, which isn’t directly related to what the the contents of the sound file will be.

> [@olivierflying747-8](#):
>
> I completely understand that you don’t want a stranger to come and “mess with your stuff”, I am the same.

I highly encourage people to mess with ProffieOS, that’s what open-source is all about. 🙂 However, I have ideas about how things should work, and how it should be written, and for anybody who wants to have their code included with the base ProffieOS code, there is a code review process that can be very painful. The pain can be reduced significantly by talking through and reaching agreement on how things should be written, which is basically what we’re doing here…

> [@olivierflying747-8](#):
>
> `!hybrid_font.PlayPolyphonic(&SFX_something)` (\<-- doesn’t this plays the sound ?)

Sure, but that isn’t the problem. The problem is that it will play the sound too much. You need to only play it when currentMode actually changes.

> [@olivierflying747-8](#):
>
> But it would exist if I add it.

Please do.

> [@olivierflying747-8](#):
>
> , but if I do, I would remove the `EFFECT_(something)` from multi\_prop.h

No, DEFINE\_EFFECT and EFFECT() does different things, one cannot be substituted for the other.

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [December 15, 2024, 3:07am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/74 "2024-12-15T03:07:21Z")

</div>

Hello @profezzorn, sorry for re-visiting my “old” threads but I would really love to understand all this stuff. When you said:

> [@profezzorn](#):
>
> No, DEFINE\_EFFECT and EFFECT() does different things, one cannot be substituted for the other.

Does it mean:

- Should I have both ? Which is what I believe is what you are implying but I do not understand why.  
or
- Do I need to choose one or the other ? And if this is the case, I don’t know which is the “good one” or why ?

The way I understand the code, if I use `SaberBase::DoEffect(xyz,0)`, it will play xyz.wav if I have DEFINE\_EFFECT(XYZ) in saber\_base.h (witch I do) and will also do other “things” if specifically programmed in saber\_base.h to do so ?

I also created multipropdisplaycontroller.h (based on `BlasterDisplayController`) and added:

```auto
#ifdef PROPS_MULTI_PROP_H
#include "multipropdisplaycontroller.h" 
#endif

```

in ssd1306.h  
[multipropdisplaycontroller.h](https://crucible.hubbe.net/uploads/short-url/e3MWR6p3QubNPwIDSJBBGctyVHf.h) (15.9 KB)

So if I have xyz.bmp in “common” or “appropriate\_font\_folder”, xyz.bmp should display on OLED at the same time as xyz.wav is played for the duration of xyz.wav. Is this correct ?

Now why would I also need `EFFECT(xyz);` in my multi\_prop.h ?

- I either use `hybrid_font.PlayPolyphonic(xyz)` to play xyz.wav and that’s it.  
or
- I use `SaberBase::DoEffect(xyz,0)` to play xyz.wav and more stuff, if programmed & maybe play xyz.bmp on OLED ?

I guess I am completely wrong on all of it but I would love to understand the “what it does”/“how it works” between the two, if you have the time to spare.

Thank you for reading so far.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [December 15, 2024, 3:56am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/75 "2024-12-15T03:56:48Z")

</div>

> [@olivierflying747-8](#):
>
> Does it mean:
> 
> - Should I have both ? Which is what I believe is what you are implying but I do not understand why.  
> or
> - Do I need to choose one or the other ? And if this is the case, I don’t know which is the “good one” or why ?

They do _DIFFERENT_ things.  
Chosing one or the other is like choosing between apples and screwdrivers.

Let me explain a little about what they do:

DEFINE\_EFFECT adds an enum value. An enum value is just assigning a name to a number, and that name only exists while compiling. If you add `DEFINE_EFFECT(CHICKEN_DANCE)`, then it will create an enum value called `EFFECT_CHECKEN_DANCE`. This enum value will be associated with some number, it’s not particularly important _what_ that number is though, all we care about is that it is different from all the other EFFECT\_\* enum values.

When you canll `SaberBase::DoEffect(xyz,0);` then `xyz` is one of these enum values. So the prop could call `SaberBase::DoEffect(EFFECT_CHICKEN_DANCE, 0);` to let all SaberBase instances know that it’s time to do the chicken dance. Note that this does not play a sound unless one of the SaberBase instances actually do so in `SB_Effect()`.

Then there is the `EFFECT()` macro. It creates an instance of the Effect class. The purpose of the Effect class is to keep track of all the files on the SD card related to one specific effect. So, if we put `EFFECT(chicken_dance);` somewhere, it will create an object in that scope called `SFX_chicken_dance`. Normally, this is done at the global scope, which means that the lifetime of the object is permanent. When we scan a font directory, we offer each file to each effect, and if the name matches, then that Effect instance will remember the highest and lowest number of that file, and where it was, and other details like that. So if we have a `chicken_dance.wav` in our font directory, the SFX\_chicken\_dance object will (eventually) know that.

The missing piece that ties all of this together is the `SB_Effect()` function. It will receive the EFFECT\_\* enum value(s), and usually do something like `hybrid_font.PlayPolyphonic(&SFX_chicken_dance);` in response, and now sound will play when you call `SaberBsae::DoEffect`.

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [December 15, 2024, 2:18pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/76 "2024-12-15T14:18:59Z")

</div>

Thank you so much for this thorough explanation. I think I understand now.  
This is all fascinating yet confusing (I am a lot less confused now then when I started - while revisiting my older posts, the answers you all gave me, make a lot more sense).

> [@profezzorn](#):
>
> No, DEFINE\_EFFECT and EFFECT() does different things

So in summary:

- I need both (and I do)
- I somehow/somewhere need to link them together via the `SB_Effect()` function.

> [@profezzorn](#):
>
> Note that this does not play a sound unless one of the SaberBase instances actually do so in `SB_Effect()`.

This is not clear how/where I need to have that. Or is it just as simple as having `SaberBase::DoEffect(EFFECT_XYZ, 0);` in my switchModes function and that will trigger `hybrid_font.PlayPolyphonic(&SFX_xyz);` and thus I do not want to have:

```auto
SaberBase::DoEffect(EFFECT_XYZ, 0);
hybrid_font.PlayPolyphonic(&SFX_xyz);

```

in my switchModes function because that would play xyz.wav twice, which I don’t want so I need to remove any `hybrid_font.PlayPolyphonic(&SFX_xyz);` & only have `SaberBase::DoEffect(EFFECT_XYZ, 0);`

Obviously I still keep `EFFECT(xyz);` at global level in multi\_prop.h & have `DEFINE_EFFECT(XYZ)` in saber\_base.h

Did I understand it correctly, or do I still need to add some more code somewhere?

I thank for for your patience with me & dedication for the hobby. I hope I am not annoying you with all my questions.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [December 15, 2024, 10:22pm UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/77 "2024-12-15T22:22:08Z")

</div>

This is an example of what you need to link an effect to a sound:

> <https://github.com/profezzorn/ProffieOS/blob/ed595f7a419388277e54eea942d78c9c424e58c9/props/saber_fett263_buttons.h#L6335>

Don’t read the whole function, because some of it is a lot more complicated than what you need. Just the first three lines should be enough…

---

<div class="post-metadata">

**Author:** ![olivierflying747-8](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/olivierflying747-8/32/5228_2.png) [@olivierflying747-8](https://crucible.hubbe.net/u/olivierflying747-8)\
**Post date:** [December 16, 2024, 3:52am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/78 "2024-12-16T03:52:05Z")

</div>

> [@profezzorn](#):
>
> Don’t read the whole function

Of course, I did read the whole section, sorry I couldn’t help it.  
Here is what I came up with:

```auto
    void SB_Effect(EffectType effect, EffectLocation location) override {
        switch (effect) {
            case EFFECT_SABERMODE: MultiPropHelpers::announcemode(&SFX_sabermode); return;
            case EFFECT_BLASTERMODE: MultiPropHelpers::announcemode(&SFX_blastermode); return;
            case EFFECT_DETONATORMODE: MultiPropHelpers::announcemode(&SFX_detonatormode); return;
            case EFFECT_JETPACKMODE: MultiPropHelpers::announcemode(&SFX_jetpackmode); return;
            case EFFECT_MORSECODEMODE: morsecodemode(); /* General invitation to transmit */ return;
        }
        switch (currentMode) {
            case Prop_Mode::SABER: Saber::SB_Effect(effect, location); break;
            case Prop_Mode::BLASTER: Blaster::SB_Effect(effect, location); break;
            case Prop_Mode::DETONATOR: Detonator::SB_Effect(effect, location); break;
            case Prop_Mode::JETPACK: Jetpack::SB_Effect(effect, location); break;
            case Prop_Mode::MORSECODE: MorseCode::SB_Effect(effect, location); break;
       }
    }

```

Is this starting to look better, or am I still way-off ?

Please find my latest multi\_prop.h with much reduced repetition.  
[multi\_prop.h](https://crucible.hubbe.net/uploads/short-url/c6mEsvr435qvAZJ2ztUrbazjgLx.h) (20.2 KB)  
Is it still too repetitive ? I tried to reduce the repetition further but it ended up using a lot more memory (3x as much - however, it was with plug-in 4.1.0 and I didn’t have the time to retry with 3.6.0, so I might “re-visit” that code later, once I know the rest is better)

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [December 16, 2024, 10:02am UTC](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793/79 "2024-12-16T10:02:25Z")

</div>

> [@olivierflying747-8](#):
>
> Is this starting to look better, or am I still way-off ?

It’s looking fairly reasonable I think.

[Previous page](https://crucible.hubbe.net/t/multi-prop-h-i-feel-i-am-getting-closer-to-something-usable-but/5793.md?page=3)
