NightFox’s Lib
|
Simple helpers to load and play raw PCM sound files. More...
Data Structures | |
struct | NF_TYPE_RAWSOUND_INFO |
Struct that holds information about the loaded sound files. More... | |
Macros | |
#define | NF_SLOTS_RAWSOUND 32 |
Number of slot availables for raw sound effects. | |
Functions | |
void | NF_InitRawSoundBuffers (void) |
Initialize all buffers and variables to load sound files. More... | |
void | NF_ResetRawSoundBuffers (void) |
Resets all sound buffers and clears the data in them. More... | |
void | NF_LoadRawSound (const char *file, u32 id, u32 freq, u32 format) |
Load a RAW file from the filesystem to RAM. More... | |
void | NF_UnloadRawSound (u32 id) |
Deletes from RAM the sound file stored in the specified slot. More... | |
u32 | NF_PlayRawSound (u32 id, u32 volume, u32 pan, bool loop, u32 loopfrom) |
Play the sound file loaded in the specified slot. More... | |
Variables | |
char * | NF_BUFFER_RAWSOUND [NF_SLOTS_RAWSOUND] |
Buffers of all loaded sound files. | |
NF_TYPE_RAWSOUND_INFO | NF_RAWSOUND [NF_SLOTS_RAWSOUND] |
Information of all sound effects. | |
Simple helpers to load and play raw PCM sound files.
void NF_InitRawSoundBuffers | ( | void | ) |
Initialize all buffers and variables to load sound files.
You must use this function once before loading or using any sound file. Remember to initialize the DS sound engine using soundEnable().
void NF_LoadRawSound | ( | const char * | file, |
u32 | id, | ||
u32 | freq, | ||
u32 | format | ||
) |
Load a RAW file from the filesystem to RAM.
To convert sound files to "RAW" format you can use the free program "Switch" http://www.nch.com.au/switch/plus.html. The best parameters for "RAW" files on the DS are: 8 bits signed, mono, 11025 Hz or 22050 Hz.
Example:
file | File name without extension |
id | Destination slot number (0 - 31) |
freq | Frequency of the sample in Hz (11025, 22050, etc) |
format | Sample format (0 -> 8 bits, 1 -> 16 bits, 2 -> ADPCM). |
u32 NF_PlayRawSound | ( | u32 | id, |
u32 | volume, | ||
u32 | pan, | ||
bool | loop, | ||
u32 | loopfrom | ||
) |
Play the sound file loaded in the specified slot.
If you want to loop the sound you must also set the sample number where the loop starts.
This fuction also returns the channel number asigned to the playback.
Example:
You can use libnds functions to pause, stop and set the volume of the sound while it plays.
id | Slot number (0 - 31) |
volume | Volume (0 - 127) |
pan | Panning. 0: left, 64: center, 127: right. |
loop | True if you want the sound to loop. |
loopfrom | Loop starting point |
void NF_ResetRawSoundBuffers | ( | void | ) |
Resets all sound buffers and clears the data in them.
It's useful when you change a level in the game, for example.
void NF_UnloadRawSound | ( | u32 | id | ) |
Deletes from RAM the sound file stored in the specified slot.
id | Slot number (0 - 31) |