Welcome! Log In Create A New Profile

Advanced

sound library tweak for AESNDLIB

Posted by Titmouse 
sound library tweak for AESNDLIB
November 25, 2011 11:41PM
I needed different behavior from AESNDLIB that would let me re-use a used voice, so I’ve tweaked my own AESND_AllocateNextFreeVoice function, with a trivial change.
My function works more like the other sound lib's ASND_GetFirstUnusedVoice, if like me you dynamically assigned sound. ( yes. . . you can use a callback, but why expose you side of the code to all that unnecessary work)
void AESND_Init()
{
// top part removed for example
	for(i=0;i<MAX_VOICES;i++)  // this is the 2nd loop in the original code
	{
		snd_set0w((int*)&__aesndvoicepb,sizeof(struct aesndpb_t)>>2);
		__aesndvoicepb.flags = VOICE_STOPPED; // added tweak
AESNDPB* AESND_AllocateNextFreeVoice(AESNDVoiceCallback cb) // new function
{
	u32 i,level;
	AESNDPB *pb = NULL;

	_CPU_ISR_Disable(level);
	for(i=0;i<MAX_VOICES;i++) {
		pb = &__aesndvoicepb;
		if (pb->flags&VOICE_STOPPED)   // changed, was if(!(pb->flags&VOICE_USED)) 
		{
// rest is unchanged as before

Must admit I’ve not really tested it, but it should work– if you try this out and see smoke coming out of your wii let me know
(2nd edit - fixed bad cut and paste - html invalid character thing)



Edited 1 time(s). Last edit at 11/25/2011 11:56PM by Titmouse.
Sorry, only registered users may post in this forum.

Click here to login