parent
d4c87fd755
commit
7dcab92739
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,2 @@ |
||||
~\Documents\emsdk\emsdk_env.ps1 activate latest |
||||
em++ -std=c++20 -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 -s USE_SDL_MIXER=2 $(Get-ChildItem *.cpp) -o pge.html --preload-file assets |
||||
em++ -std=c++20 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 -s USE_SDL_MIXER=2 -sSTACK_SIZE=5MB $(Get-ChildItem *.cpp) soloud.o -o pge.html --preload-file assets |
@ -0,0 +1,285 @@ |
||||
/*
|
||||
olcPGEX_AudioListener.h |
||||
|
||||
+-------------------------------------------------------------+ |
||||
| OneLoneCoder Pixel Game Engine Extension | |
||||
| AudioListener v1.0 | |
||||
+-------------------------------------------------------------+ |
||||
|
||||
What is this? |
||||
~~~~~~~~~~~~~ |
||||
This is an extension to the olcPixelGameEngine v2.16 and above. |
||||
|
||||
Its purpose is to allow audio integration into PGE which is |
||||
compatible with Emscripten for Web applications also. |
||||
|
||||
Unlike my other extensions, this one requires some external |
||||
libraries and additional setup (refer to github for instructions). |
||||
|
||||
In addition to the libraries the following files are required: |
||||
|
||||
olcPGEX_AudioListener.h (this file) |
||||
olcPGEX_AudioSource.h |
||||
|
||||
These can be found in the github repo as well... |
||||
|
||||
|
||||
What it can do: |
||||
~~~~~~~~~~~~~~~ |
||||
Play Audio! |
||||
|
||||
Using SDL2 as a backend and SoLoud as a frontend, this extension allows you |
||||
to easily load and manipulate sound in a way that is cross platform and also |
||||
has web support (using emscripten for PGE). |
||||
|
||||
In addition to the standard PLAY, PAUSE, and STOP controls you can also adjust |
||||
VOLUME settings and MODULATION (playback speed). |
||||
|
||||
WAV and OGG are supported on most backends, however MP3 is also supported by |
||||
SoLoud and SDL2 (even inside the web browser!). |
||||
|
||||
|
||||
Limitations: |
||||
~~~~~~~~~~~~ |
||||
Requires SDL2, SDL2_Mixer, and SoLoud libraries be installed and linked |
||||
successfully (detailed instructions on the github repo). |
||||
|
||||
|
||||
How Does It Work? |
||||
~~~~~~~~~~~~~~~~~ |
||||
Once you have followed the setup instructions on the github repo and |
||||
successfully compiled the test program you are ready to follow these |
||||
instructions... |
||||
|
||||
Add the following defines / includes underneath your olcPixelGameEngine |
||||
include: |
||||
|
||||
#define AUDIO_LISTENER_IMPLEMENTATION |
||||
#include "olcPGEX_AudioListener.h" |
||||
#define AUDIO_SOURCE_IMPLEMENTATION |
||||
#include "olcPGEX_AudioSource.h" |
||||
|
||||
(Order matters here, they must be included exactly as above!) |
||||
|
||||
In your declarations add exactly (1) AudioListener |
||||
|
||||
olcPGEX_AudioListener AL{}; |
||||
|
||||
|
||||
(Note: Currently, only 1 instance of an AudioListener is permitted) |
||||
|
||||
Now add at least (1) AudioSource (you will eventually add many of these) |
||||
|
||||
olcPGEX_AudioSource AS_Test{}; |
||||
|
||||
|
||||
In the OnUserCreate function you must now initialise the AudioListener |
||||
|
||||
AL.AudioSystemInit(); |
||||
|
||||
|
||||
Next we can assign our AudioListener to our AudioSource and load an audio file |
||||
|
||||
AS_Test.AL = &game.AL; |
||||
AS_Test.LoadAudioSample(1, "./assets/mus/Test.mp3"); |
||||
|
||||
|
||||
This assumes you have an MP3 file called "Test.mp3" in the listed folder in your |
||||
project directory. Also note the ID is set to "1" in this example. It is recommended |
||||
that you assign labels to your audio files as IDs instead so you can more easily |
||||
keep track of them. For example |
||||
|
||||
enum AUDIO |
||||
{ |
||||
NULL_SND = 0, // used as a default case
|
||||
TEST_SND = 1, |
||||
// add other sounds here
|
||||
}; |
||||
|
||||
AS_Test.LoadAudioSample(TEST_SND, "./assets/mus/Test.mp3"); |
||||
|
||||
This way you can easily refer to your sound without having to remember the integer |
||||
value you assigned it in the beginning... |
||||
|
||||
|
||||
Now all that is left to do is play the sound... |
||||
|
||||
In OnUserUpdate we can play / stop the sound using the SPACEBAR like so |
||||
|
||||
if (GetKey(olc::Key::SPACE).bPressed) |
||||
{ |
||||
if (AS_Test.bIsPlaying) |
||||
AS_Test.Stop(); |
||||
else |
||||
AS_Test.Play(); |
||||
|
||||
} |
||||
|
||||
|
||||
Those are the basics... other features can be accessed in much the same way. |
||||
|
||||
Enjoy! |
||||
|
||||
|
||||
|
||||
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2018 - 2019 OneLoneCoder.com |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions |
||||
are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above |
||||
copyright notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce |
||||
the above copyright notice. This list of conditions and the following |
||||
disclaimer must be reproduced in the documentation and/or other |
||||
materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its |
||||
contributors may be used to endorse or promote products derived |
||||
from this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
Author |
||||
~~~~~~ |
||||
Justin Richards |
||||
|
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
#ifndef OLC_PGEX_AUDIO_LISTENER |
||||
#define OLC_PGEX_AUDIO_LISTENER |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_wav.h" |
||||
|
||||
class olcPGEX_AudioListener : public olc::PGEX |
||||
{ |
||||
public: |
||||
// Struct to keep the Audio Sample data together
|
||||
struct sAudioSample |
||||
{ |
||||
sAudioSample(int ID, SoLoud::Wav* wavPtr) |
||||
{ |
||||
nSampleID = ID; |
||||
wav = wavPtr; |
||||
} |
||||
|
||||
int nSampleID; |
||||
SoLoud::Wav* wav; |
||||
}; |
||||
|
||||
// SoLoud Audio Engine Object
|
||||
SoLoud::Soloud soloud; |
||||
|
||||
// Position used for volume calculations
|
||||
olc::vf2d vecPos = { 0.0f, 0.0f }; |
||||
|
||||
// Global volume settings
|
||||
float fMusicVolume = 0.2f; |
||||
float fSoundFXVolume = 0.4f; |
||||
|
||||
bool bMusicOn = true; |
||||
bool bSoundOn = true; |
||||
|
||||
// Vector of Audio Samples
|
||||
std::vector<sAudioSample> audioSamples; |
||||
std::list<SoLoud::Wav> wavs; |
||||
|
||||
|
||||
|
||||
// Initialise the Audio Engine, and Destroy it when done
|
||||
void AudioSystemInit(); |
||||
void AudioSystemDestroy(); |
||||
|
||||
// Load a file and store it in the list of wavs
|
||||
void LoadAudioSample(int ID, const char* fileName); |
||||
|
||||
// Identify a particular Audio Sample based on its ID
|
||||
sAudioSample* GetAudioSampleByID(int ID); |
||||
|
||||
// Update the spacial position of the Audio Listener
|
||||
void UpdatePosition(olc::vf2d pos); |
||||
|
||||
// Calculate distance between listener and source
|
||||
float GetDistance(olc::vf2d sourcePos, bool returnRoot = true); |
||||
}; |
||||
|
||||
#ifdef AUDIO_LISTENER_IMPLEMENTATION |
||||
#undef AUDIO_LISTENER_IMPLEMENTATION |
||||
|
||||
void olcPGEX_AudioListener::AudioSystemInit() |
||||
{ |
||||
// Initialise the SoLoud backend
|
||||
soloud.init(); |
||||
} |
||||
|
||||
void olcPGEX_AudioListener::AudioSystemDestroy() |
||||
{ |
||||
// Clean up the SoLoud engine
|
||||
soloud.deinit(); |
||||
} |
||||
|
||||
void olcPGEX_AudioListener::LoadAudioSample(int ID, const char* fileName) |
||||
{ |
||||
// Search for any matching IDs
|
||||
for (auto& a : audioSamples) |
||||
if (a.nSampleID == ID) return; // Audio Sample is already loaded, no need to load the same file twice!
|
||||
|
||||
// Add a new wav to the list of wavs and get a pointer to it
|
||||
wavs.push_back(SoLoud::Wav()); |
||||
SoLoud::Wav* wavPtr = &wavs.back(); |
||||
|
||||
// Use the pointer to load the file into the back of the wav list
|
||||
wavPtr->load(fileName); |
||||
|
||||
// Create a new Audio sample object in the vector of samples that links both the ID and wav file itself, for convenience
|
||||
audioSamples.emplace_back(sAudioSample(ID, wavPtr)); |
||||
} |
||||
|
||||
olcPGEX_AudioListener::sAudioSample* olcPGEX_AudioListener::GetAudioSampleByID(int ID) |
||||
{ |
||||
// Look for matching IDs
|
||||
for (auto& a : audioSamples) |
||||
if (ID == a.nSampleID) return &a; // Match found! Return it...
|
||||
|
||||
// No match found, need to return a reference so we return the first sample in the list
|
||||
return &audioSamples[0]; |
||||
} |
||||
|
||||
void olcPGEX_AudioListener::UpdatePosition(olc::vf2d pos) |
||||
{ |
||||
// Position
|
||||
vecPos = pos; |
||||
} |
||||
|
||||
float olcPGEX_AudioListener::GetDistance(olc::vf2d sourcePos, bool returnRoot) |
||||
{ |
||||
// Return the distance via square root if needed, or the squared version when optimisation is possible
|
||||
if (returnRoot) |
||||
return sqrtf(abs(sourcePos.x * sourcePos.x - vecPos.x * vecPos.x) + abs(sourcePos.y * sourcePos.y - vecPos.y * vecPos.y)); |
||||
else |
||||
return abs(sourcePos.x * sourcePos.x - vecPos.x * vecPos.x) + abs(sourcePos.y * sourcePos.y - vecPos.y * vecPos.y); |
||||
|
||||
} |
||||
|
||||
#endif // AUDIO_LISTENER_IMPLEMENTATION
|
||||
|
||||
#endif |
@ -0,0 +1,224 @@ |
||||
/*
|
||||
olcPGEX_AudioSource.h |
||||
|
||||
+-------------------------------------------------------------+ |
||||
| OneLoneCoder Pixel Game Engine Extension | |
||||
| AudioSource v1.0 | |
||||
+-------------------------------------------------------------+ |
||||
|
||||
What is this? |
||||
~~~~~~~~~~~~~ |
||||
This is an extension to the olcPixelGameEngine v2.16 and above. |
||||
|
||||
It is to be used in conjunction with olcPGEX_AudioListener.h. |
||||
|
||||
A detailed description and instructions can be found in that |
||||
header file, please refer to it instead :-) |
||||
|
||||
Enjoy! |
||||
|
||||
|
||||
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2018 - 2019 OneLoneCoder.com |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions |
||||
are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above |
||||
copyright notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce |
||||
the above copyright notice. This list of conditions and the following |
||||
disclaimer must be reproduced in the documentation and/or other |
||||
materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its |
||||
contributors may be used to endorse or promote products derived |
||||
from this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
Author |
||||
~~~~~~ |
||||
Justin Richards |
||||
|
||||
*/ |
||||
|
||||
#ifndef OLC_PGEX_AUDIO_SOURCE |
||||
#define OLC_PGEX_AUDIO_SOURCE |
||||
|
||||
#pragma once |
||||
#include "olcPGEX_AudioListener.h" |
||||
|
||||
class olcPGEX_AudioSource : public olc::PGEX |
||||
{ |
||||
public: |
||||
// Pointer to the Audio Listener for this object
|
||||
olcPGEX_AudioListener* AL; |
||||
|
||||
// Handle for this particular copy of the sound
|
||||
int handle = 255; |
||||
|
||||
// Maximum copies of this sound allowed for this audio source
|
||||
//const int nMaxSamples = 4;
|
||||
//int nSampleHandles[4] = { 255, 255, 255, 255 };
|
||||
|
||||
// Audio Sample ID used to locate which sound to play
|
||||
int nID; |
||||
|
||||
// Convenient BOOL to determine playback status
|
||||
bool bIsPlaying = false; |
||||
|
||||
// Current Playback Speed
|
||||
float fPlaySpeed = 1.0f; |
||||
|
||||
// Volume
|
||||
float fVolume = 1.0f; |
||||
float fMinVolume = 0.0f; |
||||
float fMaxVolume = 1.0f; |
||||
|
||||
// Does the Audio Sample Loop?
|
||||
bool bLooping = false; |
||||
|
||||
// Paused status
|
||||
bool bPaused = false; |
||||
|
||||
// Object position, used for calculating volume
|
||||
olc::vf2d pos = { 0.0f, 0.0f }; |
||||
|
||||
|
||||
|
||||
// Instruct Audio Listener to load this sound (if not loaded already)
|
||||
void LoadAudioSample(int ID, const char* fileName); |
||||
|
||||
// Play the Audio Sample, with given parameters
|
||||
void Play(float speed = 1.0f, float vol = 1.0f, bool looping = false, bool paused = false); |
||||
|
||||
// Pause or Un-Pause - maintains the playback position and handle
|
||||
void Pause(bool pauseState = true); |
||||
|
||||
// Stop - playback position and handle will be lost
|
||||
void Stop(); |
||||
|
||||
// Audio Modulation - control the speed of playback
|
||||
void ModulateAudio(float minPlaySpeed, float maxPlaySpeed, float modulation, bool precise = false, bool deferred = false); |
||||
|
||||
// Adjust Volume
|
||||
void SetVolume(float vol, float minVol = 0.0f, float maxVol = 1.0f); |
||||
|
||||
// Set Default Parameters
|
||||
void SetDefaults(float speed, float vol, float minVol, float maxVol, bool looping); |
||||
}; |
||||
|
||||
#ifdef AUDIO_SOURCE_IMPLEMENTATION |
||||
#undef AUDIO_SOURCE_IMPLEMENTATION |
||||
|
||||
|
||||
void olcPGEX_AudioSource::LoadAudioSample(int ID, const char* fileName) |
||||
{ |
||||
// Link the IDs together
|
||||
nID = ID; |
||||
|
||||
// Call the Audio Listener to load the sample
|
||||
AL->LoadAudioSample(ID, fileName); |
||||
} |
||||
|
||||
void olcPGEX_AudioSource::Play(float speed, float vol, bool looping, bool paused) |
||||
{ |
||||
// Set parameters
|
||||
fPlaySpeed = speed; |
||||
fVolume = vol; |
||||
bLooping = looping; |
||||
bPaused = paused; |
||||
|
||||
// Assign a handle to this instance of the sound we are about to play
|
||||
handle = AL->soloud.play(*AL->GetAudioSampleByID(nID)->wav, fVolume, 0.0f, bPaused); |
||||
|
||||
// Set speed and looping
|
||||
AL->soloud.setRelativePlaySpeed(handle, fPlaySpeed); |
||||
AL->soloud.setLooping(handle, looping); |
||||
|
||||
// Update Play status
|
||||
bIsPlaying = true; |
||||
} |
||||
|
||||
void olcPGEX_AudioSource::Pause(bool pauseState) |
||||
{ |
||||
// Use the Audio Listener to pause or un-pause the sound as neccessary
|
||||
AL->soloud.setPause(handle, pauseState); |
||||
|
||||
// Update Play status
|
||||
bIsPlaying = !pauseState; |
||||
} |
||||
|
||||
void olcPGEX_AudioSource::Stop() |
||||
{ |
||||
// Use the Audio Listener to stop the sound
|
||||
AL->soloud.stop(handle); |
||||
|
||||
// The current handle will now point to nothing, so we set it to MAX so we can test for validity if need be
|
||||
handle = 255; |
||||
|
||||
// Update Play status
|
||||
bIsPlaying = false; |
||||
} |
||||
|
||||
void olcPGEX_AudioSource::ModulateAudio(float minPlaySpeed, float maxPlaySpeed, float modulation, bool precise, bool deferred) |
||||
{ |
||||
// Apply the modulation
|
||||
if (precise) |
||||
fPlaySpeed = modulation; |
||||
else |
||||
fPlaySpeed += modulation; |
||||
|
||||
// Adjust the play speed to keep it within range
|
||||
if (fPlaySpeed < minPlaySpeed) fPlaySpeed = minPlaySpeed; |
||||
else if (fPlaySpeed > maxPlaySpeed) fPlaySpeed = maxPlaySpeed; |
||||
|
||||
// If multiple adjustments to the playback speed are required, then the Audio Listener update itself can be
|
||||
// deferred until the very last adjustment is made... A small optimisation
|
||||
if (!deferred) |
||||
AL->soloud.setRelativePlaySpeed(handle, fPlaySpeed); |
||||
} |
||||
|
||||
void olcPGEX_AudioSource::SetVolume(float vol, float minVol, float maxVol) |
||||
{ |
||||
// Set volume
|
||||
fVolume = vol; |
||||
|
||||
// Clamp volume withing set bounds
|
||||
if (fVolume < minVol) |
||||
fVolume = minVol; |
||||
else if (fVolume > maxVol) |
||||
fVolume = maxVol; |
||||
|
||||
// Instruct the Audio Listener to apply the volume change
|
||||
AL->soloud.setVolume(handle, fVolume); |
||||
} |
||||
|
||||
void olcPGEX_AudioSource::SetDefaults(float speed, float vol, float minVol, float maxVol, bool looping) |
||||
{ |
||||
// Set defaults for this particular Audio Source
|
||||
fPlaySpeed = speed; |
||||
fVolume = vol; |
||||
fMinVolume = minVol; |
||||
fMaxVolume = maxVol; |
||||
bLooping = looping; |
||||
} |
||||
|
||||
#endif // AUDIO_SOURCE_IMPLEMENTATION
|
||||
#endif |
Before Width: | Height: | Size: 47 MiB After Width: | Height: | Size: 465 KiB |
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,555 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_H |
||||
#define SOLOUD_H |
||||
|
||||
#include <stdlib.h> // rand |
||||
#include <math.h> // sin |
||||
|
||||
#ifdef SOLOUD_NO_ASSERTS |
||||
#define SOLOUD_ASSERT(x) |
||||
#else |
||||
#ifdef _MSC_VER |
||||
#include <stdio.h> // for sprintf in asserts |
||||
#ifndef VC_EXTRALEAN |
||||
#define VC_EXTRALEAN |
||||
#endif |
||||
#ifndef WIN32_LEAN_AND_MEAN |
||||
#define WIN32_LEAN_AND_MEAN |
||||
#endif |
||||
#include <windows.h> // only needed for OutputDebugStringA, should be solved somehow. |
||||
#define SOLOUD_ASSERT(x) if (!(x)) { char temp[200]; sprintf(temp, "%s(%d): assert(%s) failed.\n", __FILE__, __LINE__, #x); OutputDebugStringA(temp); __debugbreak(); } |
||||
#else |
||||
#include <assert.h> // assert |
||||
#define SOLOUD_ASSERT(x) assert(x) |
||||
#endif |
||||
#endif |
||||
|
||||
#ifdef WITH_SDL |
||||
#undef WITH_SDL2 |
||||
#undef WITH_SDL1 |
||||
#define WITH_SDL1 |
||||
#define WITH_SDL2 |
||||
#endif |
||||
|
||||
#ifdef WITH_SDL_STATIC |
||||
#undef WITH_SDL1_STATIC |
||||
#define WITH_SDL1_STATIC |
||||
#endif |
||||
|
||||
#ifndef M_PI |
||||
#define M_PI 3.14159265359 |
||||
#endif |
||||
|
||||
#if defined(_WIN32)||defined(_WIN64) |
||||
#define WINDOWS_VERSION |
||||
#endif |
||||
|
||||
#if !defined(DISABLE_SIMD) |
||||
#if defined(__x86_64__) || defined( _M_X64 ) || defined( __i386 ) || defined( _M_IX86 ) |
||||
#define SOLOUD_SSE_INTRINSICS |
||||
#endif |
||||
#endif |
||||
|
||||
#define SOLOUD_VERSION 202002 |
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Configuration defines
|
||||
|
||||
// Maximum number of filters per stream
|
||||
#define FILTERS_PER_STREAM 8 |
||||
|
||||
// Number of samples to process on one go
|
||||
#define SAMPLE_GRANULARITY 512 |
||||
|
||||
// Maximum number of concurrent voices (hard limit is 4095)
|
||||
#define VOICE_COUNT 1024 |
||||
|
||||
// Use linear resampler
|
||||
#define RESAMPLER_LINEAR |
||||
|
||||
// 1)mono, 2)stereo 4)quad 6)5.1 8)7.1
|
||||
#define MAX_CHANNELS 8 |
||||
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Typedefs have to be made before the includes, as the
|
||||
// includes depend on them.
|
||||
namespace SoLoud |
||||
{ |
||||
class Soloud; |
||||
typedef void (*mutexCallFunction)(void *aMutexPtr); |
||||
typedef void (*soloudCallFunction)(Soloud *aSoloud); |
||||
typedef unsigned int result; |
||||
typedef unsigned int handle; |
||||
typedef double time; |
||||
}; |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
// Class that handles aligned allocations to support vectorized operations
|
||||
class AlignedFloatBuffer |
||||
{ |
||||
public: |
||||
float *mData; // aligned pointer
|
||||
unsigned char *mBasePtr; // raw allocated pointer (for delete)
|
||||
int mFloats; // size of buffer (w/out padding)
|
||||
|
||||
// ctor
|
||||
AlignedFloatBuffer(); |
||||
// Allocate and align buffer
|
||||
result init(unsigned int aFloats); |
||||
// Clear data to zero.
|
||||
void clear(); |
||||
// dtor
|
||||
~AlignedFloatBuffer(); |
||||
}; |
||||
|
||||
// Lightweight class that handles small aligned buffer to support vectorized operations
|
||||
class TinyAlignedFloatBuffer |
||||
{ |
||||
public: |
||||
float *mData; // aligned pointer
|
||||
unsigned char mActualData[sizeof(float) * 16 + 16]; |
||||
|
||||
// ctor
|
||||
TinyAlignedFloatBuffer(); |
||||
}; |
||||
}; |
||||
|
||||
#include "soloud_filter.h" |
||||
#include "soloud_fader.h" |
||||
#include "soloud_audiosource.h" |
||||
#include "soloud_bus.h" |
||||
#include "soloud_queue.h" |
||||
#include "soloud_error.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
|
||||
// Soloud core class.
|
||||
class Soloud |
||||
{ |
||||
public: |
||||
// Back-end data; content is up to the back-end implementation.
|
||||
void * mBackendData; |
||||
// Pointer for the audio thread mutex.
|
||||
void * mAudioThreadMutex; |
||||
// Flag for when we're inside the mutex, used for debugging.
|
||||
bool mInsideAudioThreadMutex; |
||||
// Called by SoLoud to shut down the back-end. If NULL, not called. Should be set by back-end.
|
||||
soloudCallFunction mBackendCleanupFunc; |
||||
|
||||
// CTor
|
||||
Soloud(); |
||||
// DTor
|
||||
~Soloud(); |
||||
|
||||
enum BACKENDS |
||||
{ |
||||
AUTO = 0, |
||||
SDL1, |
||||
SDL2, |
||||
PORTAUDIO, |
||||
WINMM, |
||||
XAUDIO2, |
||||
WASAPI, |
||||
ALSA, |
||||
JACK, |
||||
OSS, |
||||
OPENAL, |
||||
COREAUDIO, |
||||
OPENSLES, |
||||
VITA_HOMEBREW, |
||||
MINIAUDIO, |
||||
NOSOUND, |
||||
NULLDRIVER, |
||||
BACKEND_MAX, |
||||
}; |
||||
|
||||
enum FLAGS |
||||
{ |
||||
// Use round-off clipper
|
||||
CLIP_ROUNDOFF = 1, |
||||
ENABLE_VISUALIZATION = 2, |
||||
LEFT_HANDED_3D = 4, |
||||
NO_FPU_REGISTER_CHANGE = 8 |
||||
}; |
||||
|
||||
// Initialize SoLoud. Must be called before SoLoud can be used.
|
||||
result init(unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aBackend = Soloud::AUTO, unsigned int aSamplerate = Soloud::AUTO, unsigned int aBufferSize = Soloud::AUTO, unsigned int aChannels = 2); |
||||
|
||||
// Deinitialize SoLoud. Must be called before shutting down.
|
||||
void deinit(); |
||||
|
||||
// Query SoLoud version number (should equal to SOLOUD_VERSION macro)
|
||||
unsigned int getVersion() const; |
||||
|
||||
// Translate error number to an asciiz string
|
||||
const char * getErrorString(result aErrorCode) const; |
||||
|
||||
// Returns current backend ID (BACKENDS enum)
|
||||
unsigned int getBackendId(); |
||||
// Returns current backend string. May be NULL.
|
||||
const char * getBackendString(); |
||||
// Returns current backend channel count (1 mono, 2 stereo, etc)
|
||||
unsigned int getBackendChannels(); |
||||
// Returns current backend sample rate
|
||||
unsigned int getBackendSamplerate(); |
||||
// Returns current backend buffer size
|
||||
unsigned int getBackendBufferSize(); |
||||
|
||||
// Set speaker position in 3d space
|
||||
result setSpeakerPosition(unsigned int aChannel, float aX, float aY, float aZ); |
||||
// Get speaker position in 3d space
|
||||
result getSpeakerPosition(unsigned int aChannel, float &aX, float &aY, float &aZ); |
||||
|
||||
// Start playing a sound. Returns voice handle, which can be ignored or used to alter the playing sound's parameters. Negative volume means to use default.
|
||||
handle play(AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, bool aPaused = 0, unsigned int aBus = 0); |
||||
// Start playing a sound delayed in relation to other sounds called via this function. Negative volume means to use default.
|
||||
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, unsigned int aBus = 0); |
||||
// Start playing a 3d audio source
|
||||
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0, unsigned int aBus = 0); |
||||
// Start playing a 3d audio source, delayed in relation to other sounds called via this function.
|
||||
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, unsigned int aBus = 0); |
||||
// Start playing a sound without any panning. It will be played at full volume.
|
||||
handle playBackground(AudioSource &aSound, float aVolume = -1.0f, bool aPaused = 0, unsigned int aBus = 0); |
||||
|
||||
// Seek the audio stream to certain point in time. Some streams can't seek backwards. Relative play speed affects time.
|
||||
result seek(handle aVoiceHandle, time aSeconds); |
||||
// Stop the sound.
|
||||
void stop(handle aVoiceHandle); |
||||
// Stop all voices.
|
||||
void stopAll(); |
||||
// Stop all voices that play this sound source
|
||||
void stopAudioSource(AudioSource &aSound); |
||||
// Count voices that play this audio source
|
||||
int countAudioSource(AudioSource &aSound); |
||||
|
||||
// Set a live filter parameter. Use 0 for the global filters.
|
||||
void setFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); |
||||
// Get a live filter parameter. Use 0 for the global filters.
|
||||
float getFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); |
||||
// Fade a live filter parameter. Use 0 for the global filters.
|
||||
void fadeFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, time aTime); |
||||
// Oscillate a live filter parameter. Use 0 for the global filters.
|
||||
void oscillateFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, time aTime); |
||||
|
||||
// Get current play time, in seconds.
|
||||
time getStreamTime(handle aVoiceHandle); |
||||
// Get current sample position, in seconds.
|
||||
time getStreamPosition(handle aVoiceHandle); |
||||
// Get current pause state.
|
||||
bool getPause(handle aVoiceHandle); |
||||
// Get current volume.
|
||||
float getVolume(handle aVoiceHandle); |
||||
// Get current overall volume (set volume * 3d volume)
|
||||
float getOverallVolume(handle aVoiceHandle); |
||||
// Get current pan.
|
||||
float getPan(handle aVoiceHandle); |
||||
// Get current sample rate.
|
||||
float getSamplerate(handle aVoiceHandle); |
||||
// Get current voice protection state.
|
||||
bool getProtectVoice(handle aVoiceHandle); |
||||
// Get the current number of busy voices.
|
||||
unsigned int getActiveVoiceCount(); |
||||
// Get the current number of voices in SoLoud
|
||||
unsigned int getVoiceCount(); |
||||
// Check if the handle is still valid, or if the sound has stopped.
|
||||
bool isValidVoiceHandle(handle aVoiceHandle); |
||||
// Get current relative play speed.
|
||||
float getRelativePlaySpeed(handle aVoiceHandle); |
||||
// Get current post-clip scaler value.
|
||||
float getPostClipScaler() const; |
||||
// Get current global volume
|
||||
float getGlobalVolume() const; |
||||
// Get current maximum active voice setting
|
||||
unsigned int getMaxActiveVoiceCount() const; |
||||
// Query whether a voice is set to loop.
|
||||
bool getLooping(handle aVoiceHandle); |
||||
// Get voice loop point value
|
||||
time getLoopPoint(handle aVoiceHandle); |
||||
|
||||
// Set voice loop point value
|
||||
void setLoopPoint(handle aVoiceHandle, time aLoopPoint); |
||||
// Set voice's loop state
|
||||
void setLooping(handle aVoiceHandle, bool aLooping); |
||||
// Set current maximum active voice setting
|
||||
result setMaxActiveVoiceCount(unsigned int aVoiceCount); |
||||
// Set behavior for inaudible sounds
|
||||
void setInaudibleBehavior(handle aVoiceHandle, bool aMustTick, bool aKill); |
||||
// Set the global volume
|
||||
void setGlobalVolume(float aVolume); |
||||
// Set the post clip scaler value
|
||||
void setPostClipScaler(float aScaler); |
||||
// Set the pause state
|
||||
void setPause(handle aVoiceHandle, bool aPause); |
||||
// Pause all voices
|
||||
void setPauseAll(bool aPause); |
||||
// Set the relative play speed
|
||||
result setRelativePlaySpeed(handle aVoiceHandle, float aSpeed); |
||||
// Set the voice protection state
|
||||
void setProtectVoice(handle aVoiceHandle, bool aProtect); |
||||
// Set the sample rate
|
||||
void setSamplerate(handle aVoiceHandle, float aSamplerate); |
||||
// Set panning value; -1 is left, 0 is center, 1 is right
|
||||
void setPan(handle aVoiceHandle, float aPan); |
||||
// Set absolute left/right volumes
|
||||
void setPanAbsolute(handle aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume = 0, float aRBVolume = 0, float aCVolume = 0, float aSVolume = 0); |
||||
// Set overall volume
|
||||
void setVolume(handle aVoiceHandle, float aVolume); |
||||
// Set delay, in samples, before starting to play samples. Calling this on a live sound will cause glitches.
|
||||
void setDelaySamples(handle aVoiceHandle, unsigned int aSamples); |
||||
|
||||
// Set up volume fader
|
||||
void fadeVolume(handle aVoiceHandle, float aTo, time aTime); |
||||
// Set up panning fader
|
||||
void fadePan(handle aVoiceHandle, float aTo, time aTime); |
||||
// Set up relative play speed fader
|
||||
void fadeRelativePlaySpeed(handle aVoiceHandle, float aTo, time aTime); |
||||
// Set up global volume fader
|
||||
void fadeGlobalVolume(float aTo, time aTime); |
||||
// Schedule a stream to pause
|
||||
void schedulePause(handle aVoiceHandle, time aTime); |
||||
// Schedule a stream to stop
|
||||
void scheduleStop(handle aVoiceHandle, time aTime); |
||||
|
||||
// Set up volume oscillator
|
||||
void oscillateVolume(handle aVoiceHandle, float aFrom, float aTo, time aTime); |
||||
// Set up panning oscillator
|
||||
void oscillatePan(handle aVoiceHandle, float aFrom, float aTo, time aTime); |
||||
// Set up relative play speed oscillator
|
||||
void oscillateRelativePlaySpeed(handle aVoiceHandle, float aFrom, float aTo, time aTime); |
||||
// Set up global volume oscillator
|
||||
void oscillateGlobalVolume(float aFrom, float aTo, time aTime); |
||||
|
||||
// Set global filters. Set to NULL to clear the filter.
|
||||
void setGlobalFilter(unsigned int aFilterId, Filter *aFilter); |
||||
|
||||
// Enable or disable visualization data gathering
|
||||
void setVisualizationEnable(bool aEnable); |
||||
|
||||
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
|
||||
float *calcFFT(); |
||||
|
||||
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
|
||||
float *getWave(); |
||||
|
||||
// Get approximate output volume for a channel for visualization. Visualization has to be enabled before use.
|
||||
float getApproximateVolume(unsigned int aChannel); |
||||
|
||||
// Get current loop count. Returns 0 if handle is not valid. (All audio sources may not update loop count)
|
||||
unsigned int getLoopCount(handle aVoiceHandle); |
||||
|
||||
// Get audiosource-specific information from a voice.
|
||||
float getInfo(handle aVoiceHandle, unsigned int aInfoKey); |
||||
|
||||
// Create a voice group. Returns 0 if unable (out of voice groups / out of memory)
|
||||
handle createVoiceGroup(); |
||||
// Destroy a voice group.
|
||||
result destroyVoiceGroup(handle aVoiceGroupHandle); |
||||
// Add a voice handle to a voice group
|
||||
result addVoiceToGroup(handle aVoiceGroupHandle, handle aVoiceHandle); |
||||
// Is this handle a valid voice group?
|
||||
bool isVoiceGroup(handle aVoiceGroupHandle); |
||||
// Is this voice group empty?
|
||||
bool isVoiceGroupEmpty(handle aVoiceGroupHandle); |
||||
|
||||
// Perform 3d audio parameter update
|
||||
void update3dAudio(); |
||||
|
||||
// Set the speed of sound constant for doppler
|
||||
result set3dSoundSpeed(float aSpeed); |
||||
// Get the current speed of sound constant for doppler
|
||||
float get3dSoundSpeed(); |
||||
// Set 3d listener parameters
|
||||
void set3dListenerParameters(float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); |
||||
// Set 3d listener position
|
||||
void set3dListenerPosition(float aPosX, float aPosY, float aPosZ); |
||||
// Set 3d listener "at" vector
|
||||
void set3dListenerAt(float aAtX, float aAtY, float aAtZ); |
||||
// set 3d listener "up" vector
|
||||
void set3dListenerUp(float aUpX, float aUpY, float aUpZ); |
||||
// Set 3d listener velocity
|
||||
void set3dListenerVelocity(float aVelocityX, float aVelocityY, float aVelocityZ); |
||||
|
||||
// Set 3d audio source parameters
|
||||
void set3dSourceParameters(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); |
||||
// Set 3d audio source position
|
||||
void set3dSourcePosition(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ); |
||||
// Set 3d audio source velocity
|
||||
void set3dSourceVelocity(handle aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); |
||||
// Set 3d audio source min/max distance (distance < min means max volume)
|
||||
void set3dSourceMinMaxDistance(handle aVoiceHandle, float aMinDistance, float aMaxDistance); |
||||
// Set 3d audio source attenuation parameters
|
||||
void set3dSourceAttenuation(handle aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
// Set 3d audio source doppler factor to reduce or enhance doppler effect. Default = 1.0
|
||||
void set3dSourceDopplerFactor(handle aVoiceHandle, float aDopplerFactor); |
||||
|
||||
// Rest of the stuff is used internally.
|
||||
|
||||
// Returns mixed float samples in buffer. Called by the back-end, or user with null driver.
|
||||
void mix(float *aBuffer, unsigned int aSamples); |
||||
// Returns mixed 16-bit signed integer samples in buffer. Called by the back-end, or user with null driver.
|
||||
void mixSigned16(short *aBuffer, unsigned int aSamples); |
||||
public: |
||||
// Mix N samples * M channels. Called by other mix_ functions.
|
||||
void mix_internal(unsigned int aSamples); |
||||
|
||||
// Handle rest of initialization (called from backend)
|
||||
void postinit_internal(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels); |
||||
|
||||
// Update list of active voices
|
||||
void calcActiveVoices_internal(); |
||||
// Map resample buffers to active voices
|
||||
void mapResampleBuffers_internal(); |
||||
// Perform mixing for a specific bus
|
||||
void mixBus_internal(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels); |
||||
// Find a free voice, stopping the oldest if no free voice is found.
|
||||
int findFreeVoice_internal(); |
||||
// Converts handle to voice, if the handle is valid. Returns -1 if not.
|
||||
int getVoiceFromHandle_internal(handle aVoiceHandle) const; |
||||
// Converts voice + playindex into handle
|
||||
handle getHandleFromVoice_internal(unsigned int aVoice) const; |
||||
// Stop voice (not handle).
|
||||
void stopVoice_internal(unsigned int aVoice); |
||||
// Set voice (not handle) pan.
|
||||
void setVoicePan_internal(unsigned int aVoice, float aPan); |
||||
// Set voice (not handle) relative play speed.
|
||||
result setVoiceRelativePlaySpeed_internal(unsigned int aVoice, float aSpeed); |
||||
// Set voice (not handle) volume.
|
||||
void setVoiceVolume_internal(unsigned int aVoice, float aVolume); |
||||
// Set voice (not handle) pause state.
|
||||
void setVoicePause_internal(unsigned int aVoice, int aPause); |
||||
// Update overall volume from set and 3d volumes
|
||||
void updateVoiceVolume_internal(unsigned int aVoice); |
||||
// Update overall relative play speed from set and 3d speeds
|
||||
void updateVoiceRelativePlaySpeed_internal(unsigned int aVoice); |
||||
// Perform 3d audio calculation for array of voices
|
||||
void update3dVoices_internal(unsigned int *aVoiceList, unsigned int aVoiceCount); |
||||
// Clip the samples in the buffer
|
||||
void clip_internal(AlignedFloatBuffer &aBuffer, AlignedFloatBuffer &aDestBuffer, unsigned int aSamples, float aVolume0, float aVolume1); |
||||
// Remove all non-active voices from group
|
||||
void trimVoiceGroup_internal(handle aVoiceGroupHandle); |
||||
// Get pointer to the zero-terminated array of voice handles in a voice group
|
||||
handle * voiceGroupHandleToArray_internal(handle aVoiceGroupHandle) const; |
||||
|
||||
// Lock audio thread mutex.
|
||||
void lockAudioMutex_internal(); |
||||
// Unlock audio thread mutex.
|
||||
void unlockAudioMutex_internal(); |
||||
|
||||
// Max. number of active voices. Busses and tickable inaudibles also count against this.
|
||||
unsigned int mMaxActiveVoices; |
||||
// Highest voice in use so far
|
||||
unsigned int mHighestVoice; |
||||
// Scratch buffer, used for resampling.
|
||||
AlignedFloatBuffer mScratch; |
||||
// Current size of the scratch, in samples.
|
||||
unsigned int mScratchSize; |
||||
// Amount of scratch needed.
|
||||
unsigned int mScratchNeeded; |
||||
// Output scratch buffer, used in mix_().
|
||||
AlignedFloatBuffer mOutputScratch; |
||||
// Resampler buffers, two per active voice.
|
||||
AlignedFloatBuffer *mResampleData; |
||||
// Owners of the resample data
|
||||
AudioSourceInstance **mResampleDataOwner; |
||||
// Audio voices.
|
||||
AudioSourceInstance *mVoice[VOICE_COUNT]; |
||||
// Output sample rate (not float)
|
||||
unsigned int mSamplerate; |
||||
// Output channel count
|
||||
unsigned int mChannels; |
||||
// Current backend ID
|
||||
unsigned int mBackendID; |
||||
// Current backend string
|
||||
const char * mBackendString; |
||||
// Maximum size of output buffer; used to calculate needed scratch.
|
||||
unsigned int mBufferSize; |
||||
// Flags; see Soloud::FLAGS
|
||||
unsigned int mFlags; |
||||
// Global volume. Applied before clipping.
|
||||
float mGlobalVolume; |
||||
// Post-clip scaler. Applied after clipping.
|
||||
float mPostClipScaler; |
||||
// Current play index. Used to create audio handles.
|
||||
unsigned int mPlayIndex; |
||||
// Current sound source index. Used to create sound source IDs.
|
||||
unsigned int mAudioSourceID; |
||||
// Fader for the global volume.
|
||||
Fader mGlobalVolumeFader; |
||||
// Global stream time, for the global volume fader.
|
||||
time mStreamTime; |
||||
// Last time seen by the playClocked call
|
||||
time mLastClockedTime; |
||||
// Global filter
|
||||
Filter *mFilter[FILTERS_PER_STREAM]; |
||||
// Global filter instance
|
||||
FilterInstance *mFilterInstance[FILTERS_PER_STREAM]; |
||||
|
||||
// Approximate volume for channels.
|
||||
float mVisualizationChannelVolume[MAX_CHANNELS]; |
||||
// Mono-mixed wave data for visualization and for visualization FFT input
|
||||
float mVisualizationWaveData[256]; |
||||
// FFT output data
|
||||
float mFFTData[256]; |
||||
// Snapshot of wave data for visualization
|
||||
float mWaveData[256]; |
||||
|
||||
// 3d listener position
|
||||
float m3dPosition[3]; |
||||
// 3d listener look-at
|
||||
float m3dAt[3]; |
||||
// 3d listener up
|
||||
float m3dUp[3]; |
||||
// 3d listener velocity
|
||||
float m3dVelocity[3]; |
||||
// 3d speed of sound (for doppler)
|
||||
float m3dSoundSpeed; |
||||
|
||||
// 3d position of speakers
|
||||
float m3dSpeakerPosition[3 * MAX_CHANNELS]; |
||||
|
||||
// Data related to 3d processing, separate from AudioSource so we can do 3d calculations without audio mutex.
|
||||
AudioSourceInstance3dData m3dData[VOICE_COUNT]; |
||||
|
||||
// For each voice group, first int is number of ints alocated.
|
||||
unsigned int **mVoiceGroup; |
||||
unsigned int mVoiceGroupCount; |
||||
|
||||
// List of currently active voices
|
||||
unsigned int mActiveVoice[VOICE_COUNT]; |
||||
// Number of currently active voices
|
||||
unsigned int mActiveVoiceCount; |
||||
// Active voices list needs to be recalculated
|
||||
bool mActiveVoiceDirty; |
||||
}; |
||||
}; |
||||
|
||||
#endif |
Binary file not shown.
@ -0,0 +1,315 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_AUDIOSOURCE_H |
||||
#define SOLOUD_AUDIOSOURCE_H |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_fader.h" |
||||
#include "soloud_filter.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class AudioSource;
|
||||
class AudioSourceInstance; |
||||
class AudioSourceInstance3dData; |
||||
|
||||
class AudioCollider |
||||
{ |
||||
public: |
||||
// Calculate volume multiplier. Assumed to return value between 0 and 1.
|
||||
virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0; |
||||
}; |
||||
|
||||
class AudioAttenuator |
||||
{ |
||||
public: |
||||
virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0; |
||||
}; |
||||
|
||||
class AudioSourceInstance3dData |
||||
{ |
||||
public: |
||||
// ctor
|
||||
AudioSourceInstance3dData(); |
||||
// Set settings from audiosource
|
||||
void init(AudioSource &aSource); |
||||
// 3d position
|
||||
float m3dPosition[3]; |
||||
// 3d velocity
|
||||
float m3dVelocity[3]; |
||||
// 3d cone direction
|
||||
/*
|
||||
float m3dConeDirection[3]; |
||||
// 3d cone inner angle
|
||||
float m3dConeInnerAngle; |
||||
// 3d cone outer angle
|
||||
float m3dConeOuterAngle; |
||||
// 3d cone outer volume multiplier
|
||||
float m3dConeOuterVolume; |
||||
*/ |
||||
// 3d min distance
|
||||
float m3dMinDistance; |
||||
// 3d max distance
|
||||
float m3dMaxDistance; |
||||
// 3d attenuation rolloff factor
|
||||
float m3dAttenuationRolloff; |
||||
// 3d attenuation model
|
||||
unsigned int m3dAttenuationModel; |
||||
// 3d doppler factor
|
||||
float m3dDopplerFactor; |
||||
// Pointer to a custom audio collider object
|
||||
AudioCollider *mCollider; |
||||
// Pointer to a custom audio attenuator object
|
||||
AudioAttenuator *mAttenuator; |
||||
// User data related to audio collider
|
||||
int mColliderData; |
||||
|
||||
// Doppler sample rate multiplier
|
||||
float mDopplerValue;
|
||||
// Overall 3d volume
|
||||
float m3dVolume; |
||||
// Channel volume
|
||||
float mChannelVolume[MAX_CHANNELS]; |
||||
// Copy of flags
|
||||
unsigned int mFlags; |
||||
// Latest handle for this voice
|
||||
handle mHandle; |
||||
}; |
||||
|
||||
// Base class for audio instances
|
||||
class AudioSourceInstance |
||||
{ |
||||
public: |
||||
enum FLAGS |
||||
{
|
||||
// This audio instance loops (if supported)
|
||||
LOOPING = 1, |
||||
// This audio instance is protected - won't get stopped if we run out of voices
|
||||
PROTECTED = 2, |
||||
// This audio instance is paused
|
||||
PAUSED = 4, |
||||
// This audio instance is affected by 3d processing
|
||||
PROCESS_3D = 8, |
||||
// This audio instance has listener-relative 3d coordinates
|
||||
LISTENER_RELATIVE = 16, |
||||
// Currently inaudible
|
||||
INAUDIBLE = 32, |
||||
// If inaudible, should be killed (default = don't kill kill)
|
||||
INAUDIBLE_KILL = 64, |
||||
// If inaudible, should still be ticked (default = pause)
|
||||
INAUDIBLE_TICK = 128 |
||||
}; |
||||
// Ctor
|
||||
AudioSourceInstance(); |
||||
// Dtor
|
||||
virtual ~AudioSourceInstance(); |
||||
// Play index; used to identify instances from handles
|
||||
unsigned int mPlayIndex; |
||||
// Loop count
|
||||
unsigned int mLoopCount; |
||||
// Flags; see AudioSourceInstance::FLAGS
|
||||
unsigned int mFlags; |
||||
// Pan value, for getPan()
|
||||
float mPan; |
||||
// Volume for each channel (panning)
|
||||
float mChannelVolume[MAX_CHANNELS]; |
||||
// Set volume
|
||||
float mSetVolume; |
||||
// Overall volume overall = set * 3d
|
||||
float mOverallVolume; |
||||
// Base samplerate; samplerate = base samplerate * relative play speed
|
||||
float mBaseSamplerate; |
||||
// Samplerate; samplerate = base samplerate * relative play speed
|
||||
float mSamplerate; |
||||
// Number of channels this audio source produces
|
||||
unsigned int mChannels; |
||||
// Relative play speed; samplerate = base samplerate * relative play speed
|
||||
float mSetRelativePlaySpeed; |
||||
// Overall relative plays peed; overall = set * 3d
|
||||
float mOverallRelativePlaySpeed; |
||||
// How long this stream has played, in seconds.
|
||||
time mStreamTime; |
||||
// Position of this stream, in seconds.
|
||||
time mStreamPosition; |
||||
// Fader for the audio panning
|
||||
Fader mPanFader; |
||||
// Fader for the audio volume
|
||||
Fader mVolumeFader; |
||||
// Fader for the relative play speed
|
||||
Fader mRelativePlaySpeedFader; |
||||
// Fader used to schedule pausing of the stream
|
||||
Fader mPauseScheduler; |
||||
// Fader used to schedule stopping of the stream
|
||||
Fader mStopScheduler; |
||||
// Affected by some fader
|
||||
int mActiveFader; |
||||
// Current channel volumes, used to ramp the volume changes to avoid clicks
|
||||
float mCurrentChannelVolume[MAX_CHANNELS]; |
||||
// ID of the sound source that generated this instance
|
||||
unsigned int mAudioSourceID; |
||||
// Handle of the bus this audio instance is playing on. 0 for root.
|
||||
unsigned int mBusHandle; |
||||
// Filter pointer
|
||||
FilterInstance *mFilter[FILTERS_PER_STREAM]; |
||||
// Initialize instance. Mostly internal use.
|
||||
void init(AudioSource &aSource, int aPlayIndex); |
||||
// Buffers for the resampler
|
||||
AlignedFloatBuffer *mResampleData[2]; |
||||
// Sub-sample playhead; 16.16 fixed point
|
||||
unsigned int mSrcOffset; |
||||
// Samples left over from earlier pass
|
||||
unsigned int mLeftoverSamples; |
||||
// Number of samples to delay streaming
|
||||
unsigned int mDelaySamples; |
||||
// When looping, start playing from this time
|
||||
time mLoopPoint; |
||||
|
||||
// Get N samples from the stream to the buffer. Report samples written.
|
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize) = 0; |
||||
// Has the stream ended?
|
||||
virtual bool hasEnded() = 0; |
||||
// Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow).
|
||||
virtual result seek(time aSeconds, float *mScratch, unsigned int mScratchSize); |
||||
// Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind.
|
||||
virtual result rewind(); |
||||
// Get information. Returns 0 by default.
|
||||
virtual float getInfo(unsigned int aInfoKey); |
||||
}; |
||||
|
||||
class Soloud; |
||||
|
||||
// Base class for audio sources
|
||||
class AudioSource |
||||
{ |
||||
public: |
||||
enum FLAGS |
||||
{ |
||||
// The instances from this audio source should loop
|
||||
SHOULD_LOOP = 1, |
||||
// Only one instance of this audio source should play at the same time
|
||||
SINGLE_INSTANCE = 2, |
||||
// Visualization data gathering enabled. Only for busses.
|
||||
VISUALIZATION_DATA = 4, |
||||
// Audio instances created from this source are affected by 3d processing
|
||||
PROCESS_3D = 8, |
||||
// Audio instances created from this source have listener-relative 3d coordinates
|
||||
LISTENER_RELATIVE = 16, |
||||
// Delay start of sound by the distance from listener
|
||||
DISTANCE_DELAY = 32, |
||||
// If inaudible, should be killed (default)
|
||||
INAUDIBLE_KILL = 64, |
||||
// If inaudible, should still be ticked (default = pause)
|
||||
INAUDIBLE_TICK = 128 |
||||
}; |
||||
enum ATTENUATION_MODELS |
||||
{ |
||||
// No attenuation
|
||||
NO_ATTENUATION = 0, |
||||
// Inverse distance attenuation model
|
||||
INVERSE_DISTANCE = 1, |
||||
// Linear distance attenuation model
|
||||
LINEAR_DISTANCE = 2, |
||||
// Exponential distance attenuation model
|
||||
EXPONENTIAL_DISTANCE = 3 |
||||
}; |
||||
|
||||
// Flags. See AudioSource::FLAGS
|
||||
unsigned int mFlags; |
||||
// Base sample rate, used to initialize instances
|
||||
float mBaseSamplerate; |
||||
// Default volume for created instances
|
||||
float mVolume; |
||||
// Number of channels this audio source produces
|
||||
unsigned int mChannels; |
||||
// Sound source ID. Assigned by SoLoud the first time it's played.
|
||||
unsigned int mAudioSourceID; |
||||
// 3d min distance
|
||||
float m3dMinDistance; |
||||
// 3d max distance
|
||||
float m3dMaxDistance; |
||||
// 3d attenuation rolloff factor
|
||||
float m3dAttenuationRolloff; |
||||
// 3d attenuation model
|
||||
unsigned int m3dAttenuationModel; |
||||
// 3d doppler factor
|
||||
float m3dDopplerFactor; |
||||
// Filter pointer
|
||||
Filter *mFilter[FILTERS_PER_STREAM]; |
||||
// Pointer to the Soloud object. Needed to stop all instances in dtor.
|
||||
Soloud *mSoloud; |
||||
// Pointer to a custom audio collider object
|
||||
AudioCollider *mCollider; |
||||
// Pointer to custom attenuator object
|
||||
AudioAttenuator *mAttenuator; |
||||
// User data related to audio collider
|
||||
int mColliderData; |
||||
// When looping, start playing from this time
|
||||
time mLoopPoint; |
||||
|
||||
// CTor
|
||||
AudioSource(); |
||||
// Set default volume for instances
|
||||
void setVolume(float aVolume); |
||||
// Set the looping of the instances created from this audio source
|
||||
void setLooping(bool aLoop); |
||||
// Set whether only one instance of this sound should ever be playing at the same time
|
||||
void setSingleInstance(bool aSingleInstance); |
||||
|
||||
// Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol)
|
||||
void set3dMinMaxDistance(float aMinDistance, float aMaxDistance); |
||||
// Set attenuation model and rolloff factor for 3d audio source
|
||||
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
// Set doppler factor to reduce or enhance doppler effect, default = 1.0
|
||||
void set3dDopplerFactor(float aDopplerFactor); |
||||
// Set the coordinates for this audio source to be relative to listener's coordinates.
|
||||
void set3dListenerRelative(bool aListenerRelative); |
||||
// Enable delaying the start of the sound based on the distance.
|
||||
void set3dDistanceDelay(bool aDistanceDelay); |
||||
|
||||
// Set a custom 3d audio collider. Set to NULL to disable.
|
||||
void set3dCollider(AudioCollider *aCollider, int aUserData = 0); |
||||
// Set a custom attenuator. Set to NULL to disable.
|
||||
void set3dAttenuator(AudioAttenuator *aAttenuator); |
||||
|
||||
// Set behavior for inaudible sounds
|
||||
void setInaudibleBehavior(bool aMustTick, bool aKill); |
||||
|
||||
// Set time to jump to when looping
|
||||
void setLoopPoint(time aLoopPoint); |
||||
// Get current loop point value
|
||||
time getLoopPoint(); |
||||
|
||||
// Set filter. Set to NULL to clear the filter.
|
||||
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); |
||||
// DTor
|
||||
virtual ~AudioSource(); |
||||
// Create instance from the audio source. Called from within Soloud class.
|
||||
virtual AudioSourceInstance *createInstance() = 0; |
||||
// Stop all instances of this audio source
|
||||
void stop(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,68 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_BASSBOOSTFILTER_H |
||||
#define SOLOUD_BASSBOOSTFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_fftfilter.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class BassboostFilter; |
||||
|
||||
class BassboostFilterInstance : public FFTFilterInstance |
||||
{ |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
BOOST = 1 |
||||
}; |
||||
BassboostFilter *mParent; |
||||
public: |
||||
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
BassboostFilterInstance(BassboostFilter *aParent); |
||||
}; |
||||
|
||||
class BassboostFilter : public FFTFilter |
||||
{ |
||||
public: |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
BOOST = 1 |
||||
}; |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
float mBoost; |
||||
result setParams(float aBoost); |
||||
virtual FilterInstance *createInstance(); |
||||
BassboostFilter(); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,94 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2014 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_BQRFILTER_H |
||||
#define SOLOUD_BQRFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class BiquadResonantFilter; |
||||
|
||||
struct BQRStateData |
||||
{ |
||||
float mY1, mY2, mX1, mX2; |
||||
}; |
||||
|
||||
class BiquadResonantFilterInstance : public FilterInstance |
||||
{ |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
TYPE, |
||||
FREQUENCY, |
||||
RESONANCE |
||||
}; |
||||
|
||||
BQRStateData mState[8]; |
||||
float mA0, mA1, mA2, mB1, mB2; |
||||
int mDirty; |
||||
float mSamplerate; |
||||
|
||||
BiquadResonantFilter *mParent; |
||||
void calcBQRParams(); |
||||
public: |
||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
virtual ~BiquadResonantFilterInstance(); |
||||
BiquadResonantFilterInstance(BiquadResonantFilter *aParent); |
||||
}; |
||||
|
||||
class BiquadResonantFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERTYPE |
||||
{ |
||||
LOWPASS = 0, |
||||
HIGHPASS = 1, |
||||
BANDPASS = 2 |
||||
}; |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
TYPE, |
||||
FREQUENCY, |
||||
RESONANCE |
||||
}; |
||||
int mFilterType; |
||||
float mFrequency; |
||||
float mResonance; |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
|
||||
virtual BiquadResonantFilterInstance *createInstance(); |
||||
BiquadResonantFilter(); |
||||
result setParams(int aType, float aFrequency, float aResonance); |
||||
virtual ~BiquadResonantFilter(); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,96 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_BUS_H |
||||
#define SOLOUD_BUS_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Bus; |
||||
|
||||
class BusInstance : public AudioSourceInstance |
||||
{ |
||||
Bus *mParent; |
||||
unsigned int mScratchSize; |
||||
AlignedFloatBuffer mScratch; |
||||
public: |
||||
// Approximate volume for channels.
|
||||
float mVisualizationChannelVolume[MAX_CHANNELS]; |
||||
// Mono-mixed wave data for visualization and for visualization FFT input
|
||||
float mVisualizationWaveData[256]; |
||||
|
||||
BusInstance(Bus *aParent); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
virtual ~BusInstance(); |
||||
}; |
||||
|
||||
class Bus : public AudioSource |
||||
{ |
||||
public: |
||||
Bus(); |
||||
virtual BusInstance *createInstance(); |
||||
// Set filter. Set to NULL to clear the filter.
|
||||
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); |
||||
// Play sound through the bus
|
||||
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0); |
||||
// Play sound through the bus, delayed in relation to other sounds called via this function.
|
||||
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f); |
||||
// Start playing a 3d audio source through the bus
|
||||
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0); |
||||
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
|
||||
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f); |
||||
// Set number of channels for the bus (default 2)
|
||||
result setChannels(unsigned int aChannels); |
||||
// Enable or disable visualization data gathering
|
||||
void setVisualizationEnable(bool aEnable); |
||||
// Move a live sound to this bus
|
||||
void annexSound(handle aVoiceHandle); |
||||
|
||||
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
|
||||
float *calcFFT(); |
||||
|
||||
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
|
||||
float *getWave(); |
||||
|
||||
// Get approximate volume for output channel for visualization. Visualization has to be enabled before use.
|
||||
float getApproximateVolume(unsigned int aChannel); |
||||
|
||||
// Get number of immediate child voices to this bus
|
||||
unsigned int getActiveVoiceCount(); |
||||
public: |
||||
BusInstance *mInstance; |
||||
unsigned int mChannelHandle; |
||||
// FFT output data
|
||||
float mFFTData[256]; |
||||
// Snapshot of wave data for visualization
|
||||
float mWaveData[256]; |
||||
// Internal: find the bus' channel
|
||||
void findBusHandle(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,710 @@ |
||||
/* **************************************************
|
||||
* WARNING: this is a generated file. Do not edit. * |
||||
* Any edits will be overwritten by the generator. * |
||||
************************************************** */ |
||||
|
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
/* SoLoud C-Api Code Generator (c)2013-2020 Jari Komppa http://iki.fi/sol/ */ |
||||
|
||||
#ifndef SOLOUD_C_H_INCLUDED |
||||
#define SOLOUD_C_H_INCLUDED |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
// Collected enumerations
|
||||
enum SOLOUD_ENUMS |
||||
{ |
||||
SOLOUD_AUTO = 0, |
||||
SOLOUD_SDL1 = 1, |
||||
SOLOUD_SDL2 = 2, |
||||
SOLOUD_PORTAUDIO = 3, |
||||
SOLOUD_WINMM = 4, |
||||
SOLOUD_XAUDIO2 = 5, |
||||
SOLOUD_WASAPI = 6, |
||||
SOLOUD_ALSA = 7, |
||||
SOLOUD_JACK = 8, |
||||
SOLOUD_OSS = 9, |
||||
SOLOUD_OPENAL = 10, |
||||
SOLOUD_COREAUDIO = 11, |
||||
SOLOUD_OPENSLES = 12, |
||||
SOLOUD_VITA_HOMEBREW = 13, |
||||
SOLOUD_MINIAUDIO = 14, |
||||
SOLOUD_NOSOUND = 15, |
||||
SOLOUD_NULLDRIVER = 16, |
||||
SOLOUD_BACKEND_MAX = 17, |
||||
SOLOUD_CLIP_ROUNDOFF = 1, |
||||
SOLOUD_ENABLE_VISUALIZATION = 2, |
||||
SOLOUD_LEFT_HANDED_3D = 4, |
||||
SOLOUD_NO_FPU_REGISTER_CHANGE = 8, |
||||
BASSBOOSTFILTER_WET = 0, |
||||
BASSBOOSTFILTER_BOOST = 1, |
||||
BIQUADRESONANTFILTER_LOWPASS = 0, |
||||
BIQUADRESONANTFILTER_HIGHPASS = 1, |
||||
BIQUADRESONANTFILTER_BANDPASS = 2, |
||||
BIQUADRESONANTFILTER_WET = 0, |
||||
BIQUADRESONANTFILTER_TYPE = 1, |
||||
BIQUADRESONANTFILTER_FREQUENCY = 2, |
||||
BIQUADRESONANTFILTER_RESONANCE = 3, |
||||
ECHOFILTER_WET = 0, |
||||
ECHOFILTER_DELAY = 1, |
||||
ECHOFILTER_DECAY = 2, |
||||
ECHOFILTER_FILTER = 3, |
||||
FLANGERFILTER_WET = 0, |
||||
FLANGERFILTER_DELAY = 1, |
||||
FLANGERFILTER_FREQ = 2, |
||||
FREEVERBFILTER_WET = 0, |
||||
FREEVERBFILTER_FREEZE = 1, |
||||
FREEVERBFILTER_ROOMSIZE = 2, |
||||
FREEVERBFILTER_DAMP = 3, |
||||
FREEVERBFILTER_WIDTH = 4, |
||||
LOFIFILTER_WET = 0, |
||||
LOFIFILTER_SAMPLERATE = 1, |
||||
LOFIFILTER_BITDEPTH = 2, |
||||
NOISE_WHITE = 0, |
||||
NOISE_PINK = 1, |
||||
NOISE_BROWNISH = 2, |
||||
NOISE_BLUEISH = 3, |
||||
ROBOTIZEFILTER_WET = 0, |
||||
ROBOTIZEFILTER_FREQ = 1, |
||||
ROBOTIZEFILTER_WAVE = 2, |
||||
SFXR_COIN = 0, |
||||
SFXR_LASER = 1, |
||||
SFXR_EXPLOSION = 2, |
||||
SFXR_POWERUP = 3, |
||||
SFXR_HURT = 4, |
||||
SFXR_JUMP = 5, |
||||
SFXR_BLIP = 6, |
||||
SPEECH_KW_SAW = 0, |
||||
SPEECH_KW_TRIANGLE = 1, |
||||
SPEECH_KW_SIN = 2, |
||||
SPEECH_KW_SQUARE = 3, |
||||
SPEECH_KW_PULSE = 4, |
||||
SPEECH_KW_NOISE = 5, |
||||
SPEECH_KW_WARBLE = 6, |
||||
VIC_PAL = 0, |
||||
VIC_NTSC = 1, |
||||
VIC_BASS = 0, |
||||
VIC_ALTO = 1, |
||||
VIC_SOPRANO = 2, |
||||
VIC_NOISE = 3, |
||||
VIC_MAX_REGS = 4, |
||||
WAVESHAPERFILTER_WET = 0, |
||||
WAVESHAPERFILTER_AMOUNT = 1 |
||||
}; |
||||
|
||||
// Object handle typedefs
|
||||
typedef void * AlignedFloatBuffer; |
||||
typedef void * TinyAlignedFloatBuffer; |
||||
typedef void * Soloud; |
||||
typedef void * AudioCollider; |
||||
typedef void * AudioAttenuator; |
||||
typedef void * AudioSource; |
||||
typedef void * BassboostFilter; |
||||
typedef void * BiquadResonantFilter; |
||||
typedef void * Bus; |
||||
typedef void * DCRemovalFilter; |
||||
typedef void * EchoFilter; |
||||
typedef void * Fader; |
||||
typedef void * FFTFilter; |
||||
typedef void * Filter; |
||||
typedef void * FlangerFilter; |
||||
typedef void * FreeverbFilter; |
||||
typedef void * LofiFilter; |
||||
typedef void * Monotone; |
||||
typedef void * Noise; |
||||
typedef void * Openmpt; |
||||
typedef void * Queue; |
||||
typedef void * RobotizeFilter; |
||||
typedef void * Sfxr; |
||||
typedef void * Speech; |
||||
typedef void * TedSid; |
||||
typedef void * Vic; |
||||
typedef void * Vizsn; |
||||
typedef void * Wav; |
||||
typedef void * WaveShaperFilter; |
||||
typedef void * WavStream; |
||||
typedef void * File; |
||||
|
||||
/*
|
||||
* Soloud |
||||
*/ |
||||
void Soloud_destroy(Soloud * aSoloud); |
||||
Soloud * Soloud_create(); |
||||
int Soloud_init(Soloud * aSoloud); |
||||
int Soloud_initEx(Soloud * aSoloud, unsigned int aFlags /* = Soloud::CLIP_ROUNDOFF */, unsigned int aBackend /* = Soloud::AUTO */, unsigned int aSamplerate /* = Soloud::AUTO */, unsigned int aBufferSize /* = Soloud::AUTO */, unsigned int aChannels /* = 2 */); |
||||
void Soloud_deinit(Soloud * aSoloud); |
||||
unsigned int Soloud_getVersion(Soloud * aSoloud); |
||||
const char * Soloud_getErrorString(Soloud * aSoloud, int aErrorCode); |
||||
unsigned int Soloud_getBackendId(Soloud * aSoloud); |
||||
const char * Soloud_getBackendString(Soloud * aSoloud); |
||||
unsigned int Soloud_getBackendChannels(Soloud * aSoloud); |
||||
unsigned int Soloud_getBackendSamplerate(Soloud * aSoloud); |
||||
unsigned int Soloud_getBackendBufferSize(Soloud * aSoloud); |
||||
int Soloud_setSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float aX, float aY, float aZ); |
||||
int Soloud_getSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float * aX, float * aY, float * aZ); |
||||
unsigned int Soloud_play(Soloud * aSoloud, AudioSource * aSound); |
||||
unsigned int Soloud_playEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); |
||||
unsigned int Soloud_playClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound); |
||||
unsigned int Soloud_playClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, unsigned int aBus /* = 0 */); |
||||
unsigned int Soloud_play3d(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); |
||||
unsigned int Soloud_play3dEx(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); |
||||
unsigned int Soloud_play3dClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); |
||||
unsigned int Soloud_play3dClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, unsigned int aBus /* = 0 */); |
||||
unsigned int Soloud_playBackground(Soloud * aSoloud, AudioSource * aSound); |
||||
unsigned int Soloud_playBackgroundEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); |
||||
int Soloud_seek(Soloud * aSoloud, unsigned int aVoiceHandle, double aSeconds); |
||||
void Soloud_stop(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
void Soloud_stopAll(Soloud * aSoloud); |
||||
void Soloud_stopAudioSource(Soloud * aSoloud, AudioSource * aSound); |
||||
int Soloud_countAudioSource(Soloud * aSoloud, AudioSource * aSound); |
||||
void Soloud_setFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); |
||||
float Soloud_getFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); |
||||
void Soloud_fadeFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, double aTime); |
||||
void Soloud_oscillateFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, double aTime); |
||||
double Soloud_getStreamTime(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
double Soloud_getStreamPosition(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
int Soloud_getPause(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getVolume(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getOverallVolume(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getPan(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
int Soloud_getProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
unsigned int Soloud_getActiveVoiceCount(Soloud * aSoloud); |
||||
unsigned int Soloud_getVoiceCount(Soloud * aSoloud); |
||||
int Soloud_isValidVoiceHandle(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getPostClipScaler(Soloud * aSoloud); |
||||
float Soloud_getGlobalVolume(Soloud * aSoloud); |
||||
unsigned int Soloud_getMaxActiveVoiceCount(Soloud * aSoloud); |
||||
int Soloud_getLooping(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
double Soloud_getLoopPoint(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
void Soloud_setLoopPoint(Soloud * aSoloud, unsigned int aVoiceHandle, double aLoopPoint); |
||||
void Soloud_setLooping(Soloud * aSoloud, unsigned int aVoiceHandle, int aLooping); |
||||
int Soloud_setMaxActiveVoiceCount(Soloud * aSoloud, unsigned int aVoiceCount); |
||||
void Soloud_setInaudibleBehavior(Soloud * aSoloud, unsigned int aVoiceHandle, int aMustTick, int aKill); |
||||
void Soloud_setGlobalVolume(Soloud * aSoloud, float aVolume); |
||||
void Soloud_setPostClipScaler(Soloud * aSoloud, float aScaler); |
||||
void Soloud_setPause(Soloud * aSoloud, unsigned int aVoiceHandle, int aPause); |
||||
void Soloud_setPauseAll(Soloud * aSoloud, int aPause); |
||||
int Soloud_setRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aSpeed); |
||||
void Soloud_setProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle, int aProtect); |
||||
void Soloud_setSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle, float aSamplerate); |
||||
void Soloud_setPan(Soloud * aSoloud, unsigned int aVoiceHandle, float aPan); |
||||
void Soloud_setPanAbsolute(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume); |
||||
void Soloud_setPanAbsoluteEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume /* = 0 */, float aRBVolume /* = 0 */, float aCVolume /* = 0 */, float aSVolume /* = 0 */); |
||||
void Soloud_setVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aVolume); |
||||
void Soloud_setDelaySamples(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aSamples); |
||||
void Soloud_fadeVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); |
||||
void Soloud_fadePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); |
||||
void Soloud_fadeRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); |
||||
void Soloud_fadeGlobalVolume(Soloud * aSoloud, float aTo, double aTime); |
||||
void Soloud_schedulePause(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); |
||||
void Soloud_scheduleStop(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); |
||||
void Soloud_oscillateVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); |
||||
void Soloud_oscillatePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); |
||||
void Soloud_oscillateRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); |
||||
void Soloud_oscillateGlobalVolume(Soloud * aSoloud, float aFrom, float aTo, double aTime); |
||||
void Soloud_setGlobalFilter(Soloud * aSoloud, unsigned int aFilterId, Filter * aFilter); |
||||
void Soloud_setVisualizationEnable(Soloud * aSoloud, int aEnable); |
||||
float * Soloud_calcFFT(Soloud * aSoloud); |
||||
float * Soloud_getWave(Soloud * aSoloud); |
||||
float Soloud_getApproximateVolume(Soloud * aSoloud, unsigned int aChannel); |
||||
unsigned int Soloud_getLoopCount(Soloud * aSoloud, unsigned int aVoiceHandle); |
||||
float Soloud_getInfo(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aInfoKey); |
||||
unsigned int Soloud_createVoiceGroup(Soloud * aSoloud); |
||||
int Soloud_destroyVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); |
||||
int Soloud_addVoiceToGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle, unsigned int aVoiceHandle); |
||||
int Soloud_isVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); |
||||
int Soloud_isVoiceGroupEmpty(Soloud * aSoloud, unsigned int aVoiceGroupHandle); |
||||
void Soloud_update3dAudio(Soloud * aSoloud); |
||||
int Soloud_set3dSoundSpeed(Soloud * aSoloud, float aSpeed); |
||||
float Soloud_get3dSoundSpeed(Soloud * aSoloud); |
||||
void Soloud_set3dListenerParameters(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ); |
||||
void Soloud_set3dListenerParametersEx(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); |
||||
void Soloud_set3dListenerPosition(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ); |
||||
void Soloud_set3dListenerAt(Soloud * aSoloud, float aAtX, float aAtY, float aAtZ); |
||||
void Soloud_set3dListenerUp(Soloud * aSoloud, float aUpX, float aUpY, float aUpZ); |
||||
void Soloud_set3dListenerVelocity(Soloud * aSoloud, float aVelocityX, float aVelocityY, float aVelocityZ); |
||||
void Soloud_set3dSourceParameters(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); |
||||
void Soloud_set3dSourceParametersEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); |
||||
void Soloud_set3dSourcePosition(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); |
||||
void Soloud_set3dSourceVelocity(Soloud * aSoloud, unsigned int aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); |
||||
void Soloud_set3dSourceMinMaxDistance(Soloud * aSoloud, unsigned int aVoiceHandle, float aMinDistance, float aMaxDistance); |
||||
void Soloud_set3dSourceAttenuation(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Soloud_set3dSourceDopplerFactor(Soloud * aSoloud, unsigned int aVoiceHandle, float aDopplerFactor); |
||||
void Soloud_mix(Soloud * aSoloud, float * aBuffer, unsigned int aSamples); |
||||
void Soloud_mixSigned16(Soloud * aSoloud, short * aBuffer, unsigned int aSamples); |
||||
|
||||
/*
|
||||
* BassboostFilter |
||||
*/ |
||||
void BassboostFilter_destroy(BassboostFilter * aBassboostFilter); |
||||
int BassboostFilter_getParamCount(BassboostFilter * aBassboostFilter); |
||||
const char * BassboostFilter_getParamName(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); |
||||
unsigned int BassboostFilter_getParamType(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); |
||||
float BassboostFilter_getParamMax(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); |
||||
float BassboostFilter_getParamMin(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); |
||||
int BassboostFilter_setParams(BassboostFilter * aBassboostFilter, float aBoost); |
||||
BassboostFilter * BassboostFilter_create(); |
||||
|
||||
/*
|
||||
* BiquadResonantFilter |
||||
*/ |
||||
void BiquadResonantFilter_destroy(BiquadResonantFilter * aBiquadResonantFilter); |
||||
int BiquadResonantFilter_getParamCount(BiquadResonantFilter * aBiquadResonantFilter); |
||||
const char * BiquadResonantFilter_getParamName(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); |
||||
unsigned int BiquadResonantFilter_getParamType(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); |
||||
float BiquadResonantFilter_getParamMax(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); |
||||
float BiquadResonantFilter_getParamMin(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); |
||||
BiquadResonantFilter * BiquadResonantFilter_create(); |
||||
int BiquadResonantFilter_setParams(BiquadResonantFilter * aBiquadResonantFilter, int aType, float aFrequency, float aResonance); |
||||
|
||||
/*
|
||||
* Bus |
||||
*/ |
||||
void Bus_destroy(Bus * aBus); |
||||
Bus * Bus_create(); |
||||
void Bus_setFilter(Bus * aBus, unsigned int aFilterId, Filter * aFilter); |
||||
unsigned int Bus_play(Bus * aBus, AudioSource * aSound); |
||||
unsigned int Bus_playEx(Bus * aBus, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */); |
||||
unsigned int Bus_playClocked(Bus * aBus, double aSoundTime, AudioSource * aSound); |
||||
unsigned int Bus_playClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */); |
||||
unsigned int Bus_play3d(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); |
||||
unsigned int Bus_play3dEx(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */); |
||||
unsigned int Bus_play3dClocked(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); |
||||
unsigned int Bus_play3dClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */); |
||||
int Bus_setChannels(Bus * aBus, unsigned int aChannels); |
||||
void Bus_setVisualizationEnable(Bus * aBus, int aEnable); |
||||
void Bus_annexSound(Bus * aBus, unsigned int aVoiceHandle); |
||||
float * Bus_calcFFT(Bus * aBus); |
||||
float * Bus_getWave(Bus * aBus); |
||||
float Bus_getApproximateVolume(Bus * aBus, unsigned int aChannel); |
||||
unsigned int Bus_getActiveVoiceCount(Bus * aBus); |
||||
void Bus_setVolume(Bus * aBus, float aVolume); |
||||
void Bus_setLooping(Bus * aBus, int aLoop); |
||||
void Bus_set3dMinMaxDistance(Bus * aBus, float aMinDistance, float aMaxDistance); |
||||
void Bus_set3dAttenuation(Bus * aBus, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Bus_set3dDopplerFactor(Bus * aBus, float aDopplerFactor); |
||||
void Bus_set3dListenerRelative(Bus * aBus, int aListenerRelative); |
||||
void Bus_set3dDistanceDelay(Bus * aBus, int aDistanceDelay); |
||||
void Bus_set3dCollider(Bus * aBus, AudioCollider * aCollider); |
||||
void Bus_set3dColliderEx(Bus * aBus, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Bus_set3dAttenuator(Bus * aBus, AudioAttenuator * aAttenuator); |
||||
void Bus_setInaudibleBehavior(Bus * aBus, int aMustTick, int aKill); |
||||
void Bus_setLoopPoint(Bus * aBus, double aLoopPoint); |
||||
double Bus_getLoopPoint(Bus * aBus); |
||||
void Bus_stop(Bus * aBus); |
||||
|
||||
/*
|
||||
* DCRemovalFilter |
||||
*/ |
||||
void DCRemovalFilter_destroy(DCRemovalFilter * aDCRemovalFilter); |
||||
DCRemovalFilter * DCRemovalFilter_create(); |
||||
int DCRemovalFilter_setParams(DCRemovalFilter * aDCRemovalFilter); |
||||
int DCRemovalFilter_setParamsEx(DCRemovalFilter * aDCRemovalFilter, float aLength /* = 0.1f */); |
||||
int DCRemovalFilter_getParamCount(DCRemovalFilter * aDCRemovalFilter); |
||||
const char * DCRemovalFilter_getParamName(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); |
||||
unsigned int DCRemovalFilter_getParamType(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); |
||||
float DCRemovalFilter_getParamMax(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); |
||||
float DCRemovalFilter_getParamMin(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); |
||||
|
||||
/*
|
||||
* EchoFilter |
||||
*/ |
||||
void EchoFilter_destroy(EchoFilter * aEchoFilter); |
||||
int EchoFilter_getParamCount(EchoFilter * aEchoFilter); |
||||
const char * EchoFilter_getParamName(EchoFilter * aEchoFilter, unsigned int aParamIndex); |
||||
unsigned int EchoFilter_getParamType(EchoFilter * aEchoFilter, unsigned int aParamIndex); |
||||
float EchoFilter_getParamMax(EchoFilter * aEchoFilter, unsigned int aParamIndex); |
||||
float EchoFilter_getParamMin(EchoFilter * aEchoFilter, unsigned int aParamIndex); |
||||
EchoFilter * EchoFilter_create(); |
||||
int EchoFilter_setParams(EchoFilter * aEchoFilter, float aDelay); |
||||
int EchoFilter_setParamsEx(EchoFilter * aEchoFilter, float aDelay, float aDecay /* = 0.7f */, float aFilter /* = 0.0f */); |
||||
|
||||
/*
|
||||
* FFTFilter |
||||
*/ |
||||
void FFTFilter_destroy(FFTFilter * aFFTFilter); |
||||
FFTFilter * FFTFilter_create(); |
||||
int FFTFilter_getParamCount(FFTFilter * aFFTFilter); |
||||
const char * FFTFilter_getParamName(FFTFilter * aFFTFilter, unsigned int aParamIndex); |
||||
unsigned int FFTFilter_getParamType(FFTFilter * aFFTFilter, unsigned int aParamIndex); |
||||
float FFTFilter_getParamMax(FFTFilter * aFFTFilter, unsigned int aParamIndex); |
||||
float FFTFilter_getParamMin(FFTFilter * aFFTFilter, unsigned int aParamIndex); |
||||
|
||||
/*
|
||||
* FlangerFilter |
||||
*/ |
||||
void FlangerFilter_destroy(FlangerFilter * aFlangerFilter); |
||||
int FlangerFilter_getParamCount(FlangerFilter * aFlangerFilter); |
||||
const char * FlangerFilter_getParamName(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); |
||||
unsigned int FlangerFilter_getParamType(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); |
||||
float FlangerFilter_getParamMax(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); |
||||
float FlangerFilter_getParamMin(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); |
||||
FlangerFilter * FlangerFilter_create(); |
||||
int FlangerFilter_setParams(FlangerFilter * aFlangerFilter, float aDelay, float aFreq); |
||||
|
||||
/*
|
||||
* FreeverbFilter |
||||
*/ |
||||
void FreeverbFilter_destroy(FreeverbFilter * aFreeverbFilter); |
||||
int FreeverbFilter_getParamCount(FreeverbFilter * aFreeverbFilter); |
||||
const char * FreeverbFilter_getParamName(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); |
||||
unsigned int FreeverbFilter_getParamType(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); |
||||
float FreeverbFilter_getParamMax(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); |
||||
float FreeverbFilter_getParamMin(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); |
||||
FreeverbFilter * FreeverbFilter_create(); |
||||
int FreeverbFilter_setParams(FreeverbFilter * aFreeverbFilter, float aMode, float aRoomSize, float aDamp, float aWidth); |
||||
|
||||
/*
|
||||
* LofiFilter |
||||
*/ |
||||
void LofiFilter_destroy(LofiFilter * aLofiFilter); |
||||
int LofiFilter_getParamCount(LofiFilter * aLofiFilter); |
||||
const char * LofiFilter_getParamName(LofiFilter * aLofiFilter, unsigned int aParamIndex); |
||||
unsigned int LofiFilter_getParamType(LofiFilter * aLofiFilter, unsigned int aParamIndex); |
||||
float LofiFilter_getParamMax(LofiFilter * aLofiFilter, unsigned int aParamIndex); |
||||
float LofiFilter_getParamMin(LofiFilter * aLofiFilter, unsigned int aParamIndex); |
||||
LofiFilter * LofiFilter_create(); |
||||
int LofiFilter_setParams(LofiFilter * aLofiFilter, float aSampleRate, float aBitdepth); |
||||
|
||||
/*
|
||||
* Monotone |
||||
*/ |
||||
void Monotone_destroy(Monotone * aMonotone); |
||||
Monotone * Monotone_create(); |
||||
int Monotone_setParams(Monotone * aMonotone, int aHardwareChannels); |
||||
int Monotone_setParamsEx(Monotone * aMonotone, int aHardwareChannels, int aWaveform /* = SoLoud::Misc::WAVE_SQUARE */); |
||||
int Monotone_load(Monotone * aMonotone, const char * aFilename); |
||||
int Monotone_loadMem(Monotone * aMonotone, const unsigned char * aMem, unsigned int aLength); |
||||
int Monotone_loadMemEx(Monotone * aMonotone, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
int Monotone_loadFile(Monotone * aMonotone, File * aFile); |
||||
void Monotone_setVolume(Monotone * aMonotone, float aVolume); |
||||
void Monotone_setLooping(Monotone * aMonotone, int aLoop); |
||||
void Monotone_set3dMinMaxDistance(Monotone * aMonotone, float aMinDistance, float aMaxDistance); |
||||
void Monotone_set3dAttenuation(Monotone * aMonotone, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Monotone_set3dDopplerFactor(Monotone * aMonotone, float aDopplerFactor); |
||||
void Monotone_set3dListenerRelative(Monotone * aMonotone, int aListenerRelative); |
||||
void Monotone_set3dDistanceDelay(Monotone * aMonotone, int aDistanceDelay); |
||||
void Monotone_set3dCollider(Monotone * aMonotone, AudioCollider * aCollider); |
||||
void Monotone_set3dColliderEx(Monotone * aMonotone, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Monotone_set3dAttenuator(Monotone * aMonotone, AudioAttenuator * aAttenuator); |
||||
void Monotone_setInaudibleBehavior(Monotone * aMonotone, int aMustTick, int aKill); |
||||
void Monotone_setLoopPoint(Monotone * aMonotone, double aLoopPoint); |
||||
double Monotone_getLoopPoint(Monotone * aMonotone); |
||||
void Monotone_setFilter(Monotone * aMonotone, unsigned int aFilterId, Filter * aFilter); |
||||
void Monotone_stop(Monotone * aMonotone); |
||||
|
||||
/*
|
||||
* Noise |
||||
*/ |
||||
void Noise_destroy(Noise * aNoise); |
||||
Noise * Noise_create(); |
||||
void Noise_setOctaveScale(Noise * aNoise, float aOct0, float aOct1, float aOct2, float aOct3, float aOct4, float aOct5, float aOct6, float aOct7, float aOct8, float aOct9); |
||||
void Noise_setType(Noise * aNoise, int aType); |
||||
void Noise_setVolume(Noise * aNoise, float aVolume); |
||||
void Noise_setLooping(Noise * aNoise, int aLoop); |
||||
void Noise_set3dMinMaxDistance(Noise * aNoise, float aMinDistance, float aMaxDistance); |
||||
void Noise_set3dAttenuation(Noise * aNoise, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Noise_set3dDopplerFactor(Noise * aNoise, float aDopplerFactor); |
||||
void Noise_set3dListenerRelative(Noise * aNoise, int aListenerRelative); |
||||
void Noise_set3dDistanceDelay(Noise * aNoise, int aDistanceDelay); |
||||
void Noise_set3dCollider(Noise * aNoise, AudioCollider * aCollider); |
||||
void Noise_set3dColliderEx(Noise * aNoise, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Noise_set3dAttenuator(Noise * aNoise, AudioAttenuator * aAttenuator); |
||||
void Noise_setInaudibleBehavior(Noise * aNoise, int aMustTick, int aKill); |
||||
void Noise_setLoopPoint(Noise * aNoise, double aLoopPoint); |
||||
double Noise_getLoopPoint(Noise * aNoise); |
||||
void Noise_setFilter(Noise * aNoise, unsigned int aFilterId, Filter * aFilter); |
||||
void Noise_stop(Noise * aNoise); |
||||
|
||||
/*
|
||||
* Openmpt |
||||
*/ |
||||
void Openmpt_destroy(Openmpt * aOpenmpt); |
||||
Openmpt * Openmpt_create(); |
||||
int Openmpt_load(Openmpt * aOpenmpt, const char * aFilename); |
||||
int Openmpt_loadMem(Openmpt * aOpenmpt, const unsigned char * aMem, unsigned int aLength); |
||||
int Openmpt_loadMemEx(Openmpt * aOpenmpt, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
int Openmpt_loadFile(Openmpt * aOpenmpt, File * aFile); |
||||
void Openmpt_setVolume(Openmpt * aOpenmpt, float aVolume); |
||||
void Openmpt_setLooping(Openmpt * aOpenmpt, int aLoop); |
||||
void Openmpt_set3dMinMaxDistance(Openmpt * aOpenmpt, float aMinDistance, float aMaxDistance); |
||||
void Openmpt_set3dAttenuation(Openmpt * aOpenmpt, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Openmpt_set3dDopplerFactor(Openmpt * aOpenmpt, float aDopplerFactor); |
||||
void Openmpt_set3dListenerRelative(Openmpt * aOpenmpt, int aListenerRelative); |
||||
void Openmpt_set3dDistanceDelay(Openmpt * aOpenmpt, int aDistanceDelay); |
||||
void Openmpt_set3dCollider(Openmpt * aOpenmpt, AudioCollider * aCollider); |
||||
void Openmpt_set3dColliderEx(Openmpt * aOpenmpt, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Openmpt_set3dAttenuator(Openmpt * aOpenmpt, AudioAttenuator * aAttenuator); |
||||
void Openmpt_setInaudibleBehavior(Openmpt * aOpenmpt, int aMustTick, int aKill); |
||||
void Openmpt_setLoopPoint(Openmpt * aOpenmpt, double aLoopPoint); |
||||
double Openmpt_getLoopPoint(Openmpt * aOpenmpt); |
||||
void Openmpt_setFilter(Openmpt * aOpenmpt, unsigned int aFilterId, Filter * aFilter); |
||||
void Openmpt_stop(Openmpt * aOpenmpt); |
||||
|
||||
/*
|
||||
* Queue |
||||
*/ |
||||
void Queue_destroy(Queue * aQueue); |
||||
Queue * Queue_create(); |
||||
int Queue_play(Queue * aQueue, AudioSource * aSound); |
||||
unsigned int Queue_getQueueCount(Queue * aQueue); |
||||
int Queue_isCurrentlyPlaying(Queue * aQueue, AudioSource * aSound); |
||||
int Queue_setParamsFromAudioSource(Queue * aQueue, AudioSource * aSound); |
||||
int Queue_setParams(Queue * aQueue, float aSamplerate); |
||||
int Queue_setParamsEx(Queue * aQueue, float aSamplerate, unsigned int aChannels /* = 2 */); |
||||
void Queue_setVolume(Queue * aQueue, float aVolume); |
||||
void Queue_setLooping(Queue * aQueue, int aLoop); |
||||
void Queue_set3dMinMaxDistance(Queue * aQueue, float aMinDistance, float aMaxDistance); |
||||
void Queue_set3dAttenuation(Queue * aQueue, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Queue_set3dDopplerFactor(Queue * aQueue, float aDopplerFactor); |
||||
void Queue_set3dListenerRelative(Queue * aQueue, int aListenerRelative); |
||||
void Queue_set3dDistanceDelay(Queue * aQueue, int aDistanceDelay); |
||||
void Queue_set3dCollider(Queue * aQueue, AudioCollider * aCollider); |
||||
void Queue_set3dColliderEx(Queue * aQueue, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Queue_set3dAttenuator(Queue * aQueue, AudioAttenuator * aAttenuator); |
||||
void Queue_setInaudibleBehavior(Queue * aQueue, int aMustTick, int aKill); |
||||
void Queue_setLoopPoint(Queue * aQueue, double aLoopPoint); |
||||
double Queue_getLoopPoint(Queue * aQueue); |
||||
void Queue_setFilter(Queue * aQueue, unsigned int aFilterId, Filter * aFilter); |
||||
void Queue_stop(Queue * aQueue); |
||||
|
||||
/*
|
||||
* RobotizeFilter |
||||
*/ |
||||
void RobotizeFilter_destroy(RobotizeFilter * aRobotizeFilter); |
||||
int RobotizeFilter_getParamCount(RobotizeFilter * aRobotizeFilter); |
||||
const char * RobotizeFilter_getParamName(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); |
||||
unsigned int RobotizeFilter_getParamType(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); |
||||
float RobotizeFilter_getParamMax(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); |
||||
float RobotizeFilter_getParamMin(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); |
||||
void RobotizeFilter_setParams(RobotizeFilter * aRobotizeFilter, float aFreq, int aWaveform); |
||||
RobotizeFilter * RobotizeFilter_create(); |
||||
|
||||
/*
|
||||
* Sfxr |
||||
*/ |
||||
void Sfxr_destroy(Sfxr * aSfxr); |
||||
Sfxr * Sfxr_create(); |
||||
void Sfxr_resetParams(Sfxr * aSfxr); |
||||
int Sfxr_loadParams(Sfxr * aSfxr, const char * aFilename); |
||||
int Sfxr_loadParamsMem(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength); |
||||
int Sfxr_loadParamsMemEx(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
int Sfxr_loadParamsFile(Sfxr * aSfxr, File * aFile); |
||||
int Sfxr_loadPreset(Sfxr * aSfxr, int aPresetNo, int aRandSeed); |
||||
void Sfxr_setVolume(Sfxr * aSfxr, float aVolume); |
||||
void Sfxr_setLooping(Sfxr * aSfxr, int aLoop); |
||||
void Sfxr_set3dMinMaxDistance(Sfxr * aSfxr, float aMinDistance, float aMaxDistance); |
||||
void Sfxr_set3dAttenuation(Sfxr * aSfxr, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Sfxr_set3dDopplerFactor(Sfxr * aSfxr, float aDopplerFactor); |
||||
void Sfxr_set3dListenerRelative(Sfxr * aSfxr, int aListenerRelative); |
||||
void Sfxr_set3dDistanceDelay(Sfxr * aSfxr, int aDistanceDelay); |
||||
void Sfxr_set3dCollider(Sfxr * aSfxr, AudioCollider * aCollider); |
||||
void Sfxr_set3dColliderEx(Sfxr * aSfxr, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Sfxr_set3dAttenuator(Sfxr * aSfxr, AudioAttenuator * aAttenuator); |
||||
void Sfxr_setInaudibleBehavior(Sfxr * aSfxr, int aMustTick, int aKill); |
||||
void Sfxr_setLoopPoint(Sfxr * aSfxr, double aLoopPoint); |
||||
double Sfxr_getLoopPoint(Sfxr * aSfxr); |
||||
void Sfxr_setFilter(Sfxr * aSfxr, unsigned int aFilterId, Filter * aFilter); |
||||
void Sfxr_stop(Sfxr * aSfxr); |
||||
|
||||
/*
|
||||
* Speech |
||||
*/ |
||||
void Speech_destroy(Speech * aSpeech); |
||||
Speech * Speech_create(); |
||||
int Speech_setText(Speech * aSpeech, const char * aText); |
||||
int Speech_setParams(Speech * aSpeech); |
||||
int Speech_setParamsEx(Speech * aSpeech, unsigned int aBaseFrequency /* = 1330 */, float aBaseSpeed /* = 10.0f */, float aBaseDeclination /* = 0.5f */, int aBaseWaveform /* = KW_TRIANGLE */); |
||||
void Speech_setVolume(Speech * aSpeech, float aVolume); |
||||
void Speech_setLooping(Speech * aSpeech, int aLoop); |
||||
void Speech_set3dMinMaxDistance(Speech * aSpeech, float aMinDistance, float aMaxDistance); |
||||
void Speech_set3dAttenuation(Speech * aSpeech, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Speech_set3dDopplerFactor(Speech * aSpeech, float aDopplerFactor); |
||||
void Speech_set3dListenerRelative(Speech * aSpeech, int aListenerRelative); |
||||
void Speech_set3dDistanceDelay(Speech * aSpeech, int aDistanceDelay); |
||||
void Speech_set3dCollider(Speech * aSpeech, AudioCollider * aCollider); |
||||
void Speech_set3dColliderEx(Speech * aSpeech, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Speech_set3dAttenuator(Speech * aSpeech, AudioAttenuator * aAttenuator); |
||||
void Speech_setInaudibleBehavior(Speech * aSpeech, int aMustTick, int aKill); |
||||
void Speech_setLoopPoint(Speech * aSpeech, double aLoopPoint); |
||||
double Speech_getLoopPoint(Speech * aSpeech); |
||||
void Speech_setFilter(Speech * aSpeech, unsigned int aFilterId, Filter * aFilter); |
||||
void Speech_stop(Speech * aSpeech); |
||||
|
||||
/*
|
||||
* TedSid |
||||
*/ |
||||
void TedSid_destroy(TedSid * aTedSid); |
||||
TedSid * TedSid_create(); |
||||
int TedSid_load(TedSid * aTedSid, const char * aFilename); |
||||
int TedSid_loadToMem(TedSid * aTedSid, const char * aFilename); |
||||
int TedSid_loadMem(TedSid * aTedSid, const unsigned char * aMem, unsigned int aLength); |
||||
int TedSid_loadMemEx(TedSid * aTedSid, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
int TedSid_loadFileToMem(TedSid * aTedSid, File * aFile); |
||||
int TedSid_loadFile(TedSid * aTedSid, File * aFile); |
||||
void TedSid_setVolume(TedSid * aTedSid, float aVolume); |
||||
void TedSid_setLooping(TedSid * aTedSid, int aLoop); |
||||
void TedSid_set3dMinMaxDistance(TedSid * aTedSid, float aMinDistance, float aMaxDistance); |
||||
void TedSid_set3dAttenuation(TedSid * aTedSid, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void TedSid_set3dDopplerFactor(TedSid * aTedSid, float aDopplerFactor); |
||||
void TedSid_set3dListenerRelative(TedSid * aTedSid, int aListenerRelative); |
||||
void TedSid_set3dDistanceDelay(TedSid * aTedSid, int aDistanceDelay); |
||||
void TedSid_set3dCollider(TedSid * aTedSid, AudioCollider * aCollider); |
||||
void TedSid_set3dColliderEx(TedSid * aTedSid, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void TedSid_set3dAttenuator(TedSid * aTedSid, AudioAttenuator * aAttenuator); |
||||
void TedSid_setInaudibleBehavior(TedSid * aTedSid, int aMustTick, int aKill); |
||||
void TedSid_setLoopPoint(TedSid * aTedSid, double aLoopPoint); |
||||
double TedSid_getLoopPoint(TedSid * aTedSid); |
||||
void TedSid_setFilter(TedSid * aTedSid, unsigned int aFilterId, Filter * aFilter); |
||||
void TedSid_stop(TedSid * aTedSid); |
||||
|
||||
/*
|
||||
* Vic |
||||
*/ |
||||
void Vic_destroy(Vic * aVic); |
||||
Vic * Vic_create(); |
||||
void Vic_setModel(Vic * aVic, int model); |
||||
int Vic_getModel(Vic * aVic); |
||||
void Vic_setRegister(Vic * aVic, int reg, unsigned char value); |
||||
unsigned char Vic_getRegister(Vic * aVic, int reg); |
||||
void Vic_setVolume(Vic * aVic, float aVolume); |
||||
void Vic_setLooping(Vic * aVic, int aLoop); |
||||
void Vic_set3dMinMaxDistance(Vic * aVic, float aMinDistance, float aMaxDistance); |
||||
void Vic_set3dAttenuation(Vic * aVic, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Vic_set3dDopplerFactor(Vic * aVic, float aDopplerFactor); |
||||
void Vic_set3dListenerRelative(Vic * aVic, int aListenerRelative); |
||||
void Vic_set3dDistanceDelay(Vic * aVic, int aDistanceDelay); |
||||
void Vic_set3dCollider(Vic * aVic, AudioCollider * aCollider); |
||||
void Vic_set3dColliderEx(Vic * aVic, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Vic_set3dAttenuator(Vic * aVic, AudioAttenuator * aAttenuator); |
||||
void Vic_setInaudibleBehavior(Vic * aVic, int aMustTick, int aKill); |
||||
void Vic_setLoopPoint(Vic * aVic, double aLoopPoint); |
||||
double Vic_getLoopPoint(Vic * aVic); |
||||
void Vic_setFilter(Vic * aVic, unsigned int aFilterId, Filter * aFilter); |
||||
void Vic_stop(Vic * aVic); |
||||
|
||||
/*
|
||||
* Vizsn |
||||
*/ |
||||
void Vizsn_destroy(Vizsn * aVizsn); |
||||
Vizsn * Vizsn_create(); |
||||
void Vizsn_setText(Vizsn * aVizsn, char * aText); |
||||
void Vizsn_setVolume(Vizsn * aVizsn, float aVolume); |
||||
void Vizsn_setLooping(Vizsn * aVizsn, int aLoop); |
||||
void Vizsn_set3dMinMaxDistance(Vizsn * aVizsn, float aMinDistance, float aMaxDistance); |
||||
void Vizsn_set3dAttenuation(Vizsn * aVizsn, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Vizsn_set3dDopplerFactor(Vizsn * aVizsn, float aDopplerFactor); |
||||
void Vizsn_set3dListenerRelative(Vizsn * aVizsn, int aListenerRelative); |
||||
void Vizsn_set3dDistanceDelay(Vizsn * aVizsn, int aDistanceDelay); |
||||
void Vizsn_set3dCollider(Vizsn * aVizsn, AudioCollider * aCollider); |
||||
void Vizsn_set3dColliderEx(Vizsn * aVizsn, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Vizsn_set3dAttenuator(Vizsn * aVizsn, AudioAttenuator * aAttenuator); |
||||
void Vizsn_setInaudibleBehavior(Vizsn * aVizsn, int aMustTick, int aKill); |
||||
void Vizsn_setLoopPoint(Vizsn * aVizsn, double aLoopPoint); |
||||
double Vizsn_getLoopPoint(Vizsn * aVizsn); |
||||
void Vizsn_setFilter(Vizsn * aVizsn, unsigned int aFilterId, Filter * aFilter); |
||||
void Vizsn_stop(Vizsn * aVizsn); |
||||
|
||||
/*
|
||||
* Wav |
||||
*/ |
||||
void Wav_destroy(Wav * aWav); |
||||
Wav * Wav_create(); |
||||
int Wav_load(Wav * aWav, const char * aFilename); |
||||
int Wav_loadMem(Wav * aWav, const unsigned char * aMem, unsigned int aLength); |
||||
int Wav_loadMemEx(Wav * aWav, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
int Wav_loadFile(Wav * aWav, File * aFile); |
||||
int Wav_loadRawWave8(Wav * aWav, unsigned char * aMem, unsigned int aLength); |
||||
int Wav_loadRawWave8Ex(Wav * aWav, unsigned char * aMem, unsigned int aLength, float aSamplerate /* = 44100.0f */, unsigned int aChannels /* = 1 */); |
||||
int Wav_loadRawWave16(Wav * aWav, short * aMem, unsigned int aLength); |
||||
int Wav_loadRawWave16Ex(Wav * aWav, short * aMem, unsigned int aLength, float aSamplerate /* = 44100.0f */, unsigned int aChannels /* = 1 */); |
||||
int Wav_loadRawWave(Wav * aWav, float * aMem, unsigned int aLength); |
||||
int Wav_loadRawWaveEx(Wav * aWav, float * aMem, unsigned int aLength, float aSamplerate /* = 44100.0f */, unsigned int aChannels /* = 1 */, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
double Wav_getLength(Wav * aWav); |
||||
void Wav_setVolume(Wav * aWav, float aVolume); |
||||
void Wav_setLooping(Wav * aWav, int aLoop); |
||||
void Wav_set3dMinMaxDistance(Wav * aWav, float aMinDistance, float aMaxDistance); |
||||
void Wav_set3dAttenuation(Wav * aWav, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void Wav_set3dDopplerFactor(Wav * aWav, float aDopplerFactor); |
||||
void Wav_set3dListenerRelative(Wav * aWav, int aListenerRelative); |
||||
void Wav_set3dDistanceDelay(Wav * aWav, int aDistanceDelay); |
||||
void Wav_set3dCollider(Wav * aWav, AudioCollider * aCollider); |
||||
void Wav_set3dColliderEx(Wav * aWav, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void Wav_set3dAttenuator(Wav * aWav, AudioAttenuator * aAttenuator); |
||||
void Wav_setInaudibleBehavior(Wav * aWav, int aMustTick, int aKill); |
||||
void Wav_setLoopPoint(Wav * aWav, double aLoopPoint); |
||||
double Wav_getLoopPoint(Wav * aWav); |
||||
void Wav_setFilter(Wav * aWav, unsigned int aFilterId, Filter * aFilter); |
||||
void Wav_stop(Wav * aWav); |
||||
|
||||
/*
|
||||
* WaveShaperFilter |
||||
*/ |
||||
void WaveShaperFilter_destroy(WaveShaperFilter * aWaveShaperFilter); |
||||
int WaveShaperFilter_setParams(WaveShaperFilter * aWaveShaperFilter, float aAmount); |
||||
WaveShaperFilter * WaveShaperFilter_create(); |
||||
int WaveShaperFilter_getParamCount(WaveShaperFilter * aWaveShaperFilter); |
||||
const char * WaveShaperFilter_getParamName(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); |
||||
unsigned int WaveShaperFilter_getParamType(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); |
||||
float WaveShaperFilter_getParamMax(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); |
||||
float WaveShaperFilter_getParamMin(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); |
||||
|
||||
/*
|
||||
* WavStream |
||||
*/ |
||||
void WavStream_destroy(WavStream * aWavStream); |
||||
WavStream * WavStream_create(); |
||||
int WavStream_load(WavStream * aWavStream, const char * aFilename); |
||||
int WavStream_loadMem(WavStream * aWavStream, const unsigned char * aData, unsigned int aDataLen); |
||||
int WavStream_loadMemEx(WavStream * aWavStream, const unsigned char * aData, unsigned int aDataLen, int aCopy /* = false */, int aTakeOwnership /* = true */); |
||||
int WavStream_loadToMem(WavStream * aWavStream, const char * aFilename); |
||||
int WavStream_loadFile(WavStream * aWavStream, File * aFile); |
||||
int WavStream_loadFileToMem(WavStream * aWavStream, File * aFile); |
||||
double WavStream_getLength(WavStream * aWavStream); |
||||
void WavStream_setVolume(WavStream * aWavStream, float aVolume); |
||||
void WavStream_setLooping(WavStream * aWavStream, int aLoop); |
||||
void WavStream_set3dMinMaxDistance(WavStream * aWavStream, float aMinDistance, float aMaxDistance); |
||||
void WavStream_set3dAttenuation(WavStream * aWavStream, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||
void WavStream_set3dDopplerFactor(WavStream * aWavStream, float aDopplerFactor); |
||||
void WavStream_set3dListenerRelative(WavStream * aWavStream, int aListenerRelative); |
||||
void WavStream_set3dDistanceDelay(WavStream * aWavStream, int aDistanceDelay); |
||||
void WavStream_set3dCollider(WavStream * aWavStream, AudioCollider * aCollider); |
||||
void WavStream_set3dColliderEx(WavStream * aWavStream, AudioCollider * aCollider, int aUserData /* = 0 */); |
||||
void WavStream_set3dAttenuator(WavStream * aWavStream, AudioAttenuator * aAttenuator); |
||||
void WavStream_setInaudibleBehavior(WavStream * aWavStream, int aMustTick, int aKill); |
||||
void WavStream_setLoopPoint(WavStream * aWavStream, double aLoopPoint); |
||||
double WavStream_getLoopPoint(WavStream * aWavStream); |
||||
void WavStream_setFilter(WavStream * aWavStream, unsigned int aFilterId, Filter * aFilter); |
||||
void WavStream_stop(WavStream * aWavStream); |
||||
#ifdef __cplusplus |
||||
} // extern "C"
|
||||
#endif |
||||
|
||||
#endif // SOLOUD_C_H_INCLUDED
|
||||
|
@ -0,0 +1,58 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_DCREMOVAL_H |
||||
#define SOLOUD_DCREMOVAL_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class DCRemovalFilter; |
||||
|
||||
class DCRemovalFilterInstance : public FilterInstance |
||||
{ |
||||
float *mBuffer; |
||||
float *mTotals; |
||||
int mBufferLength; |
||||
DCRemovalFilter *mParent; |
||||
int mOffset; |
||||
|
||||
public: |
||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
||||
virtual ~DCRemovalFilterInstance(); |
||||
DCRemovalFilterInstance(DCRemovalFilter *aParent); |
||||
}; |
||||
|
||||
class DCRemovalFilter : public Filter |
||||
{ |
||||
public: |
||||
float mLength; |
||||
virtual FilterInstance *createInstance(); |
||||
DCRemovalFilter(); |
||||
result setParams(float aLength = 0.1f); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,71 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_ECHOFILTER_H |
||||
#define SOLOUD_ECHOFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class EchoFilter; |
||||
|
||||
class EchoFilterInstance : public FilterInstance |
||||
{ |
||||
float *mBuffer; |
||||
int mBufferLength; |
||||
int mBufferMaxLength; |
||||
int mOffset; |
||||
|
||||
public: |
||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
||||
virtual ~EchoFilterInstance(); |
||||
EchoFilterInstance(EchoFilter *aParent); |
||||
}; |
||||
|
||||
class EchoFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
DELAY, |
||||
DECAY, |
||||
FILTER |
||||
}; |
||||
float mDelay; |
||||
float mDecay; |
||||
float mFilter; |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
virtual FilterInstance *createInstance(); |
||||
EchoFilter(); |
||||
result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,41 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2014 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
#ifndef SOLOUD_ERROR_H |
||||
#define SOLOUD_ERROR_H |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
enum SOLOUD_ERRORS |
||||
{ |
||||
SO_NO_ERROR = 0, // No error
|
||||
INVALID_PARAMETER = 1, // Some parameter is invalid
|
||||
FILE_NOT_FOUND = 2, // File not found
|
||||
FILE_LOAD_FAILED = 3, // File found, but could not be loaded
|
||||
DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL
|
||||
OUT_OF_MEMORY = 5, // Out of memory
|
||||
NOT_IMPLEMENTED = 6, // Feature not implemented
|
||||
UNKNOWN_ERROR = 7 // Other error
|
||||
}; |
||||
}; |
||||
#endif |
@ -0,0 +1,63 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2014 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FADER_H |
||||
#define SOLOUD_FADER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
// Helper class to process faders
|
||||
class Fader |
||||
{ |
||||
public: |
||||
// Value to fade from
|
||||
float mFrom; |
||||
// Value to fade to
|
||||
float mTo; |
||||
// Delta between from and to
|
||||
float mDelta; |
||||
// Total time to fade
|
||||
time mTime; |
||||
// Time fading started
|
||||
time mStartTime; |
||||
// Time fading will end
|
||||
time mEndTime; |
||||
// Current value. Used in case time rolls over.
|
||||
float mCurrent; |
||||
// Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped
|
||||
int mActive; |
||||
// Ctor
|
||||
Fader(); |
||||
// Set up LFO
|
||||
void setLFO(float aFrom, float aTo, time aTime, time aStartTime); |
||||
// Set up fader
|
||||
void set(float aFrom, float aTo, time aTime, time aStartTime); |
||||
// Get the current fading value
|
||||
float get(time aCurrentTime); |
||||
};
|
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,51 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FFT_H |
||||
#define SOLOUD_FFT_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
namespace FFT |
||||
{ |
||||
// Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten
|
||||
void fft1024(float *aBuffer); |
||||
|
||||
// Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten
|
||||
void fft256(float *aBuffer); |
||||
|
||||
// Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten
|
||||
void ifft256(float *aBuffer); |
||||
|
||||
// Generic (slower) power of two FFT. Buffer is overwritten.
|
||||
void fft(float *aBuffer, unsigned int aBufferLength); |
||||
|
||||
// Generic (slower) power of two IFFT. Buffer is overwritten.
|
||||
void ifft(float *aBuffer, unsigned int aBufferLength); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,57 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FFTFILTER_H |
||||
#define SOLOUD_FFTFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class FFTFilter; |
||||
|
||||
class FFTFilterInstance : public FilterInstance |
||||
{ |
||||
float *mTemp; |
||||
float *mInputBuffer; |
||||
float *mMixBuffer; |
||||
unsigned int mOffset[MAX_CHANNELS]; |
||||
FFTFilter *mParent; |
||||
public: |
||||
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
virtual ~FFTFilterInstance(); |
||||
FFTFilterInstance(FFTFilter *aParent); |
||||
FFTFilterInstance(); |
||||
}; |
||||
|
||||
class FFTFilter : public Filter |
||||
{ |
||||
public: |
||||
virtual FilterInstance *createInstance(); |
||||
FFTFilter(); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,90 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FILE_H |
||||
#define SOLOUD_FILE_H |
||||
|
||||
#include <stdio.h> |
||||
#include "soloud.h" |
||||
|
||||
typedef void* Soloud_Filehack; |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class File |
||||
{ |
||||
public: |
||||
virtual ~File() {} |
||||
unsigned int read8(); |
||||
unsigned int read16(); |
||||
unsigned int read32(); |
||||
virtual int eof() = 0; |
||||
virtual unsigned int read(unsigned char *aDst, unsigned int aBytes) = 0; |
||||
virtual unsigned int length() = 0; |
||||
virtual void seek(int aOffset) = 0; |
||||
virtual unsigned int pos() = 0; |
||||
virtual FILE * getFilePtr() { return 0; } |
||||
virtual const unsigned char * getMemPtr() { return 0; } |
||||
}; |
||||
|
||||
class DiskFile : public File |
||||
{ |
||||
public: |
||||
FILE *mFileHandle; |
||||
|
||||
virtual int eof(); |
||||
virtual unsigned int read(unsigned char *aDst, unsigned int aBytes); |
||||
virtual unsigned int length(); |
||||
virtual void seek(int aOffset); |
||||
virtual unsigned int pos(); |
||||
virtual ~DiskFile(); |
||||
DiskFile(); |
||||
DiskFile(FILE *fp); |
||||
result open(const char *aFilename); |
||||
virtual FILE * getFilePtr(); |
||||
}; |
||||
|
||||
class MemoryFile : public File |
||||
{ |
||||
public: |
||||
const unsigned char *mDataPtr; |
||||
unsigned int mDataLength; |
||||
unsigned int mOffset; |
||||
bool mDataOwned; |
||||
|
||||
virtual int eof(); |
||||
virtual unsigned int read(unsigned char *aDst, unsigned int aBytes); |
||||
virtual unsigned int length(); |
||||
virtual void seek(int aOffset); |
||||
virtual unsigned int pos(); |
||||
virtual const unsigned char * getMemPtr(); |
||||
virtual ~MemoryFile(); |
||||
MemoryFile(); |
||||
result openMem(const unsigned char *aData, unsigned int aDataLength, bool aCopy=false, bool aTakeOwnership=true); |
||||
result openToMem(const char *aFilename); |
||||
result openFileToMem(File *aFile); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,36 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
/*
|
||||
See soloud_file_hack_on.h |
||||
*/ |
||||
|
||||
#undef FILE |
||||
#undef fgetc |
||||
#undef fread |
||||
#undef fseek |
||||
#undef ftell |
||||
#undef fclose |
||||
#undef fopen |
||||
#undef fopen_s |
@ -0,0 +1,60 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
/*
|
||||
This is a "hack" header to fool third party code to use our File stuff instead |
||||
of stdio FILE* stuff. |
||||
You can use soloud_file_hack_off.h to undef the stuff defined here. |
||||
*/ |
||||
|
||||
#ifndef SEEK_SET |
||||
#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio. |
||||
#endif |
||||
|
||||
typedef void* Soloud_Filehack; |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
extern int Soloud_Filehack_fgetc(Soloud_Filehack *f); |
||||
extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f); |
||||
extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base); |
||||
extern int Soloud_Filehack_ftell(Soloud_Filehack *f); |
||||
extern int Soloud_Filehack_fclose(Soloud_Filehack *f); |
||||
extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode); |
||||
extern int Soloud_Filehack_fopen_s(Soloud_Filehack **f, const char* aFilename, char* aMode); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#define FILE Soloud_Filehack |
||||
#define fgetc Soloud_Filehack_fgetc |
||||
#define fread Soloud_Filehack_fread |
||||
#define fseek Soloud_Filehack_fseek |
||||
#define ftell Soloud_Filehack_ftell |
||||
#define fclose Soloud_Filehack_fclose |
||||
#define fopen Soloud_Filehack_fopen |
||||
#define fopen_s Soloud_Filehack_fopen_s |
@ -0,0 +1,76 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2014 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FILTER_H |
||||
#define SOLOUD_FILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Fader; |
||||
|
||||
class FilterInstance |
||||
{ |
||||
public: |
||||
unsigned int mNumParams; |
||||
unsigned int mParamChanged; |
||||
float *mParam; |
||||
Fader *mParamFader; |
||||
|
||||
|
||||
FilterInstance(); |
||||
virtual result initParams(int aNumParams); |
||||
virtual void updateParams(time aTime); |
||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
virtual float getFilterParameter(unsigned int aAttributeId); |
||||
virtual void setFilterParameter(unsigned int aAttributeId, float aValue); |
||||
virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime); |
||||
virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime); |
||||
virtual ~FilterInstance(); |
||||
}; |
||||
|
||||
class Filter |
||||
{ |
||||
public: |
||||
enum PARAMTYPE |
||||
{ |
||||
FLOAT_PARAM = 0, |
||||
INT_PARAM, |
||||
BOOL_PARAM |
||||
}; |
||||
Filter(); |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
|
||||
virtual FilterInstance *createInstance() = 0; |
||||
virtual ~Filter(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,70 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FLANGERFILTER_H |
||||
#define SOLOUD_FLANGERFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class FlangerFilter; |
||||
|
||||
class FlangerFilterInstance : public FilterInstance |
||||
{ |
||||
float *mBuffer; |
||||
unsigned int mBufferLength; |
||||
FlangerFilter *mParent; |
||||
unsigned int mOffset; |
||||
double mIndex; |
||||
|
||||
public: |
||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
||||
virtual ~FlangerFilterInstance(); |
||||
FlangerFilterInstance(FlangerFilter *aParent); |
||||
}; |
||||
|
||||
class FlangerFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERPARAMS |
||||
{ |
||||
WET, |
||||
DELAY, |
||||
FREQ |
||||
}; |
||||
float mDelay; |
||||
float mFreq; |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
virtual FilterInstance *createInstance(); |
||||
FlangerFilter(); |
||||
result setParams(float aDelay, float aFreq); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,83 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_FREEVERBFILTER_H |
||||
#define SOLOUD_FREEVERBFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class FreeverbFilter; |
||||
namespace FreeverbImpl |
||||
{ |
||||
class Revmodel; |
||||
} |
||||
|
||||
class FreeverbFilterInstance : public FilterInstance |
||||
{ |
||||
enum FILTERPARAM { |
||||
WET = 0, |
||||
FREEZE, |
||||
ROOMSIZE, |
||||
DAMP, |
||||
WIDTH |
||||
};
|
||||
|
||||
FreeverbFilter *mParent; |
||||
FreeverbImpl::Revmodel *mModel; |
||||
public: |
||||
virtual void filter(float* aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
|
||||
virtual ~FreeverbFilterInstance(); |
||||
FreeverbFilterInstance(FreeverbFilter *aParent); |
||||
}; |
||||
|
||||
class FreeverbFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERPARAM { |
||||
WET = 0, |
||||
FREEZE, |
||||
ROOMSIZE, |
||||
DAMP, |
||||
WIDTH |
||||
}; |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
|
||||
float mMode; |
||||
float mRoomSize; |
||||
float mDamp; |
||||
float mWidth; |
||||
virtual FreeverbFilterInstance *createInstance(); |
||||
FreeverbFilter(); |
||||
result setParams(float aMode, float aRoomSize, float aDamp, float aWidth); |
||||
virtual ~FreeverbFilter(); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,164 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_INTERNAL_H |
||||
#define SOLOUD_INTERNAL_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
// SDL1 back-end initialization call
|
||||
result sdl1_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// SDL2 back-end initialization call
|
||||
result sdl2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// SDL1 "non-dynamic" back-end initialization call
|
||||
result sdl1static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// SDL2 "non-dynamic" back-end initialization call
|
||||
result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// OpenAL back-end initialization call
|
||||
result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// Core Audio driver back-end initialization call
|
||||
result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// OpenSL ES back-end initialization call
|
||||
result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// PortAudio back-end initialization call
|
||||
result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// WinMM back-end initialization call
|
||||
result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); |
||||
|
||||
// XAudio2 back-end initialization call
|
||||
result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// WASAPI back-end initialization call
|
||||
result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); |
||||
|
||||
// OSS back-end initialization call
|
||||
result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// PS Vita homebrew back-end initialization call
|
||||
result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// ALSA back-end initialization call
|
||||
result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// JACK back-end initialization call
|
||||
result jack_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// MiniAudio back-end initialization call
|
||||
result miniaudio_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// nosound back-end initialization call
|
||||
result nosound_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// null driver back-end initialization call
|
||||
result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||
|
||||
// Deinterlace samples in a buffer. From 12121212 to 11112222
|
||||
void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); |
||||
|
||||
// Interlace samples in a buffer. From 11112222 to 12121212
|
||||
void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); |
||||
|
||||
// Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212
|
||||
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels); |
||||
}; |
||||
|
||||
#define FOR_ALL_VOICES_PRE \ |
||||
handle *h_ = NULL; \
|
||||
handle th_[2] = { aVoiceHandle, 0 }; \
|
||||
lockAudioMutex_internal(); \
|
||||
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
|
||||
if (h_ == NULL) h_ = th_; \
|
||||
while (*h_) \
|
||||
{ \
|
||||
int ch = getVoiceFromHandle_internal(*h_); \
|
||||
if (ch != -1) \
|
||||
{ |
||||
|
||||
#define FOR_ALL_VOICES_POST \ |
||||
} \
|
||||
h_++; \
|
||||
} \
|
||||
unlockAudioMutex_internal(); |
||||
|
||||
#define FOR_ALL_VOICES_PRE_3D \ |
||||
handle *h_ = NULL; \
|
||||
handle th_[2] = { aVoiceHandle, 0 }; \
|
||||
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
|
||||
if (h_ == NULL) h_ = th_; \
|
||||
while (*h_) \
|
||||
{ \
|
||||
int ch = (*h_ & 0xfff) - 1; \
|
||||
if (ch != -1 && m3dData[ch].mHandle == *h_) \
|
||||
{ |
||||
|
||||
#define FOR_ALL_VOICES_POST_3D \ |
||||
} \
|
||||
h_++; \
|
||||
}
|
||||
|
||||
#define FOR_ALL_VOICES_PRE_EXT \ |
||||
handle *h_ = NULL; \
|
||||
handle th_[2] = { aVoiceHandle, 0 }; \
|
||||
mSoloud->lockAudioMutex_internal(); \
|
||||
h_ = mSoloud->voiceGroupHandleToArray_internal(aVoiceHandle); \
|
||||
if (h_ == NULL) h_ = th_; \
|
||||
while (*h_) \
|
||||
{ \
|
||||
int ch = mSoloud->getVoiceFromHandle_internal(*h_); \
|
||||
if (ch != -1) \
|
||||
{ |
||||
|
||||
#define FOR_ALL_VOICES_POST_EXT \ |
||||
} \
|
||||
h_++; \
|
||||
} \
|
||||
mSoloud->unlockAudioMutex_internal(); |
||||
|
||||
#define FOR_ALL_VOICES_PRE_3D_EXT \ |
||||
handle *h_ = NULL; \
|
||||
handle th_[2] = { aVoiceHandle, 0 }; \
|
||||
h_ = mSoloud->voiceGroupHandleToArray(aVoiceHandle); \
|
||||
if (h_ == NULL) h_ = th_; \
|
||||
while (*h_) \
|
||||
{ \
|
||||
int ch = (*h_ & 0xfff) - 1; \
|
||||
if (ch != -1 && mSoloud->m3dData[ch].mHandle == *h_) \
|
||||
{ |
||||
|
||||
#define FOR_ALL_VOICES_POST_3D_EXT \ |
||||
} \
|
||||
h_++; \
|
||||
}
|
||||
|
||||
#endif |
@ -0,0 +1,80 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_LOFIFILTER_H |
||||
#define SOLOUD_LOFIFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class LofiFilter; |
||||
|
||||
struct LofiChannelData |
||||
{ |
||||
float mSample; |
||||
float mSamplesToSkip; |
||||
}; |
||||
|
||||
class LofiFilterInstance : public FilterInstance |
||||
{ |
||||
enum FILTERPARAMS |
||||
{ |
||||
WET, |
||||
SAMPLERATE, |
||||
BITDEPTH |
||||
}; |
||||
LofiChannelData mChannelData[2]; |
||||
|
||||
LofiFilter *mParent; |
||||
public: |
||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
virtual ~LofiFilterInstance(); |
||||
LofiFilterInstance(LofiFilter *aParent); |
||||
}; |
||||
|
||||
class LofiFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERPARAMS |
||||
{ |
||||
WET, |
||||
SAMPLERATE, |
||||
BITDEPTH |
||||
}; |
||||
float mSampleRate; |
||||
float mBitdepth; |
||||
virtual LofiFilterInstance *createInstance(); |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
LofiFilter(); |
||||
result setParams(float aSampleRate, float aBitdepth); |
||||
virtual ~LofiFilter(); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,65 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_MISC_H |
||||
#define SOLOUD_MISC_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
namespace Misc |
||||
{ |
||||
enum WAVEFORM |
||||
{ |
||||
WAVE_SQUARE = 0, |
||||
WAVE_SAW, |
||||
WAVE_SIN, |
||||
WAVE_TRIANGLE, |
||||
WAVE_BOUNCE, |
||||
WAVE_JAWS, |
||||
WAVE_HUMPS, |
||||
WAVE_FSQUARE, |
||||
WAVE_FSAW |
||||
}; |
||||
// Generate a waveform.
|
||||
float generateWaveform(int aWaveform, float p); |
||||
|
||||
// WELL512 random
|
||||
class Prg |
||||
{ |
||||
public: |
||||
// random generator
|
||||
Prg(); |
||||
unsigned int mState[16]; |
||||
unsigned int mIndex; |
||||
unsigned int rand(); |
||||
float rand_float(); |
||||
void srand(int aSeed); |
||||
}; |
||||
|
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,110 @@ |
||||
/*
|
||||
MONOTONE module for SoLoud audio engine |
||||
Copyright (c) 2013-2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef MONOTONE_H |
||||
#define MONOTONE_H |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_misc.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Monotone; |
||||
class File; |
||||
|
||||
struct MonotoneSong |
||||
{ |
||||
char *mTitle; |
||||
char *mComment; |
||||
unsigned char mVersion; // must be 1
|
||||
unsigned char mTotalPatterns; |
||||
unsigned char mTotalTracks; |
||||
unsigned char mCellSize; // must be 2 for version 1
|
||||
unsigned char mOrder[256]; |
||||
unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks
|
||||
}; |
||||
|
||||
struct MonotoneChannel |
||||
{ |
||||
int mEnabled;
|
||||
int mActive; |
||||
int mFreq[3]; |
||||
int mPortamento; |
||||
int mArpCounter; |
||||
int mArp; |
||||
int mLastNote; |
||||
int mPortamentoToNote; |
||||
int mVibrato; |
||||
int mVibratoIndex; |
||||
int mVibratoDepth; |
||||
int mVibratoSpeed; |
||||
}; |
||||
|
||||
struct MonotoneHardwareChannel |
||||
{ |
||||
int mEnabled; |
||||
float mSamplePos; |
||||
float mSamplePosInc; |
||||
}; |
||||
|
||||
class MonotoneInstance : public AudioSourceInstance |
||||
{ |
||||
Monotone *mParent;
|
||||
public: |
||||
MonotoneChannel mChannel[12]; |
||||
MonotoneHardwareChannel mOutput[12]; |
||||
int mNextChannel; |
||||
int mTempo; // ticks / row. Tick = 60hz. Default 4.
|
||||
int mOrder; |
||||
int mRow; |
||||
int mSampleCount; |
||||
int mRowTick; |
||||
|
||||
MonotoneInstance(Monotone *aParent); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
}; |
||||
|
||||
class Monotone : public AudioSource |
||||
{ |
||||
public: |
||||
|
||||
int mNotesHz[800]; |
||||
int mVibTable[32]; |
||||
int mHardwareChannels; |
||||
int mWaveform; |
||||
MonotoneSong mSong; |
||||
Monotone(); |
||||
~Monotone(); |
||||
result setParams(int aHardwareChannels, int aWaveform = SoLoud::Misc::WAVE_SQUARE); |
||||
result load(const char *aFilename); |
||||
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||
result loadFile(File *aFile); |
||||
virtual AudioSourceInstance *createInstance(); |
||||
public: |
||||
void clear(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,74 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_NOISE_H |
||||
#define SOLOUD_NOISE_H |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_misc.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Noise; |
||||
|
||||
class NoiseInstance : public AudioSourceInstance |
||||
{ |
||||
public: |
||||
NoiseInstance(Noise *aParent); |
||||
~NoiseInstance(); |
||||
|
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
|
||||
public: |
||||
float mOctaveScale[10]; |
||||
Misc::Prg mPrg; |
||||
}; |
||||
|
||||
class Noise : public AudioSource |
||||
{ |
||||
public: |
||||
|
||||
enum NOISETYPES |
||||
{ |
||||
WHITE = 0, |
||||
PINK, |
||||
BROWNISH, |
||||
BLUEISH |
||||
}; |
||||
|
||||
Noise(); |
||||
|
||||
void setOctaveScale(float aOct0, float aOct1, float aOct2, float aOct3, float aOct4, float aOct5, float aOct6, float aOct7, float aOct8, float aOct9); |
||||
void setType(int aType); |
||||
|
||||
virtual ~Noise(); |
||||
|
||||
public: |
||||
virtual AudioSourceInstance *createInstance(); |
||||
float mOctaveScale[10]; |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,62 @@ |
||||
/*
|
||||
Openmpt module for SoLoud audio engine |
||||
Copyright (c) 2016 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef OPENMPT_H |
||||
#define OPENMPT_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Openmpt; |
||||
class File; |
||||
|
||||
class OpenmptInstance : public AudioSourceInstance |
||||
{ |
||||
Openmpt *mParent; |
||||
void *mModfile; |
||||
int mPlaying; |
||||
|
||||
public: |
||||
OpenmptInstance(Openmpt *aParent); |
||||
virtual ~OpenmptInstance(); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
}; |
||||
|
||||
class Openmpt : public AudioSource |
||||
{ |
||||
public: |
||||
char *mData; |
||||
unsigned int mDataLen; |
||||
Openmpt(); |
||||
virtual ~Openmpt(); |
||||
result load(const char* aFilename); |
||||
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||
result loadFile(File *aFile); |
||||
virtual AudioSourceInstance *createInstance(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,72 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2018 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_QUEUE_H |
||||
#define SOLOUD_QUEUE_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
#define SOLOUD_QUEUE_MAX 32 |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Queue; |
||||
|
||||
class QueueInstance : public AudioSourceInstance |
||||
{ |
||||
Queue *mParent; |
||||
public: |
||||
QueueInstance(Queue *aParent); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
virtual ~QueueInstance(); |
||||
}; |
||||
|
||||
class Queue : public AudioSource |
||||
{ |
||||
public: |
||||
Queue(); |
||||
virtual QueueInstance *createInstance(); |
||||
// Play sound through the queue
|
||||
result play(AudioSource &aSound); |
||||
// Number of audio sources queued for replay
|
||||
unsigned int getQueueCount(); |
||||
// Is this audio source currently playing?
|
||||
bool isCurrentlyPlaying(AudioSource &aSound); |
||||
// Set params by reading them from an audio source
|
||||
result setParamsFromAudioSource(AudioSource &aSound); |
||||
// Set params manually
|
||||
result setParams(float aSamplerate, unsigned int aChannels = 2); |
||||
|
||||
public: |
||||
unsigned int mReadIndex, mWriteIndex, mCount; |
||||
AudioSourceInstance *mSource[SOLOUD_QUEUE_MAX]; |
||||
QueueInstance *mInstance; |
||||
handle mQueueHandle; |
||||
void findQueueHandle(); |
||||
|
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,72 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2020 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_ROBOTIZEFILTER_H |
||||
#define SOLOUD_ROBOTIZEFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_filter.h" |
||||
#include "soloud_misc.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class RobotizeFilter; |
||||
|
||||
class RobotizeFilterInstance : public FilterInstance |
||||
{ |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
FREQ, |
||||
WAVE |
||||
}; |
||||
RobotizeFilter *mParent; |
||||
public: |
||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
RobotizeFilterInstance(RobotizeFilter *aParent); |
||||
}; |
||||
|
||||
class RobotizeFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERATTRIBUTE |
||||
{ |
||||
WET = 0, |
||||
FREQ, |
||||
WAVE |
||||
}; |
||||
float mFreq; |
||||
int mWave; |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
void setParams(float aFreq, int aWaveform); |
||||
virtual FilterInstance *createInstance(); |
||||
RobotizeFilter(); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,159 @@ |
||||
/*
|
||||
SFXR module for SoLoud audio engine |
||||
Copyright (c) 2014 Jari Komppa |
||||
Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SFXR_H |
||||
#define SFXR_H |
||||
|
||||
#include "soloud.h" |
||||
#include "soloud_misc.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class File; |
||||
|
||||
struct SfxrParams |
||||
{ |
||||
int wave_type; |
||||
|
||||
float p_base_freq; |
||||
float p_freq_limit; |
||||
float p_freq_ramp; |
||||
float p_freq_dramp; |
||||
float p_duty; |
||||
float p_duty_ramp; |
||||
|
||||
float p_vib_strength; |
||||
float p_vib_speed; |
||||
float p_vib_delay; |
||||
|
||||
float p_env_attack; |
||||
float p_env_sustain; |
||||
float p_env_decay; |
||||
float p_env_punch; |
||||
|
||||
bool filter_on; |
||||
float p_lpf_resonance; |
||||
float p_lpf_freq; |
||||
float p_lpf_ramp; |
||||
float p_hpf_freq; |
||||
float p_hpf_ramp; |
||||
|
||||
float p_pha_offset; |
||||
float p_pha_ramp; |
||||
|
||||
float p_repeat_speed; |
||||
|
||||
float p_arp_speed; |
||||
float p_arp_mod; |
||||
|
||||
float master_vol; |
||||
|
||||
float sound_vol; |
||||
}; |
||||
|
||||
class Sfxr; |
||||
|
||||
class SfxrInstance : public AudioSourceInstance |
||||
{ |
||||
Sfxr *mParent; |
||||
|
||||
Misc::Prg mRand; |
||||
SfxrParams mParams; |
||||
|
||||
bool playing_sample; |
||||
int phase; |
||||
double fperiod; |
||||
double fmaxperiod; |
||||
double fslide; |
||||
double fdslide; |
||||
int period; |
||||
float square_duty; |
||||
float square_slide; |
||||
int env_stage; |
||||
int env_time; |
||||
int env_length[3]; |
||||
float env_vol; |
||||
float fphase; |
||||
float fdphase; |
||||
int iphase; |
||||
float phaser_buffer[1024]; |
||||
int ipp; |
||||
float noise_buffer[32]; |
||||
float fltp; |
||||
float fltdp; |
||||
float fltw; |
||||
float fltw_d; |
||||
float fltdmp; |
||||
float fltphp; |
||||
float flthp; |
||||
float flthp_d; |
||||
float vib_phase; |
||||
float vib_speed; |
||||
float vib_amp; |
||||
int rep_time; |
||||
int rep_limit; |
||||
int arp_time; |
||||
int arp_limit; |
||||
double arp_mod; |
||||
|
||||
void resetSample(bool aRestart); |
||||
|
||||
public: |
||||
SfxrInstance(Sfxr *aParent); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
}; |
||||
|
||||
class Sfxr : public AudioSource |
||||
{ |
||||
public: |
||||
SfxrParams mParams; |
||||
|
||||
enum SFXR_PRESETS
|
||||
{ |
||||
COIN, |
||||
LASER, |
||||
EXPLOSION, |
||||
POWERUP, |
||||
HURT, |
||||
JUMP, |
||||
BLIP |
||||
}; |
||||
|
||||
Misc::Prg mRand; |
||||
|
||||
Sfxr(); |
||||
virtual ~Sfxr(); |
||||
void resetParams(); |
||||
result loadParams(const char* aFilename); |
||||
result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||
result loadParamsFile(File *aFile); |
||||
|
||||
result loadPreset(int aPresetNo, int aRandSeed); |
||||
virtual AudioSourceInstance *createInstance(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,79 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
#ifndef SOLOUD_SPEECH_H |
||||
#define SOLOUD_SPEECH_H |
||||
|
||||
#include "soloud.h" |
||||
#include "../src/audiosource/speech/darray.h" |
||||
#include "../src/audiosource/speech/klatt.h" |
||||
#include "../src/audiosource/speech/tts.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Speech; |
||||
|
||||
class Speech : public AudioSource |
||||
{ |
||||
// copy of the enum in klatt.h for codegen purposes
|
||||
enum KLATT_WAVEFORM |
||||
{ |
||||
KW_SAW, |
||||
KW_TRIANGLE, |
||||
KW_SIN, |
||||
KW_SQUARE, |
||||
KW_PULSE, |
||||
KW_NOISE, |
||||
KW_WARBLE |
||||
}; |
||||
public: |
||||
int mBaseFrequency; |
||||
float mBaseSpeed; |
||||
float mBaseDeclination; |
||||
int mBaseWaveform; |
||||
int mFrames; |
||||
darray mElement; |
||||
Speech(); |
||||
result setText(const char *aText); |
||||
result setParams(unsigned int aBaseFrequency = 1330, float aBaseSpeed = 10.0f, float aBaseDeclination = 0.5f, int aBaseWaveform = KW_TRIANGLE); |
||||
virtual ~Speech(); |
||||
virtual AudioSourceInstance *createInstance(); |
||||
}; |
||||
|
||||
class SpeechInstance : public AudioSourceInstance |
||||
{ |
||||
klatt mSynth; |
||||
Speech *mParent; |
||||
short *mSample; |
||||
int mSampleCount; |
||||
int mOffset; |
||||
public: |
||||
SpeechInstance(Speech *aParent); |
||||
virtual ~SpeechInstance(); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual result rewind(); |
||||
virtual bool hasEnded(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
Binary file not shown.
@ -0,0 +1,74 @@ |
||||
/*
|
||||
TED/SID module for SoLoud audio engine |
||||
Copyright (c) 2013-2015 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef TEDSID_H |
||||
#define TEDSID_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
class SIDsound; |
||||
class TED; |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class TedSid; |
||||
class File; |
||||
|
||||
class TedSidInstance : public AudioSourceInstance |
||||
{ |
||||
TedSid *mParent;
|
||||
SIDsound *mSID; |
||||
TED *mTED; |
||||
unsigned int mSampleCount; |
||||
int mNextReg; |
||||
int mNextVal; |
||||
int mRegValues[128]; |
||||
public: |
||||
|
||||
TedSidInstance(TedSid *aParent); |
||||
~TedSidInstance(); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual void tick(); |
||||
virtual bool hasEnded(); |
||||
virtual float getInfo(unsigned int aInfoKey); |
||||
}; |
||||
|
||||
class TedSid : public AudioSource |
||||
{ |
||||
public: |
||||
File *mFile; |
||||
int mModel; |
||||
bool mFileOwned; |
||||
TedSid(); |
||||
~TedSid(); |
||||
result load(const char *aFilename); |
||||
result loadToMem(const char *aFilename); |
||||
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||
result loadFileToMem(File *aFile); |
||||
result loadFile(File *aFile); |
||||
virtual AudioSourceInstance *createInstance(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,84 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2014 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_THREAD_H |
||||
#define SOLOUD_THREAD_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
namespace Thread |
||||
{ |
||||
typedef void (*threadFunction)(void *aParam); |
||||
|
||||
struct ThreadHandleData; |
||||
typedef ThreadHandleData* ThreadHandle; |
||||
|
||||
void * createMutex(); |
||||
void destroyMutex(void *aHandle); |
||||
void lockMutex(void *aHandle); |
||||
void unlockMutex(void *aHandle); |
||||
|
||||
ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter); |
||||
|
||||
void sleep(int aMSec); |
||||
void wait(ThreadHandle aThreadHandle); |
||||
void release(ThreadHandle aThreadHandle); |
||||
int getTimeMillis(); |
||||
|
||||
#define MAX_THREADPOOL_TASKS 1024 |
||||
|
||||
class PoolTask |
||||
{ |
||||
public: |
||||
virtual void work() = 0; |
||||
}; |
||||
|
||||
class Pool |
||||
{ |
||||
public: |
||||
// Initialize and run thread pool. For thread count 0, work is done at addWork call.
|
||||
void init(int aThreadCount); |
||||
// Ctor, sets known state
|
||||
Pool(); |
||||
// Dtor. Waits for the threads to finish. Work may be unfinished.
|
||||
~Pool(); |
||||
// Add work to work list. Object is not automatically deleted when work is done.
|
||||
void addWork(PoolTask *aTask); |
||||
// Called from worker thread to get a new task. Returns null if no work available.
|
||||
PoolTask *getWork(); |
||||
public: |
||||
int mThreadCount; // number of threads
|
||||
ThreadHandle *mThread; // array of thread handles
|
||||
void *mWorkMutex; // mutex to protect task array/maxtask
|
||||
PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks
|
||||
int mMaxTask; // how many tasks are pending
|
||||
int mRobin; // cyclic counter, used to pick jobs for threads
|
||||
volatile int mRunning; // running flag, used to flag threads to stop
|
||||
}; |
||||
} |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,108 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2015 Jari Komppa |
||||
|
||||
VIC 6560/6561 sound chip emulator |
||||
Copyright (c) 2015 Petri Hakkinen |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_VIC_H |
||||
#define SOLOUD_VIC_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
/*
|
||||
A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models. |
||||
Bass, alto and soprano should be quite close to original vic, noise probably not so. |
||||
|
||||
The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency. |
||||
The highest bit of each oscillator register switches the oscillator on/off. |
||||
The fourth oscillator generates a noise waveform. |
||||
|
||||
VIC-20 does not have per channel volume control, only global volume, |
||||
which you can change by setting audio source's volume. |
||||
|
||||
To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter |
||||
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0. |
||||
*/ |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Vic; |
||||
|
||||
class VicInstance : public AudioSourceInstance |
||||
{ |
||||
public: |
||||
VicInstance(Vic *aParent); |
||||
~VicInstance(); |
||||
|
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
|
||||
public: |
||||
Vic* m_parent; |
||||
unsigned int m_phase[4]; |
||||
unsigned int m_noisePos; |
||||
}; |
||||
|
||||
class Vic : public AudioSource |
||||
{ |
||||
public: |
||||
// VIC model
|
||||
enum |
||||
{ |
||||
PAL = 0, |
||||
NTSC |
||||
}; |
||||
|
||||
// VIC sound registers
|
||||
enum |
||||
{ |
||||
BASS = 0, |
||||
ALTO, |
||||
SOPRANO, |
||||
NOISE, |
||||
MAX_REGS |
||||
}; |
||||
|
||||
Vic(); |
||||
|
||||
virtual ~Vic(); |
||||
|
||||
void setModel(int model); |
||||
|
||||
int getModel() const; |
||||
|
||||
void setRegister(int reg, unsigned char value); |
||||
|
||||
unsigned char getRegister(int reg); |
||||
|
||||
public: |
||||
virtual AudioSourceInstance *createInstance(); |
||||
int m_model; |
||||
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
|
||||
unsigned char m_regs[MAX_REGS];
|
||||
unsigned char m_noise[8192]; |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,82 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2018 Jari Komppa |
||||
|
||||
vizsn speech synthesizer (c) by Ville-Matias Heikkilä, |
||||
released under WTFPL, http://www.wtfpl.net/txt/copying/
|
||||
(in short, "do whatever you want to") |
||||
|
||||
Integration and changes to work with SoLoud by Jari Komppa, |
||||
released under same license. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_VIZSN_H |
||||
#define SOLOUD_VIZSN_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Vizsn; |
||||
|
||||
struct VizsnResonator |
||||
{ |
||||
public: |
||||
float a, b, c, p1, p2; |
||||
|
||||
float resonate(float i); |
||||
float antiresonate(float i); |
||||
}; |
||||
|
||||
struct VizsnBank |
||||
{ |
||||
VizsnResonator r[10]; |
||||
float pitch; |
||||
float frica, voice, aspir, bypas, breth; |
||||
}; |
||||
|
||||
class VizsnInstance : public AudioSourceInstance |
||||
{ |
||||
public: |
||||
VizsnInstance(Vizsn *aParent); |
||||
~VizsnInstance(); |
||||
|
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual bool hasEnded(); |
||||
|
||||
public: |
||||
Vizsn *mParent; |
||||
VizsnBank mBank0, mBank1, mBank0to1; |
||||
int mNper, mNmod, mNopen; |
||||
int mEchobuf[1024], mPtr; |
||||
int mCurrentVoiceType; |
||||
float mPitch; |
||||
char *mS; |
||||
float mBuf[2048]; |
||||
unsigned int mBufwrite; |
||||
unsigned int mBufread; |
||||
float vcsrc(int aPitch, int aVoicetype); |
||||
float noisrc(); |
||||
float genwave(); |
||||
void setphone(VizsnBank *aB, char aP, float aPitch); |
||||
void slidePrepare(int aNumtix); |
||||
void slideTick(); |
||||
int mA; |
||||
int mB; |
||||
int mOrgv; |
||||
float mGlotlast; |
||||
}; |
||||
|
||||
class Vizsn : public AudioSource |
||||
{ |
||||
public: |
||||
char *mText; |
||||
Vizsn(); |
||||
virtual ~Vizsn(); |
||||
void setText(char *aText); |
||||
public: |
||||
virtual AudioSourceInstance *createInstance(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,74 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2018 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_WAV_H |
||||
#define SOLOUD_WAV_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
struct stb_vorbis; |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class Wav; |
||||
class File; |
||||
class MemoryFile; |
||||
|
||||
class WavInstance : public AudioSourceInstance |
||||
{ |
||||
Wav *mParent; |
||||
unsigned int mOffset; |
||||
public: |
||||
WavInstance(Wav *aParent); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual result rewind(); |
||||
virtual bool hasEnded(); |
||||
}; |
||||
|
||||
class Wav : public AudioSource |
||||
{ |
||||
result loadwav(MemoryFile *aReader); |
||||
result loadogg(MemoryFile *aReader); |
||||
result loadmp3(MemoryFile *aReader); |
||||
result loadflac(MemoryFile *aReader); |
||||
result testAndLoadFile(MemoryFile *aReader); |
||||
public: |
||||
float *mData; |
||||
unsigned int mSampleCount; |
||||
|
||||
Wav(); |
||||
virtual ~Wav(); |
||||
result load(const char *aFilename); |
||||
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||
result loadFile(File *aFile); |
||||
result loadRawWave8(unsigned char *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1); |
||||
result loadRawWave16(short *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1); |
||||
result loadRawWave(float *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1, bool aCopy = false, bool aTakeOwnership = true); |
||||
|
||||
virtual AudioSourceInstance *createInstance(); |
||||
time getLength(); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,63 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2018 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_WAVESHAPERFILTER_H |
||||
#define SOLOUD_WAVESHAPERFILTER_H |
||||
|
||||
#include "soloud.h" |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class WaveShaperFilter; |
||||
|
||||
class WaveShaperFilterInstance : public FilterInstance |
||||
{
|
||||
WaveShaperFilter *mParent; |
||||
public: |
||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||
virtual ~WaveShaperFilterInstance(); |
||||
WaveShaperFilterInstance(WaveShaperFilter *aParent); |
||||
}; |
||||
|
||||
class WaveShaperFilter : public Filter |
||||
{ |
||||
public: |
||||
enum FILTERPARAMS { |
||||
WET = 0, |
||||
AMOUNT |
||||
}; |
||||
float mAmount; |
||||
virtual WaveShaperFilterInstance *createInstance(); |
||||
result setParams(float aAmount); |
||||
WaveShaperFilter(); |
||||
virtual ~WaveShaperFilter(); |
||||
virtual int getParamCount(); |
||||
virtual const char* getParamName(unsigned int aParamIndex); |
||||
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||
virtual float getParamMax(unsigned int aParamIndex); |
||||
virtual float getParamMin(unsigned int aParamIndex); |
||||
}; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,106 @@ |
||||
/*
|
||||
SoLoud audio engine |
||||
Copyright (c) 2013-2018 Jari Komppa |
||||
|
||||
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: |
||||
|
||||
1. 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. |
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
|
||||
3. This notice may not be removed or altered from any source |
||||
distribution. |
||||
*/ |
||||
|
||||
#ifndef SOLOUD_WAVSTREAM_H |
||||
#define SOLOUD_WAVSTREAM_H |
||||
|
||||
#include <stdio.h> |
||||
#include "soloud.h" |
||||
|
||||
struct stb_vorbis; |
||||
#ifndef dr_flac_h |
||||
struct drflac; |
||||
#endif |
||||
#ifndef dr_mp3_h |
||||
struct drmp3; |
||||
#endif |
||||
#ifndef dr_wav_h |
||||
struct drwav; |
||||
#endif |
||||
|
||||
namespace SoLoud |
||||
{ |
||||
class WavStream; |
||||
class File; |
||||
|
||||
class WavStreamInstance : public AudioSourceInstance |
||||
{ |
||||
WavStream *mParent; |
||||
unsigned int mOffset; |
||||
File *mFile; |
||||
union codec |
||||
{ |
||||
stb_vorbis *mOgg; |
||||
drflac *mFlac; |
||||
drmp3 *mMp3; |
||||
drwav *mWav; |
||||
} mCodec; |
||||
unsigned int mOggFrameSize; |
||||
unsigned int mOggFrameOffset; |
||||
float **mOggOutputs; |
||||
public: |
||||
WavStreamInstance(WavStream *aParent); |
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||
virtual result rewind(); |
||||
virtual bool hasEnded(); |
||||
virtual ~WavStreamInstance(); |
||||
}; |
||||
|
||||
enum WAVSTREAM_FILETYPE |
||||
{ |
||||
WAVSTREAM_WAV = 0, |
||||
WAVSTREAM_OGG = 1, |
||||
WAVSTREAM_FLAC = 2, |
||||
WAVSTREAM_MP3 = 3 |
||||
}; |
||||
|
||||
class WavStream : public AudioSource |
||||
{ |
||||
result loadwav(File *fp); |
||||
result loadogg(File *fp); |
||||
result loadflac(File *fp); |
||||
result loadmp3(File *fp); |
||||
public: |
||||
int mFiletype; |
||||
char *mFilename; |
||||
File *mMemFile; |
||||
File *mStreamFile; |
||||
unsigned int mSampleCount; |
||||
|
||||
WavStream(); |
||||
virtual ~WavStream(); |
||||
result load(const char *aFilename); |
||||
result loadMem(const unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true); |
||||
result loadToMem(const char *aFilename); |
||||
result loadFile(File *aFile); |
||||
result loadFileToMem(File *aFile);
|
||||
virtual AudioSourceInstance *createInstance(); |
||||
time getLength(); |
||||
|
||||
public: |
||||
result parse(File *aFile); |
||||
}; |
||||
}; |
||||
|
||||
#endif |
Loading…
Reference in new issue