# Setting callbacks for modules

**URL:** <https://discourse.libsdl.org/t/setting-callbacks-for-modules/5137>\
**Category:** SDL Development\
**Created:** [September 25, 2001, 8:49am UTC](https://discourse.libsdl.org/t/setting-callbacks-for-modules/5137 "2001-09-25T08:49:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ti\_Leggett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@Ti\_Leggett](https://discourse.libsdl.org/u/Ti_Leggett)\
**Post date:** [September 25, 2001, 8:49am UTC](https://discourse.libsdl.org/t/setting-callbacks-for-modules/5137/1 "2001-09-25T08:49:01Z")

</div>

Is there a way using either SDL\_audio or SDL\_mixer that allows setting a  
callback when playing a module and a certain instruction is found in the  
module pattern? If not, are there plans for this in the 1.3 API?

I’ve look through the headers and the closest thing I could find was  
Mix\_HookMusic.

Thanks!–  
Ti Leggett  
leggett at [eecs.tulane.edu](http://eecs.tulane.edu)

---

<div class="post-metadata">

**Author:** ![Sam\_Hart](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@Sam\_Hart](https://discourse.libsdl.org/u/Sam_Hart)\
**Post date:** [September 25, 2001, 9:20am UTC](https://discourse.libsdl.org/t/setting-callbacks-for-modules/5137/2 "2001-09-25T09:20:01Z")

</div>

I just want to throw in my two cents and say that I would personally find  
something like this /very/ useful.

I too have looked through the SDL\_mixer source, and not found anything. I  
have also been experimenting with SDL\_sound, and looked through its source,  
but doesn’t seem like anything like this is there right now.On Tuesday 25 September 2001 8:48, Ti Leggett wrote:

> Is there a way using either SDL\_audio or SDL\_mixer that allows setting a  
> callback when playing a module and a certain instruction is found in the  
> module pattern? If not, are there plans for this in the 1.3 API?
> 
> I’ve look through the headers and the closest thing I could find was  
> Mix\_HookMusic.

–  
Sam “Criswell” Hart \<@Sam\_Hart\> AIM, Yahoo!:   
Homepage: \< [http://www.geekcomix.com/snh/](http://www.geekcomix.com/snh/) \>  
PGP Info: \< [http://www.geekcomix.com/snh/contact/](http://www.geekcomix.com/snh/contact/) \>  
Tux4Kids: \< [http://www.geekcomix.com/tux4kids/](http://www.geekcomix.com/tux4kids/) \>

---

<div class="post-metadata">

**Author:** ![Teunis\_Peters](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/d07c76/32.png) [@Teunis\_Peters](https://discourse.libsdl.org/u/Teunis_Peters)\
**Post date:** [September 25, 2001, 9:57am UTC](https://discourse.libsdl.org/t/setting-callbacks-for-modules/5137/3 "2001-09-25T09:57:00Z")

</div>

> Is there a way using either SDL\_audio or SDL\_mixer that allows setting a  
> callback when playing a module and a certain instruction is found in the  
> module pattern? If not, are there plans for this in the 1.3 API?

That’s another reason to use, say, the mikmod library directly. Although  
I’m not sure it has the hook for what you’re asking for either…  
(I haven’t looked to closely)

Another reason is if you store your samples in, say, an MTM file  
(unsupported by SDL\_mixer incidentally) and wish to use them as sound  
effects… _g_

I doubt there will -ever- be hooks in SDL\_mixer for this… the code  
supports too many formats that arent module-based.

G’day, eh? 🙂  
- TeunisOn Tue, 25 Sep 2001, Ti Leggett wrote:

---

<div class="post-metadata">

**Author:** ![Ti\_Leggett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@Ti\_Leggett](https://discourse.libsdl.org/u/Ti_Leggett)\
**Post date:** [September 25, 2001, 11:19am UTC](https://discourse.libsdl.org/t/setting-callbacks-for-modules/5137/4 "2001-09-25T11:19:01Z")

</div>

> That’s another reason to use, say, the mikmod library directly. Although  
> I’m not sure it has the hook for what you’re asking for either…  
> (I haven’t looked to closely)

It appears that mikmod doesn’t support this either (unless it’s a  
non-intuitive function/macro name). I do know the midas library  
([Housemarque Audio System](http://www.s2.org/midas/)) supports this and I thought this one of the  
biggest selling points of using modules.

> I doubt there will -ever- be hooks in SDL\_mixer for this… the code  
> supports too many formats that arent module-based.

This is true but there is alpha channel support in SDL\_image, and that  
library supports graphic formats that don’t support alpha channels.

It wouldn’t even have to be callback neccessarily. It could be an event  
that’s generated.

I think this would be worth it and since it’s an effect of all module  
types, not adding a feature for only one format.

I’m not sure how the SDL submission guidelines work, but if I could hack  
up something to address this, how likely would it be to get included?  
i.e., should I just worry about making it work for me or think more  
globally.On Tue, 25 Sep 2001, winterlion wrote:
