No sound with libogc

support for the powerpc toolchain
Post Reply
asper
Posts: 7
Joined: Tue Sep 21, 2010 1:39 pm

No sound with libogc

Post by asper » Tue Sep 21, 2010 1:48 pm

I installed the latest devkitPPC and I am coding an app for Nintendo Wii.

I used the codemii tutorials to build it but I have a problem with this sound tutorial

http://www.codemii.com/2009/04/21/tutor ... /#more-509

I manage to compile it but NO SOUND can be heard even if everything seems to be ok.

Can someone re-adapt this code in order to make it working with latest devkitPPC?

I re-say that it compiles fine but under a real wii no sound can be heard !

If a re-adapt is too laborious can someone write me there what have I to code in my Makefile and in main.c in order to make a file (mod, mp3 or whatever) palying in loop in background ? I mean:

1) What to include in MakeFile
2) Whato to add in main.c
#INCLUDE
int main()
other ?

My makefile has those libs:
LIBS := -ljpeg -lwiiuse -lmad -lbte -lfat -logc -lm -lmodplay -lasnd

My main.c has the above tutorial code

THANK YOU VERY VERY VERY MUCH !!!


Thank you to everyone that can answer me !

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: No sound with libogc

Post by WinterMute » Wed Sep 22, 2010 12:18 am

add #include <asndlib.h> and replace AUDIO_Init(NULL); with ASND_Init(NULL);

you already have libasnd linked so it should work fine from there.
Help keep devkitPro toolchains free, Donate today

Personal Blog

asper
Posts: 7
Joined: Tue Sep 21, 2010 1:39 pm

Re: No sound with libogc

Post by asper » Wed Sep 22, 2010 1:14 pm

Thank you VERY much for your quick reply !

This is the new code:

MakeFile libraries:

Code: Select all

LIBS	:=	-lwiiuse -lbte -logc -lmodplay  -lasnd -lm
main.c

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <gcmodplay.h>
#include <asndlib.h>

#include "loop_mod.h"

static u32 *xfb;
static GXRModeObj *rmode;

// Modplay
static MODPlay play; 

void Initialise() {
	
	VIDEO_Init();
	WPAD_Init();
	
	rmode = VIDEO_GetPreferredMode(NULL);
	
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
	
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	
	ASND_Init(NULL);
	MODPlay_Init(&play);

}

int main() {

	Initialise();
	
	MODPlay_SetMOD(&play, loop_mod);
	MODPlay_Start(&play);
	
	printf("\x1b[2;0H");
	printf("Playing mod file. Press Home to exit\n");
	
	while(1) {
		
		WPAD_ScanPads();
		u32 pressed = WPAD_ButtonsDown(0);
		
		if (pressed & WPAD_BUTTON_HOME) {
			MODPlay_Stop(&play);
			exit(0);
		}
		
		VIDEO_WaitVSync();
	}
	
	return 0;
}
If I compile simply adding #include <asndlib.h> it compiles fine, but when I substitute AUDIO_Init(NULL); with ASND_Init(NULL);
I obtain this (bad-realized collage-image :oops: ):
Image

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: No sound with libogc

Post by WinterMute » Thu Sep 23, 2010 10:03 am

Link order matters

Code: Select all

LIBS	:=	-lwiiuse -lbte -lmodplay  -lasnd -logc  -lm
As a general rule of thumb, -logc should always be last, followed by standard compiler libraries such as -lm
Help keep devkitPro toolchains free, Donate today

Personal Blog

asper
Posts: 7
Joined: Tue Sep 21, 2010 1:39 pm

Re: No sound with libogc

Post by asper » Thu Sep 23, 2010 10:59 am

It works ! Thank you MAN !!!!!!!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest