Thsound

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
(Sample loading and management functions)
Line 18: Line 18:
 
</source>
 
</source>
  
'''mmSampleCreate'''<br>
+
'''thSampleCreate'''<br>
 
Create a sample from raw audio data.  
 
Create a sample from raw audio data.  
 
* start - pointer to start of sample in memory
 
* start - pointer to start of sample in memory
Line 27: Line 27:
 
Returns Pointer to newly created sample.
 
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 *thSampleCreate(void *start, int len, void *loopstart, int rate, u8 opts);
 
</source>
 
</source>
  
 +
'''thSampleDestroy'''<br>
 +
Unloads a sample from memory. If it was loaded from .wav file will automagically unload that as well.. :p
 +
<source lang="c">
 +
void thSampleDestroy(thSample_t *thSample);
 +
</source>
  
 
==Sound Playback functions==
 
==Sound Playback functions==

Revision as of 12:18, 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);

thSampleCreate
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 *thSampleCreate(void *start, int len, void *loopstart, int rate, u8 opts);

thSampleDestroy
Unloads a sample from memory. If it was loaded from .wav file will automagically unload that as well.. :p

void thSampleDestroy(thSample_t *thSample);

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);
Personal tools
irssi scripts
eggdrop scripts