In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Asndlib"

From WiiBrew
Jump to navigation Jump to search
m (moved Sndlib to Asndlib over redirect)
m (Categorized)
 
(18 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Infobox homebrewapp
+
'''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).
| image      =
 
| title      = Sndlib
 
| desc        = Sound library
 
| type        = Development
 
| version    = BETA 1.0
 
| author      = Hermes
 
| download    = [http://mods.elotrolado.net/~hermes/wii/sndlib_beta1.0_wii.rar sndlib_beta1.0_wii.rar]<br>[http://mods.elotrolado.net/~hermes/wii/sndlib_example.rar sndlib_example.rar]
 
| source      = Included
 
}}
 
  
'''Sndlib''' (also known as asndlib) 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.
+
== Features ==
  
===Release Announcement===
+
* Mixes internally @ 48000 Hz
 
+
* Handles 16 voices
Translated from the [[http://www.entuwii.net/foro/viewtopic.php?f=6&t=24&start=0&st=0&sk=t&sd=a Release Announcement]]
+
* 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
"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
+
* Ability to add a playback delay to create reverb or echo effects, or chaining
 +
* Dynamic pitch and volume adjustment (for special effects)
 +
* Two modes: simple and continuous double buffer
 +
* Various control functions, potential for callbacks, timers, etc
 +
* Support for MP3, Ogg, and MOD playback
  
Features:
+
== Usage ==
  
* Works with 32000Hz and 48000Hz due to hardware
+
Asndlib is included in the latest release of [[libogc]] under the name asnd. Just add -lasnd in your Makefile, and add #include <asndlib.h> to your list of headers, and then you can start using ASND_ functions!
  
* Handles 16 voices (configurable, though given the state of the mixing software, better be careful)
+
=== Audio Format ===
  
* Implementation of voices in Mono or Stereo, 8 or 16 bits (signed), with independent volume adjustment for each channel
+
The primary audio format accepted by asndlib is 16-bit, 2-channel (stereo), big-endian RAW PCM.
  
* Pitch control (frequency) for voices from 1Hz to 144000Hz
+
* To convert a file into this format using the command-line tool [http://sox.sourceforge.net/ sox] (Linux/OSX/Windows), use a command like the following:
 +
** <tt><nowiki>sox input.wav -t raw -b 16 --endian big -c 2 output.raw</nowiki></tt>
 +
* To export one of these files using [http://www.goldwave.com/ GoldWave] (Windows), choose the RAW format when saving.
  
* Ability to add a playback delay to create reverb or echo effects, or chaining.
+
=== MP3, Ogg, and MOD Playback ===
  
* Dynamic pitch and volume adjustment (for special effects)
+
See the examples/audio folder included with devkitPro for examples of how to play MP3, Ogg, and MOD files on the Wii using asnd.
  
* Three operation modes: simple, continuous double buffer, and musical notes
+
=== Simple mode ===
  
* Various control functions, potential for callbacks, timers, etc.
+
Run a voice program only once, allows you to adjust the format, frequency, delay, and volume of each channel. Ideal for sound effects.
  
* Added support for MODs, OGG (with libtremor) and a library for song creation (see song_lib.h)
+
=== Continuous double buffer mode ===
 
 
====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.
 
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.
Line 48: Line 39:
 
Ideal for music players (eg Modplay, which I have already adapted to work with this, or libtremor to play Ogg).
 
Ideal for music players (eg Modplay, which I have already adapted to work with this, or libtremor to play Ogg).
  
====Musical note mode====
+
== songlib ==
  
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.
+
Hermes' original sndlib also included a "musical note" feature called songlib for dynamic song generation. It has not been integrated into libogc, and unfortunately the source code has not been updated to work with the most recent libogc. However, the code remains here, as someone may still find it valuable, in whole or in part.
  
Ideal for small musical performances, improvised music, etc.
+
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.
+
=== Demo ===
  
====Examples====
+
* [[Media:hermes-songlib.zip|hermes-songlib.zip]] - sample applications that demonstrate various songlib features
  
* 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 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.
  
* 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).
 
 
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.
 
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
+
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!
 
 
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.
 
 
 
====Installation====
 
 
 
Snd lib 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!
 
  
====See Also====
+
== See Also ==
[[:Category:Homebrew_using_Sndlib|Homebrew using Sndlib]]
+
[[:Category:Homebrew using Sndlib|Homebrew using Asndlib]]
  
 
[[Category:Libraries]]
 
[[Category:Libraries]]

Latest revision as of 00:26, 14 May 2021

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).

Features

  • Mixes internally @ 48000 Hz
  • Handles 16 voices
  • 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)
  • Two modes: simple and continuous double buffer
  • Various control functions, potential for callbacks, timers, etc
  • Support for MP3, Ogg, and MOD playback

Usage

Asndlib is included in the latest release of libogc under the name asnd. Just add -lasnd in your Makefile, and add #include <asndlib.h> to your list of headers, and then you can start using ASND_ functions!

Audio Format

The primary audio format accepted by asndlib is 16-bit, 2-channel (stereo), big-endian RAW PCM.

  • To convert a file into this format using the command-line tool sox (Linux/OSX/Windows), use a command like the following:
    • sox input.wav -t raw -b 16 --endian big -c 2 output.raw
  • To export one of these files using GoldWave (Windows), choose the RAW format when saving.

MP3, Ogg, and MOD Playback

See the examples/audio folder included with devkitPro for examples of how to play MP3, Ogg, and MOD files on the Wii using asnd.

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).

songlib

Hermes' original sndlib also included a "musical note" feature called songlib for dynamic song generation. It has not been integrated into libogc, and unfortunately the source code has not been updated to work with the most recent libogc. However, the code remains here, as someone may still find it valuable, in whole or in part.

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.

Demo

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.

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!

See Also

Homebrew using Asndlib