It is currently Tue Oct 24, 2017 4:38 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GBDK sound example
PostPosted: Thu Mar 11, 2010 2:11 am 
Offline

Joined: Sun Mar 07, 2010 7:15 am
Posts: 45
Location: Kitee, North Karelia, Finland
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 3:18 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 4:20 am 
Offline

Joined: Sun Mar 07, 2010 7:15 am
Posts: 45
Location: Kitee, North Karelia, Finland
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group