Asndlib
This is an old revision of this page, as edited by Tantric (talk | contribs) at 08:54, 26 May 2009. It may differ significantly from the current revision. |
ASndlib (also known as sndlib) is a sound library for the Wii, included as part of libogc. It includes a software mixer capable of playing up to 16 voices at once, and one of the voices may be generated from a MOD file (using MODplay) or an OGG file (using libtremor). It also includes a "musical note" feature for dynamic song generation and some example applications that combine the various features.
Installation
Asndlib is included in the latest release of libogc under the name asnd. Just add -lasnd in your Makefile, and then you can start using SND_/ASND_ functions!
Release Announcement
Translated from the [Release Announcement]
"As promised, I already have the Wii sound library and just one day before my birthday, so we could say I'm the gift XD
Features:
- Works with 32000Hz and 48000Hz due to hardware
- Handles 16 voices (configurable, though given the state of the mixing software, better be careful)
- Implementation of voices in Mono or Stereo, 8 or 16 bits (signed), with independent volume adjustment for each channel
- Pitch control (frequency) for voices from 1Hz to 144000Hz
- Ability to add a playback delay to create reverb or echo effects, or chaining.
- Dynamic pitch and volume adjustment (for special effects)
- Three operation modes: simple, continuous double buffer, and musical notes
- Various control functions, potential for callbacks, timers, etc.
- Added support for MODs, OGG (with libtremor) and a library for song creation (see song_lib.h)
Simple mode
Run a voice program only once, allows you to adjust the format, frequency, delay, and volume of each channel. Ideal for sound effects.
Continuous double buffer mode
Schedule a voice similarly to simple mode, but add a callback function to be invoked when the voice can add new samples, using a special function.
Ideal for music players (eg Modplay, which I have already adapted to work with this, or libtremor to play Ogg).
Musical note mode
Uses a special function that allows you to specify a sample to be played in a loop, and then used by another function that lets you adjust the frequency, delay, attack, support, drop, and volume of the note.
Ideal for small musical performances, improvised music, etc.
song_lib relies on these functions for the execution of voices.
Examples
- sndlib_beta1.0_wii.rar
- sndlib_example.rar (source)
- The first example runs a MOD in the background using voice 0 and mixes it with some sound effects played on the other voices.
- The second example runs an OGG in the background using voice 0 and mixes it with some sound effects played on the other voices. If you include a file named "sample.ogg" in the root directory, it will alternate playing it and the original file.
Free mode: (Wiimote): Use A and B for mixing sound effect voices. Use - and + to change the playback speed for Ogg / Mod, and use 1 and 2 to activate the different background tracks. On the DPad, press Left / Right to move forward or backward within the Ogg (only works for the Ogg example).
Press Home or RESET to exit the application.
Indeed, the example also shows 900 rotating cubes in the background along with 900 sections of "land" and lighting composed of three "Spot" light sources to show that Rocky can still handle it! XD
Note: There shouldn't be any problem with porting these libraries to the GameCube: you'd only have to change the Makefiles to work for the GC, although snd.c (the core) is compiled for both versions. This can also be used on the PC, using the SDL port of Tremor, song_lib, and snd.c/snd.h.