Fixed heap corruption bugs causing crash on launch in release builds

dev
Shariq Shah 5 years ago
parent 120cf39ba0
commit a53f735155
  1. 116
      assets/entities/door_red_green.symtres
  2. 206
      include/common/soloud/soloud.h
  3. 40
      include/common/soloud/soloud_audiosource.h
  4. 70
      include/common/soloud/soloud_ay.h
  5. 5
      include/common/soloud/soloud_bassboostfilter.h
  6. 33
      include/common/soloud/soloud_biquadresonantfilter.h
  7. 20
      include/common/soloud/soloud_bus.h
  8. 635
      include/common/soloud/soloud_c.h
  9. 2
      include/common/soloud/soloud_dcremovalfilter.h
  10. 18
      include/common/soloud/soloud_echofilter.h
  11. 82
      include/common/soloud/soloud_eqfilter.h
  12. 6
      include/common/soloud/soloud_fft.h
  13. 11
      include/common/soloud/soloud_fftfilter.h
  14. 8
      include/common/soloud/soloud_file.h
  15. 3
      include/common/soloud/soloud_file_hack_off.h
  16. 4
      include/common/soloud/soloud_file_hack_on.h
  17. 14
      include/common/soloud/soloud_filter.h
  18. 13
      include/common/soloud/soloud_flangerfilter.h
  19. 83
      include/common/soloud/soloud_freeverbfilter.h
  20. 71
      include/common/soloud/soloud_internal.h
  21. 7
      include/common/soloud/soloud_lofifilter.h
  22. 53
      include/common/soloud/soloud_misc.h
  23. 16
      include/common/soloud/soloud_monotone.h
  24. 74
      include/common/soloud/soloud_noise.h
  25. 4
      include/common/soloud/soloud_openmpt.h
  26. 72
      include/common/soloud/soloud_queue.h
  27. 72
      include/common/soloud/soloud_robotizefilter.h
  28. 18
      include/common/soloud/soloud_sfxr.h
  29. 18
      include/common/soloud/soloud_speech.h
  30. 14
      include/common/soloud/soloud_tedsid.h
  31. 1
      include/common/soloud/soloud_thread.h
  32. 18
      include/common/soloud/soloud_vic.h
  33. 84
      include/common/soloud/soloud_vizsn.h
  34. 18
      include/common/soloud/soloud_wav.h
  35. 63
      include/common/soloud/soloud_waveshaperfilter.h
  36. 41
      include/common/soloud/soloud_wavstream.h
  37. 115
      include/common/soloud/zx7decompress.h
  38. BIN
      lib/windows/soloud/soloud_x64.dll
  39. BIN
      lib/windows/soloud/soloud_x64.exp
  40. BIN
      lib/windows/soloud/soloud_x64.lib
  41. BIN
      lib/windows/soloud/soloud_x64_d.dll
  42. BIN
      lib/windows/soloud/soloud_x64_d.exp
  43. BIN
      lib/windows/soloud/soloud_x64_d.ilk
  44. BIN
      lib/windows/soloud/soloud_x64_d.lib
  45. BIN
      lib/windows/soloud/soloud_x64_d.pdb
  46. 20
      src/common/hashmap.c
  47. 2
      src/common/limits.h
  48. 11
      src/common/memory_utils.c
  49. 4
      src/common/version.h

@ -0,0 +1,116 @@
Entity
{
type : 10
scale : 1.000 1.000 1.000
door_state : 0
door_open_position : -7.0000
rotation : 0.000 0.000 0.000 1.000
door_close_position : 0.0000
door_speed : 6.0000
position : -9.000 1.000 -6.000
flags : 1
door_mask : 3
name : Door
archetype : door_blue
bounding_box_min : -0.500 -0.500 -0.500
bounding_box_max : 0.500 0.500 0.500
}
Entity
{
type : 9
scale : 7.000 11.000 14.000
rotation : 0.000 0.000 0.000 1.000
trigger_mask : 1
position : 0.000 5.000 0.000
flags : 9
trigger_type : 1
name : Door_Trigger
bounding_box_min : -0.500 -0.500 -0.500
bounding_box_max : 0.500 0.500 0.500
}
Entity
{
type : 7
scale : 1.000 1.000 1.000
volume : 1.0000
rolloff_factor : 0.9500
rotation : 0.000 0.000 0.000 1.000
loop : false
sound_min_distance : 0.0000
position : 0.000 0.000 0.000
flags : 9
source_filename : sounds/door_locked.wav
sound_type : 1
sound_max_distance : 30.0000
name : Door_Sound
bounding_box_min : -0.500 -0.500 -0.500
sound_attenuation_type : 2
paused : true
bounding_box_max : 0.500 0.500 0.500
}
Entity
{
type : 6
scale : 7.000 12.000 0.200
material : 0
rotation : 0.000 0.000 0.000 1.000
diffuse_color : 0.055 0.863 0.839 1.000
geometry : cube.symbres
specular : 0.4000
diffuse_texture : default.tga
diffuse : 1.0000
position : 0.012 4.500 0.000
flags : 9
specular_strength : 62.0000
name : Door_Mesh
uv_scale : 0.300 0.200
}
Entity
{
type : 6
scale : 1.000 1.000 1.000
material : 1
rotation : 0.000 0.000 0.000 1.000
diffuse_color : 0.870 0.320 0.400 1.000
geometry : cube.symbres
diffuse_texture : white.tga
position : 4.000 7.500 0.000
flags : 9
name : Door_Key_Indicator_Red
uv_scale : 0.300 0.200
}
Entity
{
type : 6
scale : 1.000 1.000 1.000
material : 1
rotation : 0.000 0.000 0.000 1.000
diffuse_color : 0.530 0.670 0.280 1.000
geometry : cube.symbres
diffuse_texture : white.tga
position : 4.000 5.500 0.000
flags : 9
name : Door_Key_Indicator_Green
uv_scale : 0.300 0.200
}
Entity
{
type : 6
scale : 1.000 1.000 1.000
material : 1
rotation : 0.000 0.000 0.000 1.000
diffuse_color : 0.100 0.100 0.100 1.000
geometry : cube.symbres
diffuse_texture : white.tga
position : 4.000 3.500 0.000
flags : 9
name : Door_Key_Indicator_Blue
uv_scale : 0.300 0.200
}

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
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
@ -28,6 +28,37 @@ freely, subject to the following restrictions:
#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
@ -42,7 +73,7 @@ freely, subject to the following restrictions:
#endif
#endif
#define SOLOUD_VERSION 111
#define SOLOUD_VERSION 202002
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
@ -57,11 +88,11 @@ freely, subject to the following restrictions:
// 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
// 1)mono, 2)stereo 4)quad 6)5.1
#define MAX_CHANNELS 6
// Default resampler for both main and bus mixers
#define SOLOUD_DEFAULT_RESAMPLER SoLoud::Soloud::RESAMPLER_LINEAR
//
/////////////////////////////////////////////////////////////////////
@ -87,20 +118,35 @@ namespace SoLoud
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
@ -114,6 +160,8 @@ namespace SoLoud
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;
@ -125,18 +173,21 @@ namespace SoLoud
enum BACKENDS
{
AUTO = 0,
SDL,
SDL1,
SDL2,
PORTAUDIO,
WINMM,
XAUDIO2,
WASAPI,
ALSA,
JACK,
OSS,
OPENAL,
COREAUDIO,
OPENSLES,
VITA_HOMEBREW,
MINIAUDIO,
NOSOUND,
NULLDRIVER,
BACKEND_MAX,
};
@ -146,7 +197,28 @@ namespace SoLoud
// Use round-off clipper
CLIP_ROUNDOFF = 1,
ENABLE_VISUALIZATION = 2,
LEFT_HANDED_3D = 4
LEFT_HANDED_3D = 4,
NO_FPU_REGISTER_CHANGE = 8
};
enum WAVEFORM
{
WAVE_SQUARE = 0,
WAVE_SAW,
WAVE_SIN,
WAVE_TRIANGLE,
WAVE_BOUNCE,
WAVE_JAWS,
WAVE_HUMPS,
WAVE_FSQUARE,
WAVE_FSAW
};
enum RESAMPLER
{
RESAMPLER_POINT,
RESAMPLER_LINEAR,
RESAMPLER_CATMULLROM
};
// Initialize SoLoud. Must be called before SoLoud can be used.
@ -174,6 +246,8 @@ namespace SoLoud
// 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);
@ -187,13 +261,15 @@ namespace SoLoud
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.
void seek(handle aVoiceHandle, time aSeconds);
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);
@ -206,6 +282,8 @@ namespace SoLoud
// 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.
@ -228,15 +306,25 @@ namespace SoLoud
float getRelativePlaySpeed(handle aVoiceHandle);
// Get current post-clip scaler value.
float getPostClipScaler() const;
// Get the current main resampler
unsigned int getMainResampler() 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);
// Query whether a voice is set to auto-stop when it ends.
bool getAutoStop(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 whether sound should auto-stop when it ends
void setAutoStop(handle aVoiceHandle, bool aAutoStop);
// Set current maximum active voice setting
result setMaxActiveVoiceCount(unsigned int aVoiceCount);
// Set behavior for inaudible sounds
@ -245,6 +333,8 @@ namespace SoLoud
void setGlobalVolume(float aVolume);
// Set the post clip scaler value
void setPostClipScaler(float aScaler);
// Set the main resampler
void setMainResampler(unsigned int aResampler);
// Set the pause state
void setPause(handle aVoiceHandle, bool aPause);
// Pause all voices
@ -258,7 +348,9 @@ namespace SoLoud
// 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);
void setPanAbsolute(handle aVoiceHandle, float aLVolume, float aRVolume);
// Set channel volume (volume for a specific speaker)
void setChannelVolume(handle aVoiceHandle, unsigned int aChannel, float aVolume);
// 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.
@ -298,6 +390,9 @@ namespace SoLoud
// 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);
@ -354,15 +449,51 @@ namespace SoLoud
void mixSigned16(short *aBuffer, unsigned int aSamples);
public:
// Mix N samples * M channels. Called by other mix_ functions.
void mix_internal(unsigned int aSamples);
void mix_internal(unsigned int aSamples, unsigned int aStride);
// Handle rest of initialization (called from backend)
void postinit(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels);
void postinit_internal(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels);
// Update list of active voices
void calcActiveVoices();
void calcActiveVoices_internal();
// Map resample buffers to active voices
void mapResampleBuffers_internal();
// Perform mixing for a specific bus
void mixBus(float *aBuffer, unsigned int aSamples, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels);
void mixBus_internal(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels, unsigned int aResampler);
// 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
@ -371,12 +502,18 @@ namespace SoLoud
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;
// Pointers to resampler buffers, two per active voice.
float **mResampleData;
// Actual allocated memory for resampler buffers
AlignedFloatBuffer mResampleDataBuffer;
// Owners of the resample data
AudioSourceInstance **mResampleDataOwner;
// Audio voices.
AudioSourceInstance *mVoice[VOICE_COUNT];
// Resampler for the main bus
unsigned int mResampler;
// Output sample rate (not float)
unsigned int mSamplerate;
// Output channel count
@ -407,30 +544,9 @@ namespace SoLoud
Filter *mFilter[FILTERS_PER_STREAM];
// Global filter instance
FilterInstance *mFilterInstance[FILTERS_PER_STREAM];
// Find a free voice, stopping the oldest if no free voice is found.
int findFreeVoice();
// Converts handle to voice, if the handle is valid. Returns -1 if not.
int getVoiceFromHandle(handle aVoiceHandle) const;
// Converts voice + playindex into handle
handle getHandleFromVoice(unsigned int aVoice) const;
// Stop voice (not handle).
void stopVoice(unsigned int aVoice);
// Set voice (not handle) pan.
void setVoicePan(unsigned int aVoice, float aPan);
// Set voice (not handle) relative play speed.
result setVoiceRelativePlaySpeed(unsigned int aVoice, float aSpeed);
// Set voice (not handle) volume.
void setVoiceVolume(unsigned int aVoice, float aVolume);
// Set voice (not handle) pause state.
void setVoicePause(unsigned int aVoice, int aPause);
// Update overall volume from set and 3d volumes
void updateVoiceVolume(unsigned int aVoice);
// Update overall relative play speed from set and 3d speeds
void updateVoiceRelativePlaySpeed(unsigned int aVoice);
// Perform 3d audio calculation for array of voices
void update3dVoices(unsigned int *aVoiceList, unsigned int aVoiceCount);
// Clip the samples in the buffer
void clip(AlignedFloatBuffer &aBuffer, AlignedFloatBuffer &aDestBuffer, unsigned int aSamples, float aVolume0, float aVolume1);
// 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
@ -465,16 +581,6 @@ namespace SoLoud
unsigned int mActiveVoiceCount;
// Active voices list needs to be recalculated
bool mActiveVoiceDirty;
// Remove all non-active voices from group
void trimVoiceGroup(handle aVoiceGroupHandle);
// Get pointer to the zero-terminated array of voice handles in a voice group
handle * voiceGroupHandleToArray(handle aVoiceGroupHandle) const;
// Lock audio thread mutex.
void lockAudioMutex();
// Unlock audio thread mutex.
void unlockAudioMutex();
};
};

@ -35,13 +35,6 @@ namespace SoLoud
class AudioSourceInstance;
class AudioSourceInstance3dData;
struct AudioSourceResampleData
{
AudioSourceResampleData();
~AudioSourceResampleData();
float *mBuffer;
};
class AudioCollider
{
public:
@ -126,7 +119,9 @@ namespace SoLoud
// If inaudible, should be killed (default = don't kill kill)
INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128
INAUDIBLE_TICK = 128,
// Don't auto-stop sound
DISABLE_AUTOSTOP = 256
};
// Ctor
AudioSourceInstance();
@ -158,6 +153,8 @@ namespace SoLoud
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
@ -180,21 +177,23 @@ namespace SoLoud
FilterInstance *mFilter[FILTERS_PER_STREAM];
// Initialize instance. Mostly internal use.
void init(AudioSource &aSource, int aPlayIndex);
// Buffers for the resampler
AudioSourceResampleData *mResampleData[2];
// Pointers to buffers for the resampler
float *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
virtual void getAudio(float *aBuffer, unsigned int aSamples) = 0;
// 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 void seek(time aSeconds, float *mScratch, unsigned int mScratchSize);
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.
@ -224,7 +223,9 @@ namespace SoLoud
// If inaudible, should be killed (default)
INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128
INAUDIBLE_TICK = 128,
// Disable auto-stop
DISABLE_AUTOSTOP = 256
};
enum ATTENUATION_MODELS
{
@ -268,6 +269,8 @@ namespace SoLoud
AudioAttenuator *mAttenuator;
// User data related to audio collider
int mColliderData;
// When looping, start playing from this time
time mLoopPoint;
// CTor
AudioSource();
@ -277,6 +280,8 @@ namespace SoLoud
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 whether audio should auto-stop when it ends or not
void setAutoStop(bool aAutoStop);
// Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol)
void set3dMinMaxDistance(float aMinDistance, float aMaxDistance);
@ -284,8 +289,6 @@ namespace SoLoud
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
// Set doppler factor to reduce or enhance doppler effect, default = 1.0
void set3dDopplerFactor(float aDopplerFactor);
// Enable 3d processing. Implicitly set by play3d calls.
void set3dProcessing(bool aDo3dProcessing);
// 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.
@ -299,6 +302,11 @@ namespace SoLoud
// 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

@ -0,0 +1,70 @@
/*
AY module for 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 AY_H
#define AY_H
#include "soloud.h"
class ChipPlayer;
namespace SoLoud
{
class Ay;
class File;
class AyInstance : public AudioSourceInstance
{
public:
Ay *mParent;
ChipPlayer *mChip;
int mPos;
AyInstance(Ay *aParent);
~AyInstance();
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
virtual result rewind();
virtual float getInfo(unsigned int aInfoKey);
};
class Ay : public AudioSource
{
public:
bool mYm;
int mChipspeed;
int mCpuspeed;
int mLooppos;
int mLength;
unsigned short* mOps;
public:
Ay();
~Ay();
result load(const char *aFilename);
result loadFile(File *aFile);
result loadMem(const unsigned char* aMem, unsigned int aLength, bool aCopy, bool aTakeOwnership);
virtual AudioSourceInstance *createInstance();
};
};
#endif

@ -53,6 +53,11 @@ namespace SoLoud
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();

@ -41,16 +41,15 @@ namespace SoLoud
enum FILTERATTRIBUTE
{
WET = 0,
SAMPLERATE = 1,
FREQUENCY = 2,
RESONANCE = 3
TYPE,
FREQUENCY,
RESONANCE
};
int mActive;
BQRStateData mState[2];
BQRStateData mState[8];
float mA0, mA1, mA2, mB1, mB2;
int mDirty;
int mFilterType;
float mSamplerate;
BiquadResonantFilter *mParent;
void calcBQRParams();
@ -65,25 +64,29 @@ namespace SoLoud
public:
enum FILTERTYPE
{
NONE = 0,
LOWPASS = 1,
HIGHPASS = 2,
BANDPASS = 3
LOWPASS = 0,
HIGHPASS = 1,
BANDPASS = 2
};
enum FILTERATTRIBUTE
{
WET = 0,
SAMPLERATE = 1,
FREQUENCY = 2,
RESONANCE = 3
TYPE,
FREQUENCY,
RESONANCE
};
int mFilterType;
float mSampleRate;
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 aSampleRate, float aFrequency, float aResonance);
result setParams(int aType, float aFrequency, float aResonance);
virtual ~BiquadResonantFilter();
};
}

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
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
@ -37,11 +37,13 @@ namespace SoLoud
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 void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
virtual ~BusInstance();
};
@ -65,15 +67,29 @@ namespace SoLoud
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();
// Get current the resampler for this bus
unsigned int getResampler();
// Set the resampler for this bus
void setResampler(unsigned int aResampler);
public:
BusInstance *mInstance;
unsigned int mChannelHandle;
unsigned int mResampler;
// FFT output data
float mFFTData[256];
// Snapshot of wave data for visualization

@ -5,7 +5,7 @@
/*
SoLoud audio engine
Copyright (c) 2013-2016 Jari Komppa
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
@ -27,7 +27,7 @@ freely, subject to the following restrictions:
distribution.
*/
/* SoLoud C-Api Code Generator (c)2013-2016 Jari Komppa http://iki.fi/sol/ */
/* SoLoud C-Api Code Generator (c)2013-2020 Jari Komppa http://iki.fi/sol/ */
#ifndef SOLOUD_C_H_INCLUDED
#define SOLOUD_C_H_INCLUDED
@ -39,35 +39,70 @@ extern "C" {
enum SOLOUD_ENUMS
{
SOLOUD_AUTO = 0,
SOLOUD_SDL = 1,
SOLOUD_SDL1 = 1,
SOLOUD_SDL2 = 2,
SOLOUD_PORTAUDIO = 3,
SOLOUD_WINMM = 4,
SOLOUD_XAUDIO2 = 5,
SOLOUD_WASAPI = 6,
SOLOUD_ALSA = 7,
SOLOUD_OSS = 8,
SOLOUD_OPENAL = 9,
SOLOUD_COREAUDIO = 10,
SOLOUD_OPENSLES = 11,
SOLOUD_NULLDRIVER = 12,
SOLOUD_BACKEND_MAX = 13,
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,
BIQUADRESONANTFILTER_NONE = 0,
BIQUADRESONANTFILTER_LOWPASS = 1,
BIQUADRESONANTFILTER_HIGHPASS = 2,
BIQUADRESONANTFILTER_BANDPASS = 3,
SOLOUD_NO_FPU_REGISTER_CHANGE = 8,
SOLOUD_WAVE_SQUARE = 0,
SOLOUD_WAVE_SAW = 1,
SOLOUD_WAVE_SIN = 2,
SOLOUD_WAVE_TRIANGLE = 3,
SOLOUD_WAVE_BOUNCE = 4,
SOLOUD_WAVE_JAWS = 5,
SOLOUD_WAVE_HUMPS = 6,
SOLOUD_WAVE_FSQUARE = 7,
SOLOUD_WAVE_FSAW = 8,
SOLOUD_RESAMPLER_POINT = 0,
SOLOUD_RESAMPLER_LINEAR = 1,
SOLOUD_RESAMPLER_CATMULLROM = 2,
BASSBOOSTFILTER_WET = 0,
BASSBOOSTFILTER_BOOST = 1,
BIQUADRESONANTFILTER_LOWPASS = 0,
BIQUADRESONANTFILTER_HIGHPASS = 1,
BIQUADRESONANTFILTER_BANDPASS = 2,
BIQUADRESONANTFILTER_WET = 0,
BIQUADRESONANTFILTER_SAMPLERATE = 1,
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,
BASSBOOSTFILTER_WET = 0,
BASSBOOSTFILTER_BOOST = 1,
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,
@ -75,39 +110,56 @@ enum SOLOUD_ENUMS
SFXR_HURT = 4,
SFXR_JUMP = 5,
SFXR_BLIP = 6,
FLANGERFILTER_WET = 0,
FLANGERFILTER_DELAY = 1,
FLANGERFILTER_FREQ = 2,
MONOTONE_SQUARE = 0,
MONOTONE_SAW = 1,
MONOTONE_SIN = 2,
MONOTONE_SAWSIN = 3
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 * Ay;
typedef void * AudioCollider;
typedef void * AudioAttenuator;
typedef void * AudioSource;
typedef void * BassboostFilter;
typedef void * BiquadResonantFilter;
typedef void * LofiFilter;
typedef void * Bus;
typedef void * DCRemovalFilter;
typedef void * EchoFilter;
typedef void * Fader;
typedef void * FFTFilter;
typedef void * BassboostFilter;
typedef void * Filter;
typedef void * Speech;
typedef void * Wav;
typedef void * WavStream;
typedef void * Prg;
typedef void * Sfxr;
typedef void * FlangerFilter;
typedef void * DCRemovalFilter;
typedef void * Openmpt;
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;
/*
@ -126,6 +178,7 @@ 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);
@ -134,15 +187,19 @@ unsigned int Soloud_play3d(Soloud * aSoloud, AudioSource * aSound, float aPosX,
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 */);
void Soloud_seek(Soloud * aSoloud, unsigned int aVoiceHandle, double aSeconds);
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);
@ -154,14 +211,20 @@ 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);
unsigned int Soloud_getMainResampler(Soloud * aSoloud);
float Soloud_getGlobalVolume(Soloud * aSoloud);
unsigned int Soloud_getMaxActiveVoiceCount(Soloud * aSoloud);
int Soloud_getLooping(Soloud * aSoloud, unsigned int aVoiceHandle);
int Soloud_getAutoStop(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);
void Soloud_setAutoStop(Soloud * aSoloud, unsigned int aVoiceHandle, int aAutoStop);
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_setMainResampler(Soloud * aSoloud, unsigned int aResampler);
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);
@ -169,7 +232,7 @@ void Soloud_setProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle, int aPr
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_setChannelVolume(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aChannel, float aVolume);
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);
@ -186,6 +249,7 @@ void Soloud_setGlobalFilter(Soloud * aSoloud, unsigned int aFilterId, Filter * a
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);
@ -213,24 +277,50 @@ void Soloud_mix(Soloud * aSoloud, float * aBuffer, unsigned int aSamples);
void Soloud_mixSigned16(Soloud * aSoloud, short * aBuffer, unsigned int aSamples);
/*
* AudioAttenuator
* Ay
*/
void AudioAttenuator_destroy(AudioAttenuator * aAudioAttenuator);
float AudioAttenuator_attenuate(AudioAttenuator * aAudioAttenuator, float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor);
void Ay_destroy(Ay * aAy);
Ay * Ay_create();
void Ay_setVolume(Ay * aAy, float aVolume);
void Ay_setLooping(Ay * aAy, int aLoop);
void Ay_setAutoStop(Ay * aAy, int aAutoStop);
void Ay_set3dMinMaxDistance(Ay * aAy, float aMinDistance, float aMaxDistance);
void Ay_set3dAttenuation(Ay * aAy, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Ay_set3dDopplerFactor(Ay * aAy, float aDopplerFactor);
void Ay_set3dListenerRelative(Ay * aAy, int aListenerRelative);
void Ay_set3dDistanceDelay(Ay * aAy, int aDistanceDelay);
void Ay_set3dCollider(Ay * aAy, AudioCollider * aCollider);
void Ay_set3dColliderEx(Ay * aAy, AudioCollider * aCollider, int aUserData /* = 0 */);
void Ay_set3dAttenuator(Ay * aAy, AudioAttenuator * aAttenuator);
void Ay_setInaudibleBehavior(Ay * aAy, int aMustTick, int aKill);
void Ay_setLoopPoint(Ay * aAy, double aLoopPoint);
double Ay_getLoopPoint(Ay * aAy);
void Ay_setFilter(Ay * aAy, unsigned int aFilterId, Filter * aFilter);
void Ay_stop(Ay * aAy);
/*
* BiquadResonantFilter
* BassboostFilter
*/
void BiquadResonantFilter_destroy(BiquadResonantFilter * aBiquadResonantFilter);
BiquadResonantFilter * BiquadResonantFilter_create();
int BiquadResonantFilter_setParams(BiquadResonantFilter * aBiquadResonantFilter, int aType, float aSampleRate, float aFrequency, float aResonance);
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();
/*
* LofiFilter
* BiquadResonantFilter
*/
void LofiFilter_destroy(LofiFilter * aLofiFilter);
LofiFilter * LofiFilter_create();
int LofiFilter_setParams(LofiFilter * aLofiFilter, float aSampleRate, float aBitdepth);
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
@ -248,26 +338,51 @@ unsigned int Bus_play3dClocked(Bus * aBus, double aSoundTime, AudioSource * aSou
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);
unsigned int Bus_getResampler(Bus * aBus);
void Bus_setResampler(Bus * aBus, unsigned int aResampler);
void Bus_setVolume(Bus * aBus, float aVolume);
void Bus_setLooping(Bus * aBus, int aLoop);
void Bus_setAutoStop(Bus * aBus, int aAutoStop);
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_set3dProcessing(Bus * aBus, int aDo3dProcessing);
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 */);
@ -277,13 +392,193 @@ int EchoFilter_setParamsEx(EchoFilter * aEchoFilter, float aDelay, float aDecay
*/
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);
/*
* BassboostFilter
* FlangerFilter
*/
void BassboostFilter_destroy(BassboostFilter * aBassboostFilter);
int BassboostFilter_setParams(BassboostFilter * aBassboostFilter, float aBoost);
BassboostFilter * BassboostFilter_create();
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::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_setAutoStop(Monotone * aMonotone, int aAutoStop);
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_setAutoStop(Noise * aNoise, int aAutoStop);
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_setAutoStop(Openmpt * aOpenmpt, int aAutoStop);
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_setAutoStop(Queue * aQueue, int aAutoStop);
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_setAutoStop(Sfxr * aSfxr, int aAutoStop);
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
@ -291,197 +586,173 @@ BassboostFilter * BassboostFilter_create();
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_setAutoStop(Speech * aSpeech, int aAutoStop);
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_set3dProcessing(Speech * aSpeech, int aDo3dProcessing);
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_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_loadFile(TedSid * aTedSid, File * aFile);
void TedSid_setVolume(TedSid * aTedSid, float aVolume);
void TedSid_setLooping(TedSid * aTedSid, int aLoop);
void TedSid_setAutoStop(TedSid * aTedSid, int aAutoStop);
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_setAutoStop(Vic * aVic, int aAutoStop);
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_setAutoStop(Vizsn * aVizsn, int aAutoStop);
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, unsigned char * aMem, unsigned int aLength);
int Wav_loadMemEx(Wav * aWav, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */);
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_setAutoStop(Wav * aWav, int aAutoStop);
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_set3dProcessing(Wav * aWav, int aDo3dProcessing);
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, unsigned char * aData, unsigned int aDataLen);
int WavStream_loadMemEx(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen, int aCopy /* = false */, int aTakeOwnership /* = true */);
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_setAutoStop(WavStream * aWavStream, int aAutoStop);
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_set3dProcessing(WavStream * aWavStream, int aDo3dProcessing);
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);
/*
* Prg
*/
void Prg_destroy(Prg * aPrg);
Prg * Prg_create();
unsigned int Prg_rand(Prg * aPrg);
void Prg_srand(Prg * aPrg, int aSeed);
/*
* 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_set3dProcessing(Sfxr * aSfxr, int aDo3dProcessing);
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_setFilter(Sfxr * aSfxr, unsigned int aFilterId, Filter * aFilter);
void Sfxr_stop(Sfxr * aSfxr);
/*
* FlangerFilter
*/
void FlangerFilter_destroy(FlangerFilter * aFlangerFilter);
FlangerFilter * FlangerFilter_create();
int FlangerFilter_setParams(FlangerFilter * aFlangerFilter, float aDelay, float aFreq);
/*
* DCRemovalFilter
*/
void DCRemovalFilter_destroy(DCRemovalFilter * aDCRemovalFilter);
DCRemovalFilter * DCRemovalFilter_create();
int DCRemovalFilter_setParams(DCRemovalFilter * aDCRemovalFilter);
int DCRemovalFilter_setParamsEx(DCRemovalFilter * aDCRemovalFilter, float aLength /* = 0.1f */);
/*
* Openmpt
*/
void Openmpt_destroy(Openmpt * aOpenmpt);
Openmpt * Openmpt_create();
int Openmpt_load(Openmpt * aOpenmpt, const char * aFilename);
int Openmpt_loadMem(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength);
int Openmpt_loadMemEx(Openmpt * aOpenmpt, 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_set3dProcessing(Openmpt * aOpenmpt, int aDo3dProcessing);
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_setFilter(Openmpt * aOpenmpt, unsigned int aFilterId, Filter * aFilter);
void Openmpt_stop(Openmpt * aOpenmpt);
/*
* 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 /* = SQUARE */);
int Monotone_load(Monotone * aMonotone, const char * aFilename);
int Monotone_loadMem(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength);
int Monotone_loadMemEx(Monotone * aMonotone, 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_set3dProcessing(Monotone * aMonotone, int aDo3dProcessing);
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_setFilter(Monotone * aMonotone, unsigned int aFilterId, Filter * aFilter);
void Monotone_stop(Monotone * aMonotone);
/*
* 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, unsigned char * aMem, unsigned int aLength);
int TedSid_loadMemEx(TedSid * aTedSid, 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_set3dProcessing(TedSid * aTedSid, int aDo3dProcessing);
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_setFilter(TedSid * aTedSid, unsigned int aFilterId, Filter * aFilter);
void TedSid_stop(TedSid * aTedSid);
#ifdef __cplusplus
} // extern "C"
#endif

@ -40,7 +40,7 @@ namespace SoLoud
int mOffset;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~DCRemovalFilterInstance();
DCRemovalFilterInstance(DCRemovalFilter *aParent);
};

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
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
@ -35,11 +35,11 @@ namespace SoLoud
{
float *mBuffer;
int mBufferLength;
EchoFilter *mParent;
int mBufferMaxLength;
int mOffset;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~EchoFilterInstance();
EchoFilterInstance(EchoFilter *aParent);
};
@ -47,9 +47,21 @@ namespace SoLoud
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);

@ -0,0 +1,82 @@
/*
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_EQFILTER_H
#define SOLOUD_EQFILTER_H
#include "soloud.h"
#include "soloud_fftfilter.h"
namespace SoLoud
{
class EqFilter;
class EqFilterInstance : public FFTFilterInstance
{
enum FILTERATTRIBUTE
{
WET = 0,
BAND1 = 1,
BAND2 = 2,
BAND3 = 3,
BAND4 = 4,
BAND5 = 5,
BAND6 = 6,
BAND7 = 7,
BAND8 = 8
};
EqFilter *mParent;
public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
EqFilterInstance(EqFilter *aParent);
};
class EqFilter : public FFTFilter
{
public:
enum FILTERATTRIBUTE
{
WET = 0,
BAND1 = 1,
BAND2 = 2,
BAND3 = 3,
BAND4 = 4,
BAND5 = 5,
BAND6 = 6,
BAND7 = 7,
BAND8 = 8
};
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 mVolume[8];
result setParam(unsigned int aBand, float aVolume);
virtual FilterInstance *createInstance();
EqFilter();
};
}
#endif

@ -39,6 +39,12 @@ namespace SoLoud
// 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);
};
};

@ -36,7 +36,11 @@ namespace SoLoud
float *mTemp;
float *mInputBuffer;
float *mMixBuffer;
unsigned int mOffset[MAX_CHANNELS];
float *mLastPhase;
float *mSumPhase;
unsigned int mInputOffset[MAX_CHANNELS];
unsigned int mMixOffset[MAX_CHANNELS];
unsigned int mReadOffset[MAX_CHANNELS];
FFTFilter *mParent;
public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
@ -44,6 +48,11 @@ namespace SoLoud
virtual ~FFTFilterInstance();
FFTFilterInstance(FFTFilter *aParent);
FFTFilterInstance();
void comp2MagPhase(float* aFFTBuffer, unsigned int aSamples);
void magPhase2MagFreq(float* aFFTBuffer, unsigned int aSamples, float aSamplerate, unsigned int aChannel);
void magFreq2MagPhase(float* aFFTBuffer, unsigned int aSamples, float aSamplerate, unsigned int aChannel);
void magPhase2Comp(float* aFFTBuffer, unsigned int aSamples);
void init();
};
class FFTFilter : public Filter

@ -45,7 +45,7 @@ namespace SoLoud
virtual void seek(int aOffset) = 0;
virtual unsigned int pos() = 0;
virtual FILE * getFilePtr() { return 0; }
virtual unsigned char * getMemPtr() { return 0; }
virtual const unsigned char * getMemPtr() { return 0; }
};
class DiskFile : public File
@ -68,7 +68,7 @@ namespace SoLoud
class MemoryFile : public File
{
public:
unsigned char *mDataPtr;
const unsigned char *mDataPtr;
unsigned int mDataLength;
unsigned int mOffset;
bool mDataOwned;
@ -78,10 +78,10 @@ namespace SoLoud
virtual unsigned int length();
virtual void seek(int aOffset);
virtual unsigned int pos();
virtual unsigned char * getMemPtr();
virtual const unsigned char * getMemPtr();
virtual ~MemoryFile();
MemoryFile();
result openMem(unsigned char *aData, unsigned int aDataLength, bool aCopy=false, bool aTakeOwnership=true);
result openMem(const unsigned char *aData, unsigned int aDataLength, bool aCopy=false, bool aTakeOwnership=true);
result openToMem(const char *aFilename);
result openFileToMem(File *aFile);
};

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
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
@ -33,3 +33,4 @@ See soloud_file_hack_on.h
#undef ftell
#undef fclose
#undef fopen
#undef fopen_s

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
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
@ -44,6 +44,7 @@ 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
}
@ -56,3 +57,4 @@ extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMod
#define ftell Soloud_Filehack_ftell
#define fclose Soloud_Filehack_fclose
#define fopen Soloud_Filehack_fopen
#define fopen_s Soloud_Filehack_fopen_s

@ -43,7 +43,7 @@ namespace SoLoud
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 filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, 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);
@ -55,7 +55,19 @@ namespace SoLoud
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();
};

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
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
@ -34,13 +34,13 @@ namespace SoLoud
class FlangerFilterInstance : public FilterInstance
{
float *mBuffer;
int mBufferLength;
unsigned int mBufferLength;
FlangerFilter *mParent;
int mOffset;
unsigned int mOffset;
double mIndex;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~FlangerFilterInstance();
FlangerFilterInstance(FlangerFilter *aParent);
};
@ -56,6 +56,11 @@ namespace SoLoud
};
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);

@ -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 aBufferSize, 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

@ -29,11 +29,14 @@ freely, subject to the following restrictions:
namespace SoLoud
{
// SDL back-end initialization call
result sdl_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// 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);
// SDL "non-dynamic" back-end initialization call
result sdlstatic_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);
@ -68,28 +71,34 @@ namespace SoLoud
// 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);
void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels, unsigned int aStride);
// 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);
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels, unsigned int aStride);
};
#define FOR_ALL_VOICES_PRE \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
lockAudioMutex(); \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
lockAudioMutex_internal(); \
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = getVoiceFromHandle(*h_); \
int ch = getVoiceFromHandle_internal(*h_); \
if (ch != -1) \
{
@ -97,12 +106,12 @@ namespace SoLoud
} \
h_++; \
} \
unlockAudioMutex();
unlockAudioMutex_internal();
#define FOR_ALL_VOICES_PRE_3D \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
@ -115,4 +124,38 @@ namespace SoLoud
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

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
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
@ -66,6 +66,11 @@ namespace SoLoud
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();

@ -0,0 +1,53 @@
/*
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
{
// 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

@ -1,6 +1,6 @@
/*
MONOTONE module for SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
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
@ -26,6 +26,7 @@ freely, subject to the following restrictions:
#define MONOTONE_H
#include "soloud.h"
#include "soloud_misc.h"
namespace SoLoud
{
@ -81,20 +82,13 @@ namespace SoLoud
int mRowTick;
MonotoneInstance(Monotone *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize);
virtual bool hasEnded();
};
class Monotone : public AudioSource
{
public:
enum MONOTONE_WAVEFORMS
{
SQUARE = 0,
SAW = 1,
SIN = 2,
SAWSIN = 3
};
int mNotesHz[800];
int mVibTable[32];
@ -103,9 +97,9 @@ namespace SoLoud
MonotoneSong mSong;
Monotone();
~Monotone();
result setParams(int aHardwareChannels, int aWaveform = SQUARE);
result setParams(int aHardwareChannels, int aWaveform = Soloud::WAVE_SQUARE);
result load(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
public:

@ -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

@ -41,7 +41,7 @@ namespace SoLoud
public:
OpenmptInstance(Openmpt *aParent);
virtual ~OpenmptInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
};
@ -53,7 +53,7 @@ namespace SoLoud
Openmpt();
virtual ~Openmpt();
result load(const char* aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
};

@ -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

@ -27,22 +27,12 @@ freely, subject to the following restrictions:
#define SFXR_H
#include "soloud.h"
#include "soloud_misc.h"
namespace SoLoud
{
class File;
class Prg
{
public:
// random generator
Prg();
unsigned int state[16];
unsigned int index;
unsigned int rand();
void srand(int aSeed);
};
struct SfxrParams
{
int wave_type;
@ -89,7 +79,7 @@ namespace SoLoud
{
Sfxr *mParent;
Prg mRand;
Misc::Prg mRand;
SfxrParams mParams;
bool playing_sample;
@ -132,7 +122,7 @@ namespace SoLoud
public:
SfxrInstance(Sfxr *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
};
@ -152,7 +142,7 @@ namespace SoLoud
BLIP
};
Prg mRand;
Misc::Prg mRand;
Sfxr();
virtual ~Sfxr();

@ -35,11 +35,27 @@ namespace SoLoud
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();
};
@ -54,7 +70,7 @@ namespace SoLoud
public:
SpeechInstance(Speech *aParent);
virtual ~SpeechInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual result rewind();
virtual bool hasEnded();
};

@ -40,15 +40,14 @@ namespace SoLoud
TedSid *mParent;
SIDsound *mSID;
TED *mTED;
int mPos;
unsigned int mSampleCount;
int mNextReg;
int mNextVal;
int mRegValues[128];
public:
TedSidInstance(TedSid *aParent);
~TedSidInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual void tick();
virtual bool hasEnded();
virtual float getInfo(unsigned int aInfoKey);
@ -57,15 +56,14 @@ namespace SoLoud
class TedSid : public AudioSource
{
public:
File *mFile;
int mLooppos;
int mLength;
unsigned short* mOps;
int mModel;
bool mFileOwned;
TedSid();
~TedSid();
result load(const char *aFilename);
result loadToMem(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFileToMem(File *aFile);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
};

@ -46,6 +46,7 @@ namespace SoLoud
void sleep(int aMSec);
void wait(ThreadHandle aThreadHandle);
void release(ThreadHandle aThreadHandle);
int getTimeMillis();
#define MAX_THREADPOOL_TASKS 1024

@ -55,10 +55,10 @@ namespace SoLoud
VicInstance(Vic *aParent);
~VicInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
private:
public:
Vic* m_parent;
unsigned int m_phase[4];
unsigned int m_noisePos;
@ -71,7 +71,7 @@ namespace SoLoud
enum
{
PAL = 0,
NTSC,
NTSC
};
// VIC sound registers
@ -85,19 +85,19 @@ namespace SoLoud
};
Vic();
virtual ~Vic();
void setModel(int model);
int getModel() const;
void setRegister(int reg, unsigned char value) { m_regs[reg] = value; }
unsigned char getRegister(int reg) const { return m_regs[reg]; }
void setRegister(int reg, unsigned char value);
virtual AudioSourceInstance *createInstance();
private:
friend class VicInstance;
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];

@ -0,0 +1,84 @@
/*
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);
VizsnResonator();
};
struct VizsnBank
{
VizsnResonator r[10];
float pitch;
float frica, voice, aspir, bypas, breth;
VizsnBank();
};
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

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
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
@ -33,6 +33,7 @@ namespace SoLoud
{
class Wav;
class File;
class MemoryFile;
class WavInstance : public AudioSourceInstance
{
@ -40,16 +41,18 @@ namespace SoLoud
unsigned int mOffset;
public:
WavInstance(Wav *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual result rewind();
virtual bool hasEnded();
};
class Wav : public AudioSource
{
result loadwav(File *aReader);
result loadogg(File *aReader);
result testAndLoadFile(File *aReader);
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;
@ -57,8 +60,11 @@ namespace SoLoud
Wav();
virtual ~Wav();
result load(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
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();

@ -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

@ -1,6 +1,6 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
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
@ -28,8 +28,16 @@ freely, subject to the following restrictions:
#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
{
@ -41,40 +49,55 @@ namespace SoLoud
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 void getAudio(float *aBuffer, unsigned int aSamples);
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 loadwav(File *fp);
result loadogg(File *fp);
result loadflac(File *fp);
result loadmp3(File *fp);
public:
int mOgg;
int mFiletype;
char *mFilename;
File *mMemFile;
File *mStreamFile;
unsigned int mDataOffset;
unsigned int mBits;
unsigned int mSampleCount;
WavStream();
virtual ~WavStream();
result load(const char *aFilename);
result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true);
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);
};

@ -0,0 +1,115 @@
/*
* zx7 decompress by Jari Komppa, under public domain / unlicense
*
* Heavily based on zx7 decompressor by Einar Saukas.
* Einar Saukas requests that you mention the use of dx7, but
* this is not enforced by any way.
*
* Note that compressor has a different license!
*/
#ifndef ZX7DECOMPRESS_H
#define ZX7DECOMPRESS_H
#ifdef __cplusplus
extern "C" {
#endif
struct zx7_io
{
unsigned char* input_data;
unsigned char* output_data;
size_t input_index;
size_t output_index;
int bit_mask;
int bit_value;
};
static int zx7_read_byte(struct zx7_io *io) {
return io->input_data[io->input_index++];
}
static int zx7_read_bit(struct zx7_io *io) {
io->bit_mask >>= 1;
if (io->bit_mask == 0) {
io->bit_mask = 128;
io->bit_value = zx7_read_byte(io);
}
return io->bit_value & io->bit_mask ? 1 : 0;
}
static int zx7_read_elias_gamma(struct zx7_io *io) {
int i = 0;
int value = 0;
while (!zx7_read_bit(io)) {
i++;
}
if (i > 15) {
return -1;
}
value = 1;
while (i--) {
value = value << 1 | zx7_read_bit(io);
}
return value;
}
static int zx7_read_offset(struct zx7_io *io) {
int value = 0;
int i = 0;
value = zx7_read_byte(io);
if (value < 128) {
return value;
} else {
i = zx7_read_bit(io);
i = i << 1 | zx7_read_bit(io);
i = i << 1 | zx7_read_bit(io);
i = i << 1 | zx7_read_bit(io);
return (value & 127 | i << 7) + 128;
}
}
static void zx7_write_byte(struct zx7_io *io, int value) {
io->output_data[io->output_index++] = value;
}
static void zx7_write_bytes(struct zx7_io *io, int offset, int length) {
int i;
while (length-- > 0) {
i = io->output_index - offset;
zx7_write_byte(io, io->output_data[i]);
}
}
static int zx7_decompress(unsigned char *input_data, unsigned char *output_data) {
struct zx7_io io;
int length;
io.input_data = input_data;
io.output_data = output_data;
io.input_index = 0;
io.output_index = 0;
io.bit_mask = 0;
io.bit_value = 0;
zx7_write_byte(&io, zx7_read_byte(&io));
while (1) {
if (!zx7_read_bit(&io)) {
zx7_write_byte(&io, zx7_read_byte(&io));
} else {
length = zx7_read_elias_gamma(&io) + 1;
if (length == 0) {
return io.input_index;
}
zx7_write_bytes(&io, zx7_read_offset(&io) + 1, length);
}
}
}
#ifdef __cplusplus
}
#endif
#endif // ZX7DECOMPRESS_H

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -10,7 +10,7 @@
struct Hashmap_Entry
{
char* key;
char key[MAX_HASH_KEY_LEN];
struct Variant value;
};
@ -32,12 +32,14 @@ static struct Hashmap_Entry* hashmap_entry_new(struct Hashmap* hashmap, const ch
if(strncmp(key, hashmap->buckets[index][i].key, MAX_HASH_KEY_LEN) == 0)
{
new_entry = &hashmap->buckets[index][i];
if(new_entry->key) memory_free(new_entry->key);
//if(new_entry->key) memory_free(new_entry->key);
memset(new_entry->key, '\0', MAX_HASH_KEY_LEN);
break;
}
}
if(!new_entry) new_entry = array_grow(hashmap->buckets[index], struct Hashmap_Entry);
new_entry->key = str_new(key);
//new_entry->key = str_new(key);
strncpy(new_entry->key, key, MAX_HASH_KEY_LEN);
new_entry->value.type = VT_NONE;
variant_free(&new_entry->value);
return new_entry;
@ -57,6 +59,7 @@ struct Hashmap* hashmap_create(void)
struct Hashmap* hashmap = memory_allocate(sizeof(*hashmap));
if(!hashmap)
return NULL;
for(int i = 0; i < HASH_MAP_NUM_BUCKETS; i++)
hashmap->buckets[i] = array_new(struct Hashmap_Entry);
hashmap->iter_bucket = 0;
@ -72,11 +75,12 @@ void hashmap_free(struct Hashmap* hashmap)
for(int j = 0; j < array_len(hashmap->buckets[i]); j++)
{
struct Hashmap_Entry* entry = &hashmap->buckets[i][j];
if(entry->key)
{
memory_free(entry->key);
entry->key = NULL;
}
//if(entry->key)
//{
// memory_free(entry->key);
// entry->key = NULL;
//}
memset(entry->key, '\0', MAX_HASH_KEY_LEN);
variant_free(&entry->value);
}
array_free(hashmap->buckets[i]);

@ -39,7 +39,7 @@
#define MAX_DEBUG_VARS_PER_FRAME_TEXTURES 8
#define HASH_MAP_NUM_BUCKETS 10
#define MAX_HASH_KEY_LEN 128
#define MAX_HASH_KEY_LEN 64
#define MAX_PLAYER_HEALTH 100

@ -23,7 +23,7 @@ void* memory_allocate(size_t size)
//memory->allocated += size;
memory.allocated += size + sizeof(*allocation);
}
return allocation->allocation;
return allocation ? allocation->allocation : NULL;
}
void* memory_reallocate_(void** ptr, size_t size)
@ -34,6 +34,7 @@ void* memory_reallocate_(void** ptr, size_t size)
}
struct Memory_Allocation* current_allocation = memory_get_allocation_ptr(*ptr);
int current_allocation_size = current_allocation->size;
void* reallocated_memory = realloc(current_allocation, sizeof(*current_allocation) + size);
if(!reallocated_memory)
{
@ -41,13 +42,13 @@ void* memory_reallocate_(void** ptr, size_t size)
}
else
{
memory.allocated += (size - current_allocation->size);
current_allocation->size = size;
memory.allocated += (size - current_allocation_size);
struct Memory_Allocation* new_allocation = (struct Memory_Allocation*)reallocated_memory;
new_allocation->size = size;
current_allocation = reallocated_memory;
}
return current_allocation->allocation;
}
void* memory_allocate_and_clear(size_t count, size_t size)
@ -63,7 +64,7 @@ void* memory_allocate_and_clear(size_t count, size_t size)
//memory->allocated += size;
memory.allocated += size + sizeof(*allocation);
}
return allocation->allocation;
return allocation ? allocation->allocation : NULL;
}
void memory_free(void* ptr)

@ -4,9 +4,7 @@
/* Auto generated version file. DO NOT MODIFY */
#define SYMMETRY_VERSION_MAJOR 0
#define SYMMETRY_VERSION_MINOR 2
#define SYMMETRY_VERSION_REVISION 368
#define SYMMETRY_VERSION_REVISION 371
#define SYMMETRY_VERSION_BRANCH "dev"
#endif
#endif

Loading…
Cancel
Save