Possible PSG bug in libnds and other audio questions...

Post Reply
RotsiserMho
Posts: 1
Joined: Sat Feb 28, 2009 5:25 pm

Possible PSG bug in libnds and other audio questions...

Post by RotsiserMho » Sat Feb 28, 2009 5:41 pm

Hi all,

I'm brand new to DS development, so if my problem here is stupid, I apologize in advance.

I created a very tiny program to mess around with the PSG sound channels. Unfortunately, it seems that no matter what I set the duty cycle to, it all sounds the same. I've checked out the PSG capabilities in AXE so I know I can hear the difference, but that code seems a bit out of date (I'm assuming the hip new thing is to not write custom ARM7 code?).

In any case, here is how I have my code set up currently. It's horrible, but I don't think I'm doing anything wrong. If so, libnds is not correctly passing the duty cycle parameter on to the appropriate sound register. Any thoughts?

Also, what would be the most efficient way to get a close approximation of the NES triangle wave? Can the PSG come reasonably close?
Thanks!

Code: Select all

soundEnable();
mySound1 = soundPlayPSG(DutyCycle_12, 2094,5, 64);
mySound2 = soundPlayPSG(DutyCycle_87, 2094,5, 64);
while(1)  {
	scanKeys();
	touchRead(&touch);
	if(keysHeld() & KEY_TOUCH) {
	if (touch.rawy < 2000) {
		if (touch.rawx <= 760)
			soundSetFreq(mySound1, 1047 * 2);
		if ((touch.rawx > 760) && (touch.rawx <= 1235))
			soundSetFreq(mySound1, 1175 * 2);
		if ((touch.rawx > 1235) && (touch.rawx <= 1675))
			soundSetFreq(mySound1, 1319 * 2);
		if ((touch.rawx > 1675) && (touch.rawx <= 2130))
			soundSetFreq(mySound1, 1397 * 2);
		if ((touch.rawx > 2130) && (touch.rawx <= 2570))
			soundSetFreq(mySound1, 1568 * 2);
		if ((touch.rawx > 2570) && (touch.rawx <= 3010))
			soundSetFreq(mySound1, 1760 * 2);
		if ((touch.rawx > 3010) && (touch.rawx <= 3480))
			soundSetFreq(mySound1, 1976 * 2);
		if (touch.rawx > 3480)
			soundSetFreq(mySound1, 2093 * 2);
		soundResume(mySound1);
		soundPause(mySound2);
		}
	else {
		if (touch.rawx <= 760)
			soundSetFreq(mySound2, 1047 * 2);
		if ((touch.rawx > 760) && (touch.rawx <= 1235))
			soundSetFreq(mySound2, 1175 * 2);
		if ((touch.rawx > 1235) && (touch.rawx <= 1675))
			soundSetFreq(mySound2, 1319 * 2);
		if ((touch.rawx > 1675) && (touch.rawx <= 2130))
			soundSetFreq(mySound2, 1397 * 2);
		if ((touch.rawx > 2130) && (touch.rawx <= 2570))
			soundSetFreq(mySound2, 1568 * 2);
		if ((touch.rawx > 2570) && (touch.rawx <= 3010))
			soundSetFreq(mySound2, 1760 * 2);
		if ((touch.rawx > 3010) && (touch.rawx <= 3480))
			soundSetFreq(mySound2, 1976 * 2);
		if (touch.rawx > 3480)
			soundSetFreq(mySound2, 2093 * 2);
		soundResume(mySound2);
		soundPause(mySound1);
		}
	}
else {
		soundPause(mySound1);
		soundPause(mySound2);
	}
	swiWaitForVBlank();
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest