You will need to have an Amplitude project to follow these instructions. Please read the
project setup documentation to create a project. You can
also get one of the sample projects provided
in the GitHub repository.
Amplitude is built with several different components, which should be initialized separately before to start playing
audio.
Amplitudes comes with a very simple logger that you can customize to output messages in the console, a file, or any
other output that suits your needs.
Initializing the logger is optional, as it is not a required component. But if you want to use it, it is usually better
to initialize it first, as it is used in every part of the SDK.
The memory manager is the first required component to initialize. It is responsible for all the allocations
occurring in the SDK (even the ones due to other components initialization), and in your application.
While initializing the memory manager, you can customize the allocation functions through the MemoryManagerConfig
structure.
A typical memory manager initialization code will look like this:
The filesystem component is responsible to read/write resources as needed by the SDK. Amplitude comes shipped with a
DiskFileSystem implementation allowing you to access files on disk. You can easily create your own filesystem
implementation to fit your needs (eg: accessing assets from an archive or a package).
The used filesystem implementation should be set as the default one in the engine after the initialization. For
example, if you use the DiskFileSystem implementation, a typical usage will look like:
According to the implementation, the filesystem may be opened in a background thread (eg: unpacking an archive). If
it’s the case for you, it is necessary to wait for the filesystem to load before to continue. You can do this using the
following code:
The process is similar if you want to close your filesystem after the engine is being deinitialized or your application
is being closed:
Plugins allows you to extend the functionalities of the engine (eg: adding codecs, filters, faders, etc…), and
therefore, they should be loaded before the engine itself is initialized.
Amplitude comes shipped wih some default plugins you may enable if necessary. To do so, you should call the following
function:
You are also able to create custom plugins, and build them as shared libraries for use in your applications. These
libraries are loaded dynamically at runtime by the engine.
If using custom/external plugins, you must link Amplitude as a shared library to your program. Otherwise, your
program and plugins will not share the same memory space, and plugins won’t work properly.
The SDK allows you to set the paths in which to search for external plugins:
By default, the engine will search first in the working directory before to look in the search paths.
Once the search paths have been set, the engine can now load your plugins:
Note that the plugin is loaded using his canonical name, without prefix (eg: lib on UNIX platforms) and without
extension (eg: .dll on Windows platforms). Amplitude will add them for you automatically.