Libcwav 3DS: Difference between revisions

From GameBrew
(Created page with "{{Infobox 3DS homebrew | title = Libcwav | image = https://dlhb.gamebrew.org/3dshomebrew/Libcwav.jpg|250px | type = Media players | version = v1.0 | licence = Mixed | author =...")
 
No edit summary
Line 3: Line 3:
| image = https://dlhb.gamebrew.org/3dshomebrew/Libcwav.jpg|250px
| image = https://dlhb.gamebrew.org/3dshomebrew/Libcwav.jpg|250px
| type = Media players
| type = Media players
| version = v1.0
| version = v1.0 (27 Jan 2021)
| licence = Mixed
| licence = Mixed
| author = mariohackandglitch
| author = mariohackandglitch
Line 10: Line 10:
| source = https://dlhb.gamebrew.org/3dshomebrew/Libcwav.rar
| source = https://dlhb.gamebrew.org/3dshomebrew/Libcwav.rar
}}
}}
<youtube>oQsZ_MCmht4</youtube>


= libcwav =
libcwav is a library for playing (b)cwav files on the 3DS.


A library for playing '''(b)cwav''' files on the '''3DS'''.
The goal of this library is to provide an interface for playing (b)cwav files in 3DS homebrew sofware. The way it is designed allows to play these files in non-application environments, such as 3GX game plugins or applets, as it provides support for the CSND system service. Unlike (b)cstm files which are streamed in chunks from their storage media, (b)cwav files are fully loaded into the linear RAM. Therefore, (b)cwav files are only meant for small sound effects. This library provides support for the ADPCM encodings, which heavily reduce the required memory to play the file.


= Description =
==Installation==
Make sure you have [https://devkitpro.org/wiki/Getting_Started devkitpro] installed and working.


The goal of this library is to provide an interface for playing '''(b)cwav''' files in 3ds homebrew sofware. The way it is designed allows to play these files in non-application environments, such as ''3GX game plugins'' or ''applets'', as it provides support for the '''CSND''' system service. Unlike ''(b)cstm'' files which are streamed in chunks from their storage media, '''(b)cwav''' files are fully loaded into the linear RAM. Therefore, '''(b)cwav''' files are only meant for small sound effects. This library provides support for the '''ADPCM''' encodings, which heavily reduce the required memory to play the file.
Clone or download the repo and open a command prompt. Run <code>make install</code> and confirm there aren't any errors.


= Supported Features =
In your project makefile, add the following to the <code>LIBDIRS</code> line (or similar): <code>$(DEVKITPRO)/libcwav</code>


== Supported CWAV Audio Encodings ==
In your project makefile, add the following to the <code>LIBS</code> line (or similar): <code>-lcwav</code> if the already listed libraries start with <code>-l</code> or just <code>cwav</code> if they don't.


The following audio encodings are supported.
Add <code>#include &quot;cwav.h&quot;</code> and/or <code>#include &quot;cwav_file.h&quot;</code> in your source files to use the library.  


=== PCM8/PCM16 ===
You can check all the available function calls in the documentation provided in [[include/cwav.h|cwav.h]] and [[include/cwav_file.h|cwav_file.h]]. Also, you can see an example application in [[example_libcwav|example_libcwav]].


Uncompressed '''8/16 bit PCM'''. Useful if memory usage is not a problem.
==User guide==
===CWAV Audio Encodings===
The following audio encodings are supported:
* PCM8/PCM16 - Uncompressed 8/16 bit PCM. Useful if memory usage is not a problem.
* DSP ADPCM - Lossy compression format, useful if the available memory is limited. Can only be played with DSP.
* IMA ADPCM - Lossy compression format, similar to DSP ADPCM. Can only be played with CSND.


=== DSP ADPCM ===
===System Services===
The following system services used to play the audio are supported:
* DSP - This system service is used by normal applications. It is recommended to use this system service, as it properly supports suspending applications and sleep mode.
* CSND - This system service is used by applets to play audio. It has the advantage of playing audio on top of running/suspended applications, whitout causing any interferences.
** Use this system service if you want to play audio in applets or 3GX game plugins.
** Make sure to use <code>cwavDoAptHook()</code> or <code>cwavNotifyAptEvent()</code> to handle apt events (app suspend, sleep or exit).


Lossy compression format, useful if the available memory is limited. Can only be played with '''DSP'''.
===Create (b)cwav files===
You can use [https://github.com/mariohackandglitch/cwavtool cwavtool] to create (b)cwav files from other audio formats. It supports all possible encodings and loop points.


=== IMA ADPCM ===
==Media==
 
<youtube>oQsZ_MCmht4</youtube>
Lossy compression format, similar to '''DSP ADPCM'''. Can only be played with '''CSND'''.
 
== Supported System Services ==
 
The following system services used to play the audio are supported.
 
=== DSP ===
 
This system service is used by normal applications. It is recommended to use this system service, as it properly supports suspending applications and sleep mode.
 
=== CSND ===
 
This system service is used by ''applets'' to play audio. It has the advantage of playing audio on top of running/suspended applications, whitout causing any interferences. Use this system service if you want to play audio in ''applets'' or ''3GX game plugins''. Make sure to use ''<code>cwavDoAptHook()</code>'' or ''<code>cwavNotifyAptEvent()</code>'' to handle apt events (app suspend, sleep or exit)!
 
= Installation and Usage =
 
# Make sure you have [https://devkitpro.org/wiki/Getting_Started devkitpro] installed and working.
# Clone or download the repo and open a command prompt.
# Run <code>make install</code> and confirm there aren't any errors.
# In your project makefile, add the following to the <code>LIBDIRS</code> line (or similar): <code>$(DEVKITPRO)/libcwav</code>
# In your project makefile, add the following to the <code>LIBS</code> line (or similar): <code>-lcwav</code> if the already listed libraries start with <code>-l</code> or just <code>cwav</code> if they don't.
# Add <code>#include &quot;cwav.h&quot;</code> and/or <code>#include &quot;cwav_file.h&quot;</code> in your source files to use the library. You can check all the available function calls in the documentation provided in [[include/cwav.h|cwav.h]] and [[include/cwav_file.h|cwav_file.h]]. Also, you can see an example application in [[example_libcwav|example_libcwav]].
 
= Creating (b)cwav files =
 
You can use [https://github.com/mariohackandglitch/cwavtool cwavtool] to create '''(b)cwav''' files from other audio formats. It supports all possible encodings and loop points.
 
= Credits =
 
* [https://github.com/devkitPro/libctru libctru]: '''CSND''' and '''DSP''' implementation.
* [https://www.3dbrew.org/wiki/BCWAV 3dbrew.org]: '''(b)cwav''' file specification.
 
= License =


This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
==Credits==
[https://github.com/devkitPro/libctru libctru] - CSND and DSP implementation.


# The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
[https://www.3dbrew.org/wiki/BCWAV 3dbrew.org] - (b)cwav file specification.
# Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
# This notice may not be removed or altered from any source distribution.

Revision as of 02:07, 3 July 2021

Template:Infobox 3DS homebrew

libcwav is a library for playing (b)cwav files on the 3DS.

The goal of this library is to provide an interface for playing (b)cwav files in 3DS homebrew sofware. The way it is designed allows to play these files in non-application environments, such as 3GX game plugins or applets, as it provides support for the CSND system service. Unlike (b)cstm files which are streamed in chunks from their storage media, (b)cwav files are fully loaded into the linear RAM. Therefore, (b)cwav files are only meant for small sound effects. This library provides support for the ADPCM encodings, which heavily reduce the required memory to play the file.

Installation

Make sure you have devkitpro installed and working.

Clone or download the repo and open a command prompt. Run make install and confirm there aren't any errors.

In your project makefile, add the following to the LIBDIRS line (or similar): $(DEVKITPRO)/libcwav

In your project makefile, add the following to the LIBS line (or similar): -lcwav if the already listed libraries start with -l or just cwav if they don't.

Add #include "cwav.h" and/or #include "cwav_file.h" in your source files to use the library.

You can check all the available function calls in the documentation provided in cwav.h and cwav_file.h. Also, you can see an example application in example_libcwav.

User guide

CWAV Audio Encodings

The following audio encodings are supported:

  • PCM8/PCM16 - Uncompressed 8/16 bit PCM. Useful if memory usage is not a problem.
  • DSP ADPCM - Lossy compression format, useful if the available memory is limited. Can only be played with DSP.
  • IMA ADPCM - Lossy compression format, similar to DSP ADPCM. Can only be played with CSND.

System Services

The following system services used to play the audio are supported:

  • DSP - This system service is used by normal applications. It is recommended to use this system service, as it properly supports suspending applications and sleep mode.
  • CSND - This system service is used by applets to play audio. It has the advantage of playing audio on top of running/suspended applications, whitout causing any interferences.
    • Use this system service if you want to play audio in applets or 3GX game plugins.
    • Make sure to use cwavDoAptHook() or cwavNotifyAptEvent() to handle apt events (app suspend, sleep or exit).

Create (b)cwav files

You can use cwavtool to create (b)cwav files from other audio formats. It supports all possible encodings and loop points.

Media

Credits

libctru - CSND and DSP implementation.

3dbrew.org - (b)cwav file specification.

Advertising: