Mod Archive Forums

Community => Project / Coder's Corner => Topic started by: charles0111 on July 04, 2008, 12:34:49

Title: how to use some of the audio capability of Nintendo DS to play sound?
Post by: charles0111 on July 04, 2008, 12:34:49
Seening follow example:
     Given a pointer to an 8bit sample, recorded at 22,050Hz, where 'sample' is the start of the data, and 'sample_end' is the end, the following would set things up to play on channel 0:

  SCHANNEL_TIMER(0) = SOUND_FREQ(22050);
  SCHANNEL_SOURCE(0) = (uint32)sample;
  SCHANNEL_LENGTH(0) = ((int)sample_end - (int)sample) >> 2;
  SCHANNEL_CR(0) = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_8BIT |     SOUND_VOL(0x3F);

the details you may click follow link:http://www.double.co.nz/nintendo_ds/nds_develop4.html


my question is:
    we should oppoint what value for the SOUND_FREQ(?) and SOUND_BIT(?) is the fittest effect when to play a sound which format is such a mod or raw format.



 
Title: Re: how to use some of the audio capability of Nintendo DS to play sound?
Post by: sverx on July 04, 2008, 16:44:00
we should oppoint what value for the SOUND_FREQ(?) and SOUND_BIT(?) is the fittest effect when to play a sound which format is such a mod or raw format.

Playing a XM/MOD on a DS is a matter of giving these commands with the right values in the right moment. In easy words: if you play a sample at the same SOUND_FREQ() it has been sampled, you play the same sample -at the same pitch- that you recorded. To make a different note you need to use a different value of SOUND_FREQ(), and it's all about math. For instance if your sample is 22k sample per seconds playing it at 44k samples per second will make the same note one octave above and playing it at 11k samples per second will reproduce the same note one octave below.

SOUND_*BIT macro is needet to tell the DS about the 'format' of the sample. It can be 8 or 16 bits PCM, or 4 bits ADPCM

Title: Re: how to use some of the audio capability of Nintendo DS to play sound?
Post by: charles0111 on July 05, 2008, 02:07:50
hi sverx, :)thank you very much!