GBDK sound example

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
GBDK sound example
by on (#57961)
Hi all,

I'm complete novice with GB programming, I'm only trying to work with sound and keypads. Anyway, I haven't seen any other examples in GBDK package than sound.c, don't understand it, could someone send here a simpler example like:

just one sound, any frequency, duty cycle 25% on first channel, duration 1 second

and perhaps instructions what is needed to use two other channels and noise channel.

I would be eternally grateful, thanks for advance !

-jp

by on (#57963)
Something like this:

Code:
unsigned short freq = 1750;  // approx 440 Hz

NR50 = 0xFF;
NR51 = 0xFF;
NR52 = 0x80;
 
NR10 = 0;         // No frequency sweep
NR11 = 0x40;   // 25% duty cycle
NR12 = 0xF0;   // Maximum volume
NR13 = (unsigned char)freq;
NR14 = 0x80 | (freq>>8); // Start output

// Wait for as long as you want to output sound..

// Mute channel 1 (there are other ways to do this)
NR12 = 0;
NR14 = 0x80;


Refer to pandocs for more info.

by on (#57968)
Thanks very much, now I will check documents for addresses to other channels, yes, I'm eternally grateful, thanks mic_ !!!


-Jukka



mic_ wrote:
Something like this:

Code:
unsigned short freq = 1750;  // approx 440 Hz

NR50 = 0xFF;
NR51 = 0xFF;
NR52 = 0x80;
 
NR10 = 0;         // No frequency sweep
NR11 = 0x40;   // 25% duty cycle
NR12 = 0xF0;   // Maximum volume
NR13 = (unsigned char)freq;
NR14 = 0x80 | (freq>>8); // Start output

// Wait for as long as you want to output sound..

// Mute channel 1 (there are other ways to do this)
NR12 = 0;
NR14 = 0x80;


Refer to pandocs for more info.