Simple sound engine crashes
Simple sound engine crashes
Hi, I'm attempting to port a gameboy emulator to the ds. I'm unable to play any kind of sound with libnds's sound.h. I call soundEnable() at the beginning of my code, presumably this powers on the sound hardware? As I attempt to call a function such as soundPlayPSG and soundPlayNoise, the ds crashes immediately. I'm unsure exactly how it's supposed to work, but calling soundSetFreq, soundSetVol, etc doesn't crash, but doesn't produce any sound either. It's said that the functions should work from the arm9 side, so I shouldn't have to make an arm7.cpp? Thanks in advance for any help.
-
- Site Admin
- Posts: 2003
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: Simple sound engine crashes
Can we see the code you're using, it's difficult to say what the problem might be otherwise.
Re: Simple sound engine crashes
There isn't much I haven't said.
It leaves me with simply a white top screen and black bottom screen.
Code: Select all
int main(void)
{
irqInit();
irqEnable(IRQ_VBLANK);
consoleDemoInit();
consoleDebugInit(DebugDevice_CONSOLE);
soundEnable();
while (true)
{
soundPlayPSG(DutyCycle_50, 500, 100, 64);
// Crashes here
printf("This command is never executed.\n");
swiWaitForVBlank();
}
return 0;
}
Re: Simple sound engine crashes
From the documentation it appears that you are only supposed to call this function once. You can use its return value to pause, resume, kill, etc. The interrupt handlers have already been initialised when you reach main, calling irqInit again will remove the fifo handlers and crash when you attempt to use functions that communicate with the arm7.
Your code should look like this:
Your code should look like this:
Code: Select all
int main(void)
{
consoleDemoInit();
consoleDebugInit(DebugDevice_CONSOLE);
soundEnable();
soundPlayPSG(DutyCycle_50, 500, 100, 64);
while (true)
{
printf("This command is never executed.\n");
// you don't know this never executed. it could have just not been flushed to vram yet
swiWaitForVBlank();
}
return 0;
}
Re: Simple sound engine crashes
Ah, so it was irqInit()! I must've been reading an obsolete resource. It works fine now. Thanks!
Re: Simple sound engine crashes
Oh yeah I guess I accidentally didn't copy that part from your code. I believe irqInit() is automatically called before main() now, among other things. If you are worried about reading outdated tutorials, you should take a look at the NDS examples that are optional to install during the devkitPro Updater. They are actually more up-to-date than any guide I've ever seen for this stuff.
Who is online
Users browsing this forum: No registered users and 1 guest