Thsound
From ProjectWiki
(Difference between revisions)
Line 1: | Line 1: | ||
==What is this?== | ==What is this?== | ||
+ | Some audio functions for the NDS. Features among other things include .wav file loading. | ||
==Functions common to both CPU== | ==Functions common to both CPU== | ||
Line 12: | Line 13: | ||
Load a sample from .wav file. Supported formats are 8bit mono, 16bit mono, and IMA-ADPCM. Stereo sample support MAY be added later. | Load a sample from .wav file. Supported formats are 8bit mono, 16bit mono, and IMA-ADPCM. Stereo sample support MAY be added later. | ||
* name - name of file to load | * name - name of file to load | ||
+ | Returns pointer to newly created sample. | ||
<source lang="c"> | <source lang="c"> | ||
thSample_t *thSampleLoadWav(const char *name); | thSample_t *thSampleLoadWav(const char *name); | ||
</source> | </source> | ||
− | |||
'''mmSampleCreate'''<br> | '''mmSampleCreate'''<br> | ||
Line 24: | Line 25: | ||
* rate - sample rate in hertz (44100, 11025, etc etc) | * rate - sample rate in hertz (44100, 11025, etc etc) | ||
* opts - options. Should include one each of: SNDPCM8, SNDPCM16, SNDADPCM. Additionally may OR on SNDLOOP (or even specify a default volume, pan, but wont get into this yet.. :P) | * opts - options. Should include one each of: SNDPCM8, SNDPCM16, SNDADPCM. Additionally may OR on SNDLOOP (or even specify a default volume, pan, but wont get into this yet.. :P) | ||
+ | Returns Pointer to newly created sample. | ||
<source lang="c"> | <source lang="c"> | ||
thSample_t *mmSampleCreate(void *start, int len, void *loopstart, int rate, u8 opts); | thSample_t *mmSampleCreate(void *start, int len, void *loopstart, int rate, u8 opts); | ||
</source> | </source> | ||
− | |||
Revision as of 11:13, 12 August 2008
Contents |
What is this?
Some audio functions for the NDS. Features among other things include .wav file loading.
Functions common to both CPU
thSndInit
This needs to be called at startup on both CPU before any other audio functions.
void thSndInit(void);
Sample loading and management functions
thSampleLoadWav
Load a sample from .wav file. Supported formats are 8bit mono, 16bit mono, and IMA-ADPCM. Stereo sample support MAY be added later.
- name - name of file to load
Returns pointer to newly created sample.
thSample_t *thSampleLoadWav(const char *name);
mmSampleCreate
Create a sample from raw audio data.
- start - pointer to start of sample in memory
- len - length of sample (in samples)
- loopstart - Loop point of sample. in number of samples from start.
- rate - sample rate in hertz (44100, 11025, etc etc)
- opts - options. Should include one each of: SNDPCM8, SNDPCM16, SNDADPCM. Additionally may OR on SNDLOOP (or even specify a default volume, pan, but wont get into this yet.. :P)
Returns Pointer to newly created sample.
thSample_t *mmSampleCreate(void *start, int len, void *loopstart, int rate, u8 opts);
Sound Playback functions
thPlayDefaults
Sets default sample playback options.
void thPlayDefaults(int rate, char level, char pan, u32 flags);
thSndPlaySample
Starts playing a previously loaded sample.
- chan - channel to use for playback
- sample - previously loaded sample
- vol - playback volume (0 to 127)
- pan - playback pan (0 to 127, 0 = left, 127 = right, 64 = center)
void thSndPlaySample(char chan, thSample_t *sample, char vol, char pan);
thSndPlayRaw
void thSndPlayRaw(char chan, void *start, int len, int rate, char vol, char pan, u32 loopstart, u32 opts);
thSndRegDirect
void thSndRegDirect(char chan, u32 start, int len, int rate, u32 loopstart, u32 opts);
thSndEzPlaySample
void thSndEzPlaySample(char chan, thSample_t *sample);
thSndEzPlayRaw
void thSndEzPlayRaw(char chan, void *start, int len);
thSndPlayNoise
void thSndPlayNoise(char chan, u16 rate, char vol, char pan);
thSndPlayNote
void thSndPlayNote(char chan, char note, char duty, char vol, char pan);
thSndStop
void thSndStop(char chan);
thSndSetVol
void thSndSetVol(char chan, char vol);
thSndSetPan
void thSndSetPan(char chan, char pan);
thSndSetRate
void thSndSetRate(char chan, u32 rate);
thSndSetDuty
void thSndSetDuty(char chan, char duty);
thSndFade
void thSndFade(char chan, u16 faderate);