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. 1068
      include/common/soloud/soloud.h
  3. 634
      include/common/soloud/soloud_audiosource.h
  4. 70
      include/common/soloud/soloud_ay.h
  5. 129
      include/common/soloud/soloud_bassboostfilter.h
  6. 183
      include/common/soloud/soloud_biquadresonantfilter.h
  7. 186
      include/common/soloud/soloud_bus.h
  8. 1251
      include/common/soloud/soloud_c.h
  9. 114
      include/common/soloud/soloud_dcremovalfilter.h
  10. 128
      include/common/soloud/soloud_echofilter.h
  11. 82
      include/common/soloud/soloud_eqfilter.h
  12. 80
      include/common/soloud/soloud_error.h
  13. 124
      include/common/soloud/soloud_fader.h
  14. 94
      include/common/soloud/soloud_fft.h
  15. 121
      include/common/soloud/soloud_fftfilter.h
  16. 8
      include/common/soloud/soloud_file.h
  17. 71
      include/common/soloud/soloud_file_hack_off.h
  18. 118
      include/common/soloud/soloud_file_hack_on.h
  19. 140
      include/common/soloud/soloud_filter.h
  20. 133
      include/common/soloud/soloud_flangerfilter.h
  21. 83
      include/common/soloud/soloud_freeverbfilter.h
  22. 279
      include/common/soloud/soloud_internal.h
  23. 153
      include/common/soloud/soloud_lofifilter.h
  24. 53
      include/common/soloud/soloud_misc.h
  25. 224
      include/common/soloud/soloud_monotone.h
  26. 74
      include/common/soloud/soloud_noise.h
  27. 122
      include/common/soloud/soloud_openmpt.h
  28. 72
      include/common/soloud/soloud_queue.h
  29. 72
      include/common/soloud/soloud_robotizefilter.h
  30. 326
      include/common/soloud/soloud_sfxr.h
  31. 142
      include/common/soloud/soloud_speech.h
  32. 144
      include/common/soloud/soloud_tedsid.h
  33. 165
      include/common/soloud/soloud_thread.h
  34. 216
      include/common/soloud/soloud_vic.h
  35. 84
      include/common/soloud/soloud_vizsn.h
  36. 142
      include/common/soloud/soloud_wav.h
  37. 63
      include/common/soloud/soloud_waveshaperfilter.h
  38. 187
      include/common/soloud/soloud_wavstream.h
  39. 115
      include/common/soloud/zx7decompress.h
  40. BIN
      lib/windows/soloud/soloud_x64.dll
  41. BIN
      lib/windows/soloud/soloud_x64.exp
  42. BIN
      lib/windows/soloud/soloud_x64.lib
  43. BIN
      lib/windows/soloud/soloud_x64_d.dll
  44. BIN
      lib/windows/soloud/soloud_x64_d.exp
  45. BIN
      lib/windows/soloud/soloud_x64_d.ilk
  46. BIN
      lib/windows/soloud/soloud_x64_d.lib
  47. BIN
      lib/windows/soloud/soloud_x64_d.pdb
  48. 22
      src/common/hashmap.c
  49. 2
      src/common/limits.h
  50. 11
      src/common/memory_utils.c
  51. 6
      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
}

File diff suppressed because it is too large Load Diff

@ -1,313 +1,321 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_AUDIOSOURCE_H
#define SOLOUD_AUDIOSOURCE_H
#include "soloud.h"
#include "soloud_fader.h"
#include "soloud_filter.h"
namespace SoLoud
{
class AudioSource;
class AudioSourceInstance;
class AudioSourceInstance3dData;
struct AudioSourceResampleData
{
AudioSourceResampleData();
~AudioSourceResampleData();
float *mBuffer;
};
class AudioCollider
{
public:
// Calculate volume multiplier. Assumed to return value between 0 and 1.
virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0;
};
class AudioAttenuator
{
public:
virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0;
};
class AudioSourceInstance3dData
{
public:
// ctor
AudioSourceInstance3dData();
// Set settings from audiosource
void init(AudioSource &aSource);
// 3d position
float m3dPosition[3];
// 3d velocity
float m3dVelocity[3];
// 3d cone direction
/*
float m3dConeDirection[3];
// 3d cone inner angle
float m3dConeInnerAngle;
// 3d cone outer angle
float m3dConeOuterAngle;
// 3d cone outer volume multiplier
float m3dConeOuterVolume;
*/
// 3d min distance
float m3dMinDistance;
// 3d max distance
float m3dMaxDistance;
// 3d attenuation rolloff factor
float m3dAttenuationRolloff;
// 3d attenuation model
unsigned int m3dAttenuationModel;
// 3d doppler factor
float m3dDopplerFactor;
// Pointer to a custom audio collider object
AudioCollider *mCollider;
// Pointer to a custom audio attenuator object
AudioAttenuator *mAttenuator;
// User data related to audio collider
int mColliderData;
// Doppler sample rate multiplier
float mDopplerValue;
// Overall 3d volume
float m3dVolume;
// Channel volume
float mChannelVolume[MAX_CHANNELS];
// Copy of flags
unsigned int mFlags;
// Latest handle for this voice
handle mHandle;
};
// Base class for audio instances
class AudioSourceInstance
{
public:
enum FLAGS
{
// This audio instance loops (if supported)
LOOPING = 1,
// This audio instance is protected - won't get stopped if we run out of voices
PROTECTED = 2,
// This audio instance is paused
PAUSED = 4,
// This audio instance is affected by 3d processing
PROCESS_3D = 8,
// This audio instance has listener-relative 3d coordinates
LISTENER_RELATIVE = 16,
// Currently inaudible
INAUDIBLE = 32,
// If inaudible, should be killed (default = don't kill kill)
INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128
};
// Ctor
AudioSourceInstance();
// Dtor
virtual ~AudioSourceInstance();
// Play index; used to identify instances from handles
unsigned int mPlayIndex;
// Loop count
unsigned int mLoopCount;
// Flags; see AudioSourceInstance::FLAGS
unsigned int mFlags;
// Pan value, for getPan()
float mPan;
// Volume for each channel (panning)
float mChannelVolume[MAX_CHANNELS];
// Set volume
float mSetVolume;
// Overall volume overall = set * 3d
float mOverallVolume;
// Base samplerate; samplerate = base samplerate * relative play speed
float mBaseSamplerate;
// Samplerate; samplerate = base samplerate * relative play speed
float mSamplerate;
// Number of channels this audio source produces
unsigned int mChannels;
// Relative play speed; samplerate = base samplerate * relative play speed
float mSetRelativePlaySpeed;
// Overall relative plays peed; overall = set * 3d
float mOverallRelativePlaySpeed;
// How long this stream has played, in seconds.
time mStreamTime;
// Fader for the audio panning
Fader mPanFader;
// Fader for the audio volume
Fader mVolumeFader;
// Fader for the relative play speed
Fader mRelativePlaySpeedFader;
// Fader used to schedule pausing of the stream
Fader mPauseScheduler;
// Fader used to schedule stopping of the stream
Fader mStopScheduler;
// Affected by some fader
int mActiveFader;
// Current channel volumes, used to ramp the volume changes to avoid clicks
float mCurrentChannelVolume[MAX_CHANNELS];
// ID of the sound source that generated this instance
unsigned int mAudioSourceID;
// Handle of the bus this audio instance is playing on. 0 for root.
unsigned int mBusHandle;
// Filter pointer
FilterInstance *mFilter[FILTERS_PER_STREAM];
// Initialize instance. Mostly internal use.
void init(AudioSource &aSource, int aPlayIndex);
// Buffers for the resampler
AudioSourceResampleData *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;
// Get N samples from the stream to the buffer
virtual void getAudio(float *aBuffer, unsigned int aSamples) = 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);
// Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind.
virtual result rewind();
// Get information. Returns 0 by default.
virtual float getInfo(unsigned int aInfoKey);
};
class Soloud;
// Base class for audio sources
class AudioSource
{
public:
enum FLAGS
{
// The instances from this audio source should loop
SHOULD_LOOP = 1,
// Only one instance of this audio source should play at the same time
SINGLE_INSTANCE = 2,
// Visualization data gathering enabled. Only for busses.
VISUALIZATION_DATA = 4,
// Audio instances created from this source are affected by 3d processing
PROCESS_3D = 8,
// Audio instances created from this source have listener-relative 3d coordinates
LISTENER_RELATIVE = 16,
// Delay start of sound by the distance from listener
DISTANCE_DELAY = 32,
// If inaudible, should be killed (default)
INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128
};
enum ATTENUATION_MODELS
{
// No attenuation
NO_ATTENUATION = 0,
// Inverse distance attenuation model
INVERSE_DISTANCE = 1,
// Linear distance attenuation model
LINEAR_DISTANCE = 2,
// Exponential distance attenuation model
EXPONENTIAL_DISTANCE = 3
};
// Flags. See AudioSource::FLAGS
unsigned int mFlags;
// Base sample rate, used to initialize instances
float mBaseSamplerate;
// Default volume for created instances
float mVolume;
// Number of channels this audio source produces
unsigned int mChannels;
// Sound source ID. Assigned by SoLoud the first time it's played.
unsigned int mAudioSourceID;
// 3d min distance
float m3dMinDistance;
// 3d max distance
float m3dMaxDistance;
// 3d attenuation rolloff factor
float m3dAttenuationRolloff;
// 3d attenuation model
unsigned int m3dAttenuationModel;
// 3d doppler factor
float m3dDopplerFactor;
// Filter pointer
Filter *mFilter[FILTERS_PER_STREAM];
// Pointer to the Soloud object. Needed to stop all instances in dtor.
Soloud *mSoloud;
// Pointer to a custom audio collider object
AudioCollider *mCollider;
// Pointer to custom attenuator object
AudioAttenuator *mAttenuator;
// User data related to audio collider
int mColliderData;
// CTor
AudioSource();
// Set default volume for instances
void setVolume(float aVolume);
// Set the looping of the instances created from this audio source
void setLooping(bool aLoop);
// Set whether only one instance of this sound should ever be playing at the same time
void setSingleInstance(bool aSingleInstance);
// Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol)
void set3dMinMaxDistance(float aMinDistance, float aMaxDistance);
// Set attenuation model and rolloff factor for 3d audio source
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
// Set doppler factor to reduce or enhance doppler effect, default = 1.0
void set3dDopplerFactor(float aDopplerFactor);
// 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.
void set3dDistanceDelay(bool aDistanceDelay);
// Set a custom 3d audio collider. Set to NULL to disable.
void set3dCollider(AudioCollider *aCollider, int aUserData = 0);
// Set a custom attenuator. Set to NULL to disable.
void set3dAttenuator(AudioAttenuator *aAttenuator);
// Set behavior for inaudible sounds
void setInaudibleBehavior(bool aMustTick, bool aKill);
// Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// DTor
virtual ~AudioSource();
// Create instance from the audio source. Called from within Soloud class.
virtual AudioSourceInstance *createInstance() = 0;
// Stop all instances of this audio source
void stop();
};
};
#endif
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_AUDIOSOURCE_H
#define SOLOUD_AUDIOSOURCE_H
#include "soloud.h"
#include "soloud_fader.h"
#include "soloud_filter.h"
namespace SoLoud
{
class AudioSource;
class AudioSourceInstance;
class AudioSourceInstance3dData;
class AudioCollider
{
public:
// Calculate volume multiplier. Assumed to return value between 0 and 1.
virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0;
};
class AudioAttenuator
{
public:
virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0;
};
class AudioSourceInstance3dData
{
public:
// ctor
AudioSourceInstance3dData();
// Set settings from audiosource
void init(AudioSource &aSource);
// 3d position
float m3dPosition[3];
// 3d velocity
float m3dVelocity[3];
// 3d cone direction
/*
float m3dConeDirection[3];
// 3d cone inner angle
float m3dConeInnerAngle;
// 3d cone outer angle
float m3dConeOuterAngle;
// 3d cone outer volume multiplier
float m3dConeOuterVolume;
*/
// 3d min distance
float m3dMinDistance;
// 3d max distance
float m3dMaxDistance;
// 3d attenuation rolloff factor
float m3dAttenuationRolloff;
// 3d attenuation model
unsigned int m3dAttenuationModel;
// 3d doppler factor
float m3dDopplerFactor;
// Pointer to a custom audio collider object
AudioCollider *mCollider;
// Pointer to a custom audio attenuator object
AudioAttenuator *mAttenuator;
// User data related to audio collider
int mColliderData;
// Doppler sample rate multiplier
float mDopplerValue;
// Overall 3d volume
float m3dVolume;
// Channel volume
float mChannelVolume[MAX_CHANNELS];
// Copy of flags
unsigned int mFlags;
// Latest handle for this voice
handle mHandle;
};
// Base class for audio instances
class AudioSourceInstance
{
public:
enum FLAGS
{
// This audio instance loops (if supported)
LOOPING = 1,
// This audio instance is protected - won't get stopped if we run out of voices
PROTECTED = 2,
// This audio instance is paused
PAUSED = 4,
// This audio instance is affected by 3d processing
PROCESS_3D = 8,
// This audio instance has listener-relative 3d coordinates
LISTENER_RELATIVE = 16,
// Currently inaudible
INAUDIBLE = 32,
// If inaudible, should be killed (default = don't kill kill)
INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128,
// Don't auto-stop sound
DISABLE_AUTOSTOP = 256
};
// Ctor
AudioSourceInstance();
// Dtor
virtual ~AudioSourceInstance();
// Play index; used to identify instances from handles
unsigned int mPlayIndex;
// Loop count
unsigned int mLoopCount;
// Flags; see AudioSourceInstance::FLAGS
unsigned int mFlags;
// Pan value, for getPan()
float mPan;
// Volume for each channel (panning)
float mChannelVolume[MAX_CHANNELS];
// Set volume
float mSetVolume;
// Overall volume overall = set * 3d
float mOverallVolume;
// Base samplerate; samplerate = base samplerate * relative play speed
float mBaseSamplerate;
// Samplerate; samplerate = base samplerate * relative play speed
float mSamplerate;
// Number of channels this audio source produces
unsigned int mChannels;
// Relative play speed; samplerate = base samplerate * relative play speed
float mSetRelativePlaySpeed;
// Overall relative plays peed; overall = set * 3d
float mOverallRelativePlaySpeed;
// How long this stream has played, in seconds.
time mStreamTime;
// Position of this stream, in seconds.
time mStreamPosition;
// Fader for the audio panning
Fader mPanFader;
// Fader for the audio volume
Fader mVolumeFader;
// Fader for the relative play speed
Fader mRelativePlaySpeedFader;
// Fader used to schedule pausing of the stream
Fader mPauseScheduler;
// Fader used to schedule stopping of the stream
Fader mStopScheduler;
// Affected by some fader
int mActiveFader;
// Current channel volumes, used to ramp the volume changes to avoid clicks
float mCurrentChannelVolume[MAX_CHANNELS];
// ID of the sound source that generated this instance
unsigned int mAudioSourceID;
// Handle of the bus this audio instance is playing on. 0 for root.
unsigned int mBusHandle;
// Filter pointer
FilterInstance *mFilter[FILTERS_PER_STREAM];
// Initialize instance. Mostly internal use.
void init(AudioSource &aSource, int aPlayIndex);
// 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. Report samples written.
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize) = 0;
// Has the stream ended?
virtual bool hasEnded() = 0;
// Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow).
virtual result seek(time aSeconds, float *mScratch, unsigned int mScratchSize);
// Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind.
virtual result rewind();
// Get information. Returns 0 by default.
virtual float getInfo(unsigned int aInfoKey);
};
class Soloud;
// Base class for audio sources
class AudioSource
{
public:
enum FLAGS
{
// The instances from this audio source should loop
SHOULD_LOOP = 1,
// Only one instance of this audio source should play at the same time
SINGLE_INSTANCE = 2,
// Visualization data gathering enabled. Only for busses.
VISUALIZATION_DATA = 4,
// Audio instances created from this source are affected by 3d processing
PROCESS_3D = 8,
// Audio instances created from this source have listener-relative 3d coordinates
LISTENER_RELATIVE = 16,
// Delay start of sound by the distance from listener
DISTANCE_DELAY = 32,
// If inaudible, should be killed (default)
INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128,
// Disable auto-stop
DISABLE_AUTOSTOP = 256
};
enum ATTENUATION_MODELS
{
// No attenuation
NO_ATTENUATION = 0,
// Inverse distance attenuation model
INVERSE_DISTANCE = 1,
// Linear distance attenuation model
LINEAR_DISTANCE = 2,
// Exponential distance attenuation model
EXPONENTIAL_DISTANCE = 3
};
// Flags. See AudioSource::FLAGS
unsigned int mFlags;
// Base sample rate, used to initialize instances
float mBaseSamplerate;
// Default volume for created instances
float mVolume;
// Number of channels this audio source produces
unsigned int mChannels;
// Sound source ID. Assigned by SoLoud the first time it's played.
unsigned int mAudioSourceID;
// 3d min distance
float m3dMinDistance;
// 3d max distance
float m3dMaxDistance;
// 3d attenuation rolloff factor
float m3dAttenuationRolloff;
// 3d attenuation model
unsigned int m3dAttenuationModel;
// 3d doppler factor
float m3dDopplerFactor;
// Filter pointer
Filter *mFilter[FILTERS_PER_STREAM];
// Pointer to the Soloud object. Needed to stop all instances in dtor.
Soloud *mSoloud;
// Pointer to a custom audio collider object
AudioCollider *mCollider;
// Pointer to custom attenuator object
AudioAttenuator *mAttenuator;
// User data related to audio collider
int mColliderData;
// When looping, start playing from this time
time mLoopPoint;
// CTor
AudioSource();
// Set default volume for instances
void setVolume(float aVolume);
// Set the looping of the instances created from this audio source
void setLooping(bool aLoop);
// Set whether only one instance of this sound should ever be playing at the same time
void setSingleInstance(bool aSingleInstance);
// Set 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);
// Set attenuation model and rolloff factor for 3d audio source
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
// Set doppler factor to reduce or enhance doppler effect, default = 1.0
void set3dDopplerFactor(float aDopplerFactor);
// Set the coordinates for this audio source to be relative to listener's coordinates.
void set3dListenerRelative(bool aListenerRelative);
// Enable delaying the start of the sound based on the distance.
void set3dDistanceDelay(bool aDistanceDelay);
// Set a custom 3d audio collider. Set to NULL to disable.
void set3dCollider(AudioCollider *aCollider, int aUserData = 0);
// Set a custom attenuator. Set to NULL to disable.
void set3dAttenuator(AudioAttenuator *aAttenuator);
// Set behavior for inaudible sounds
void setInaudibleBehavior(bool aMustTick, bool aKill);
// Set time to jump to when looping
void setLoopPoint(time aLoopPoint);
// Get current loop point value
time getLoopPoint();
// Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// DTor
virtual ~AudioSource();
// Create instance from the audio source. Called from within Soloud class.
virtual AudioSourceInstance *createInstance() = 0;
// Stop all instances of this audio source
void stop();
};
};
#endif

@ -0,0 +1,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

@ -1,63 +1,68 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BASSBOOSTFILTER_H
#define SOLOUD_BASSBOOSTFILTER_H
#include "soloud.h"
#include "soloud_fftfilter.h"
namespace SoLoud
{
class BassboostFilter;
class BassboostFilterInstance : public FFTFilterInstance
{
enum FILTERATTRIBUTE
{
WET = 0,
BOOST = 1
};
BassboostFilter *mParent;
public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
BassboostFilterInstance(BassboostFilter *aParent);
};
class BassboostFilter : public FFTFilter
{
public:
enum FILTERATTRIBUTE
{
WET = 0,
BOOST = 1
};
float mBoost;
result setParams(float aBoost);
virtual FilterInstance *createInstance();
BassboostFilter();
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BASSBOOSTFILTER_H
#define SOLOUD_BASSBOOSTFILTER_H
#include "soloud.h"
#include "soloud_fftfilter.h"
namespace SoLoud
{
class BassboostFilter;
class BassboostFilterInstance : public FFTFilterInstance
{
enum FILTERATTRIBUTE
{
WET = 0,
BOOST = 1
};
BassboostFilter *mParent;
public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
BassboostFilterInstance(BassboostFilter *aParent);
};
class BassboostFilter : public FFTFilter
{
public:
enum FILTERATTRIBUTE
{
WET = 0,
BOOST = 1
};
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
float mBoost;
result setParams(float aBoost);
virtual FilterInstance *createInstance();
BassboostFilter();
};
}
#endif

@ -1,91 +1,94 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BQRFILTER_H
#define SOLOUD_BQRFILTER_H
#include "soloud.h"
namespace SoLoud
{
class BiquadResonantFilter;
struct BQRStateData
{
float mY1, mY2, mX1, mX2;
};
class BiquadResonantFilterInstance : public FilterInstance
{
enum FILTERATTRIBUTE
{
WET = 0,
SAMPLERATE = 1,
FREQUENCY = 2,
RESONANCE = 3
};
int mActive;
BQRStateData mState[2];
float mA0, mA1, mA2, mB1, mB2;
int mDirty;
int mFilterType;
BiquadResonantFilter *mParent;
void calcBQRParams();
public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~BiquadResonantFilterInstance();
BiquadResonantFilterInstance(BiquadResonantFilter *aParent);
};
class BiquadResonantFilter : public Filter
{
public:
enum FILTERTYPE
{
NONE = 0,
LOWPASS = 1,
HIGHPASS = 2,
BANDPASS = 3
};
enum FILTERATTRIBUTE
{
WET = 0,
SAMPLERATE = 1,
FREQUENCY = 2,
RESONANCE = 3
};
int mFilterType;
float mSampleRate;
float mFrequency;
float mResonance;
virtual BiquadResonantFilterInstance *createInstance();
BiquadResonantFilter();
result setParams(int aType, float aSampleRate, float aFrequency, float aResonance);
virtual ~BiquadResonantFilter();
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BQRFILTER_H
#define SOLOUD_BQRFILTER_H
#include "soloud.h"
namespace SoLoud
{
class BiquadResonantFilter;
struct BQRStateData
{
float mY1, mY2, mX1, mX2;
};
class BiquadResonantFilterInstance : public FilterInstance
{
enum FILTERATTRIBUTE
{
WET = 0,
TYPE,
FREQUENCY,
RESONANCE
};
BQRStateData mState[8];
float mA0, mA1, mA2, mB1, mB2;
int mDirty;
float mSamplerate;
BiquadResonantFilter *mParent;
void calcBQRParams();
public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~BiquadResonantFilterInstance();
BiquadResonantFilterInstance(BiquadResonantFilter *aParent);
};
class BiquadResonantFilter : public Filter
{
public:
enum FILTERTYPE
{
LOWPASS = 0,
HIGHPASS = 1,
BANDPASS = 2
};
enum FILTERATTRIBUTE
{
WET = 0,
TYPE,
FREQUENCY,
RESONANCE
};
int mFilterType;
float mFrequency;
float mResonance;
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
virtual BiquadResonantFilterInstance *createInstance();
BiquadResonantFilter();
result setParams(int aType, float aFrequency, float aResonance);
virtual ~BiquadResonantFilter();
};
}
#endif

@ -1,86 +1,102 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BUS_H
#define SOLOUD_BUS_H
#include "soloud.h"
namespace SoLoud
{
class Bus;
class BusInstance : public AudioSourceInstance
{
Bus *mParent;
unsigned int mScratchSize;
AlignedFloatBuffer mScratch;
public:
// 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 bool hasEnded();
virtual ~BusInstance();
};
class Bus : public AudioSource
{
public:
Bus();
virtual BusInstance *createInstance();
// Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// Play sound through the bus
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0);
// Play sound through the bus, delayed in relation to other sounds called via this function.
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f);
// Start playing a 3d audio source through the bus
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0);
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f);
// Set number of channels for the bus (default 2)
result setChannels(unsigned int aChannels);
// Enable or disable visualization data gathering
void setVisualizationEnable(bool aEnable);
// 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();
public:
BusInstance *mInstance;
unsigned int mChannelHandle;
// FFT output data
float mFFTData[256];
// Snapshot of wave data for visualization
float mWaveData[256];
// Internal: find the bus' channel
void findBusHandle();
};
};
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BUS_H
#define SOLOUD_BUS_H
#include "soloud.h"
namespace SoLoud
{
class Bus;
class BusInstance : public AudioSourceInstance
{
Bus *mParent;
unsigned int mScratchSize;
AlignedFloatBuffer mScratch;
public:
// Approximate volume for channels.
float mVisualizationChannelVolume[MAX_CHANNELS];
// Mono-mixed wave data for visualization and for visualization FFT input
float mVisualizationWaveData[256];
BusInstance(Bus *aParent);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
virtual ~BusInstance();
};
class Bus : public AudioSource
{
public:
Bus();
virtual BusInstance *createInstance();
// Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// Play sound through the bus
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0);
// Play sound through the bus, delayed in relation to other sounds called via this function.
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f);
// Start playing a 3d audio source through the bus
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0);
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f);
// Set number of channels for the bus (default 2)
result setChannels(unsigned int aChannels);
// Enable or disable visualization data gathering
void setVisualizationEnable(bool aEnable);
// Move a live sound to this bus
void annexSound(handle aVoiceHandle);
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
float *calcFFT();
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
float *getWave();
// Get approximate volume for output channel for visualization. Visualization has to be enabled before use.
float getApproximateVolume(unsigned int aChannel);
// Get number of immediate child voices to this bus
unsigned int getActiveVoiceCount();
// 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
float mWaveData[256];
// Internal: find the bus' channel
void findBusHandle();
};
};
#endif

File diff suppressed because it is too large Load Diff

@ -1,58 +1,58 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_DCREMOVAL_H
#define SOLOUD_DCREMOVAL_H
#include "soloud.h"
namespace SoLoud
{
class DCRemovalFilter;
class DCRemovalFilterInstance : public FilterInstance
{
float *mBuffer;
float *mTotals;
int mBufferLength;
DCRemovalFilter *mParent;
int mOffset;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~DCRemovalFilterInstance();
DCRemovalFilterInstance(DCRemovalFilter *aParent);
};
class DCRemovalFilter : public Filter
{
public:
float mLength;
virtual FilterInstance *createInstance();
DCRemovalFilter();
result setParams(float aLength = 0.1f);
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_DCREMOVAL_H
#define SOLOUD_DCREMOVAL_H
#include "soloud.h"
namespace SoLoud
{
class DCRemovalFilter;
class DCRemovalFilterInstance : public FilterInstance
{
float *mBuffer;
float *mTotals;
int mBufferLength;
DCRemovalFilter *mParent;
int mOffset;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~DCRemovalFilterInstance();
DCRemovalFilterInstance(DCRemovalFilter *aParent);
};
class DCRemovalFilter : public Filter
{
public:
float mLength;
virtual FilterInstance *createInstance();
DCRemovalFilter();
result setParams(float aLength = 0.1f);
};
}
#endif

@ -1,59 +1,71 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_ECHOFILTER_H
#define SOLOUD_ECHOFILTER_H
#include "soloud.h"
namespace SoLoud
{
class EchoFilter;
class EchoFilterInstance : public FilterInstance
{
float *mBuffer;
int mBufferLength;
EchoFilter *mParent;
int mOffset;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~EchoFilterInstance();
EchoFilterInstance(EchoFilter *aParent);
};
class EchoFilter : public Filter
{
public:
float mDelay;
float mDecay;
float mFilter;
virtual FilterInstance *createInstance();
EchoFilter();
result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f);
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_ECHOFILTER_H
#define SOLOUD_ECHOFILTER_H
#include "soloud.h"
namespace SoLoud
{
class EchoFilter;
class EchoFilterInstance : public FilterInstance
{
float *mBuffer;
int mBufferLength;
int mBufferMaxLength;
int mOffset;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~EchoFilterInstance();
EchoFilterInstance(EchoFilter *aParent);
};
class EchoFilter : public Filter
{
public:
enum FILTERATTRIBUTE
{
WET = 0,
DELAY,
DECAY,
FILTER
};
float mDelay;
float mDecay;
float mFilter;
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
virtual FilterInstance *createInstance();
EchoFilter();
result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f);
};
}
#endif

@ -0,0 +1,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

@ -1,41 +1,41 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_ERROR_H
#define SOLOUD_ERROR_H
namespace SoLoud
{
enum SOLOUD_ERRORS
{
SO_NO_ERROR = 0, // No error
INVALID_PARAMETER = 1, // Some parameter is invalid
FILE_NOT_FOUND = 2, // File not found
FILE_LOAD_FAILED = 3, // File found, but could not be loaded
DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL
OUT_OF_MEMORY = 5, // Out of memory
NOT_IMPLEMENTED = 6, // Feature not implemented
UNKNOWN_ERROR = 7 // Other error
};
};
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_ERROR_H
#define SOLOUD_ERROR_H
namespace SoLoud
{
enum SOLOUD_ERRORS
{
SO_NO_ERROR = 0, // No error
INVALID_PARAMETER = 1, // Some parameter is invalid
FILE_NOT_FOUND = 2, // File not found
FILE_LOAD_FAILED = 3, // File found, but could not be loaded
DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL
OUT_OF_MEMORY = 5, // Out of memory
NOT_IMPLEMENTED = 6, // Feature not implemented
UNKNOWN_ERROR = 7 // Other error
};
};
#endif

@ -1,63 +1,63 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FADER_H
#define SOLOUD_FADER_H
#include "soloud.h"
namespace SoLoud
{
// Helper class to process faders
class Fader
{
public:
// Value to fade from
float mFrom;
// Value to fade to
float mTo;
// Delta between from and to
float mDelta;
// Total time to fade
time mTime;
// Time fading started
time mStartTime;
// Time fading will end
time mEndTime;
// Current value. Used in case time rolls over.
float mCurrent;
// Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped
int mActive;
// Ctor
Fader();
// Set up LFO
void setLFO(float aFrom, float aTo, time aTime, time aStartTime);
// Set up fader
void set(float aFrom, float aTo, time aTime, time aStartTime);
// Get the current fading value
float get(time aCurrentTime);
};
};
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FADER_H
#define SOLOUD_FADER_H
#include "soloud.h"
namespace SoLoud
{
// Helper class to process faders
class Fader
{
public:
// Value to fade from
float mFrom;
// Value to fade to
float mTo;
// Delta between from and to
float mDelta;
// Total time to fade
time mTime;
// Time fading started
time mStartTime;
// Time fading will end
time mEndTime;
// Current value. Used in case time rolls over.
float mCurrent;
// Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped
int mActive;
// Ctor
Fader();
// Set up LFO
void setLFO(float aFrom, float aTo, time aTime, time aStartTime);
// Set up fader
void set(float aFrom, float aTo, time aTime, time aStartTime);
// Get the current fading value
float get(time aCurrentTime);
};
};
#endif

@ -1,45 +1,51 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FFT_H
#define SOLOUD_FFT_H
#include "soloud.h"
namespace SoLoud
{
namespace FFT
{
// Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten
void fft1024(float *aBuffer);
// Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten
void fft256(float *aBuffer);
// Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten
void ifft256(float *aBuffer);
};
};
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FFT_H
#define SOLOUD_FFT_H
#include "soloud.h"
namespace SoLoud
{
namespace FFT
{
// Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten
void fft1024(float *aBuffer);
// Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten
void fft256(float *aBuffer);
// Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten
void ifft256(float *aBuffer);
// Generic (slower) power of two FFT. Buffer is overwritten.
void fft(float *aBuffer, unsigned int aBufferLength);
// Generic (slower) power of two IFFT. Buffer is overwritten.
void ifft(float *aBuffer, unsigned int aBufferLength);
};
};
#endif

@ -1,57 +1,66 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FFTFILTER_H
#define SOLOUD_FFTFILTER_H
#include "soloud.h"
namespace SoLoud
{
class FFTFilter;
class FFTFilterInstance : public FilterInstance
{
float *mTemp;
float *mInputBuffer;
float *mMixBuffer;
unsigned int mOffset[MAX_CHANNELS];
FFTFilter *mParent;
public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~FFTFilterInstance();
FFTFilterInstance(FFTFilter *aParent);
FFTFilterInstance();
};
class FFTFilter : public Filter
{
public:
virtual FilterInstance *createInstance();
FFTFilter();
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FFTFILTER_H
#define SOLOUD_FFTFILTER_H
#include "soloud.h"
namespace SoLoud
{
class FFTFilter;
class FFTFilterInstance : public FilterInstance
{
float *mTemp;
float *mInputBuffer;
float *mMixBuffer;
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);
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
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
{
public:
virtual FilterInstance *createInstance();
FFTFilter();
};
}
#endif

@ -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,35 +1,36 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/*
See soloud_file_hack_on.h
*/
#undef FILE
#undef fgetc
#undef fread
#undef fseek
#undef ftell
#undef fclose
#undef fopen
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/*
See soloud_file_hack_on.h
*/
#undef FILE
#undef fgetc
#undef fread
#undef fseek
#undef ftell
#undef fclose
#undef fopen
#undef fopen_s

@ -1,58 +1,60 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/*
This is a "hack" header to fool third party code to use our File stuff instead
of stdio FILE* stuff.
You can use soloud_file_hack_off.h to undef the stuff defined here.
*/
#ifndef SEEK_SET
#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio.
#endif
typedef void* Soloud_Filehack;
#ifdef __cplusplus
extern "C" {
#endif
extern int Soloud_Filehack_fgetc(Soloud_Filehack *f);
extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f);
extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base);
extern int Soloud_Filehack_ftell(Soloud_Filehack *f);
extern int Soloud_Filehack_fclose(Soloud_Filehack *f);
extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode);
#ifdef __cplusplus
}
#endif
#define FILE Soloud_Filehack
#define fgetc Soloud_Filehack_fgetc
#define fread Soloud_Filehack_fread
#define fseek Soloud_Filehack_fseek
#define ftell Soloud_Filehack_ftell
#define fclose Soloud_Filehack_fclose
#define fopen Soloud_Filehack_fopen
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/*
This is a "hack" header to fool third party code to use our File stuff instead
of stdio FILE* stuff.
You can use soloud_file_hack_off.h to undef the stuff defined here.
*/
#ifndef SEEK_SET
#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio.
#endif
typedef void* Soloud_Filehack;
#ifdef __cplusplus
extern "C" {
#endif
extern int Soloud_Filehack_fgetc(Soloud_Filehack *f);
extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f);
extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base);
extern int Soloud_Filehack_ftell(Soloud_Filehack *f);
extern int Soloud_Filehack_fclose(Soloud_Filehack *f);
extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode);
extern int Soloud_Filehack_fopen_s(Soloud_Filehack **f, const char* aFilename, char* aMode);
#ifdef __cplusplus
}
#endif
#define FILE Soloud_Filehack
#define fgetc Soloud_Filehack_fgetc
#define fread Soloud_Filehack_fread
#define fseek Soloud_Filehack_fseek
#define ftell Soloud_Filehack_ftell
#define fclose Soloud_Filehack_fclose
#define fopen Soloud_Filehack_fopen
#define fopen_s Soloud_Filehack_fopen_s

@ -1,64 +1,76 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FILTER_H
#define SOLOUD_FILTER_H
#include "soloud.h"
namespace SoLoud
{
class Fader;
class FilterInstance
{
public:
unsigned int mNumParams;
unsigned int mParamChanged;
float *mParam;
Fader *mParamFader;
FilterInstance();
virtual result initParams(int aNumParams);
virtual void updateParams(time aTime);
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual float getFilterParameter(unsigned int aAttributeId);
virtual void setFilterParameter(unsigned int aAttributeId, float aValue);
virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime);
virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime);
virtual ~FilterInstance();
};
class Filter
{
public:
Filter();
virtual FilterInstance *createInstance() = 0;
virtual ~Filter();
};
};
#endif
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FILTER_H
#define SOLOUD_FILTER_H
#include "soloud.h"
namespace SoLoud
{
class Fader;
class FilterInstance
{
public:
unsigned int mNumParams;
unsigned int mParamChanged;
float *mParam;
Fader *mParamFader;
FilterInstance();
virtual result initParams(int aNumParams);
virtual void updateParams(time aTime);
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int 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);
virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime);
virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime);
virtual ~FilterInstance();
};
class Filter
{
public:
enum PARAMTYPE
{
FLOAT_PARAM = 0,
INT_PARAM,
BOOL_PARAM
};
Filter();
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
virtual FilterInstance *createInstance() = 0;
virtual ~Filter();
};
};
#endif

@ -1,65 +1,70 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FLANGERFILTER_H
#define SOLOUD_FLANGERFILTER_H
#include "soloud.h"
namespace SoLoud
{
class FlangerFilter;
class FlangerFilterInstance : public FilterInstance
{
float *mBuffer;
int mBufferLength;
FlangerFilter *mParent;
int mOffset;
double mIndex;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~FlangerFilterInstance();
FlangerFilterInstance(FlangerFilter *aParent);
};
class FlangerFilter : public Filter
{
public:
enum FILTERPARAMS
{
WET,
DELAY,
FREQ
};
float mDelay;
float mFreq;
virtual FilterInstance *createInstance();
FlangerFilter();
result setParams(float aDelay, float aFreq);
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FLANGERFILTER_H
#define SOLOUD_FLANGERFILTER_H
#include "soloud.h"
namespace SoLoud
{
class FlangerFilter;
class FlangerFilterInstance : public FilterInstance
{
float *mBuffer;
unsigned int mBufferLength;
FlangerFilter *mParent;
unsigned int mOffset;
double mIndex;
public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~FlangerFilterInstance();
FlangerFilterInstance(FlangerFilter *aParent);
};
class FlangerFilter : public Filter
{
public:
enum FILTERPARAMS
{
WET,
DELAY,
FREQ
};
float mDelay;
float mFreq;
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
virtual FilterInstance *createInstance();
FlangerFilter();
result setParams(float aDelay, float aFreq);
};
}
#endif

@ -0,0 +1,83 @@
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_FREEVERBFILTER_H
#define SOLOUD_FREEVERBFILTER_H
#include "soloud.h"
namespace SoLoud
{
class FreeverbFilter;
namespace FreeverbImpl
{
class Revmodel;
}
class FreeverbFilterInstance : public FilterInstance
{
enum FILTERPARAM {
WET = 0,
FREEZE,
ROOMSIZE,
DAMP,
WIDTH
};
FreeverbFilter *mParent;
FreeverbImpl::Revmodel *mModel;
public:
virtual void filter(float* aBuffer, unsigned int aSamples, unsigned int 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

@ -1,118 +1,161 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_INTERNAL_H
#define SOLOUD_INTERNAL_H
#include "soloud.h"
namespace SoLoud
{
// 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);
// 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 "non-dynamic" back-end initialization call
result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// OpenAL back-end initialization call
result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// Core Audio driver back-end initialization call
result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// OpenSL ES back-end initialization call
result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// PortAudio back-end initialization call
result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// WinMM back-end initialization call
result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2);
// XAudio2 back-end initialization call
result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// WASAPI back-end initialization call
result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2);
// OSS back-end initialization call
result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// PS Vita homebrew back-end initialization call
result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// ALSA back-end initialization call
result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// null driver back-end initialization call
result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// Deinterlace samples in a buffer. From 12121212 to 11112222
void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
// Interlace samples in a buffer. From 11112222 to 12121212
void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
// Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
};
#define FOR_ALL_VOICES_PRE \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
lockAudioMutex(); \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = getVoiceFromHandle(*h_); \
if (ch != -1) \
{
#define FOR_ALL_VOICES_POST \
} \
h_++; \
} \
unlockAudioMutex();
#define FOR_ALL_VOICES_PRE_3D \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = (*h_ & 0xfff) - 1; \
if (ch != -1 && m3dData[ch].mHandle == *h_) \
{
#define FOR_ALL_VOICES_POST_3D \
} \
h_++; \
}
#endif
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_INTERNAL_H
#define SOLOUD_INTERNAL_H
#include "soloud.h"
namespace SoLoud
{
// SDL1 back-end initialization call
result sdl1_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// SDL2 back-end initialization call
result sdl2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// SDL1 "non-dynamic" back-end initialization call
result sdl1static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// SDL2 "non-dynamic" back-end initialization call
result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// OpenAL back-end initialization call
result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// Core Audio driver back-end initialization call
result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// OpenSL ES back-end initialization call
result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// PortAudio back-end initialization call
result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// WinMM back-end initialization call
result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2);
// XAudio2 back-end initialization call
result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// WASAPI back-end initialization call
result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2);
// OSS back-end initialization call
result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// PS Vita homebrew back-end initialization call
result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// ALSA back-end initialization call
result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// JACK back-end initialization call
result jack_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// MiniAudio back-end initialization call
result miniaudio_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// nosound back-end initialization call
result nosound_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// null driver back-end initialization call
result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// Interlace samples in a buffer. From 11112222 to 12121212
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, unsigned int aStride);
};
#define FOR_ALL_VOICES_PRE \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
lockAudioMutex_internal(); \
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = getVoiceFromHandle_internal(*h_); \
if (ch != -1) \
{
#define FOR_ALL_VOICES_POST \
} \
h_++; \
} \
unlockAudioMutex_internal();
#define FOR_ALL_VOICES_PRE_3D \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = (*h_ & 0xfff) - 1; \
if (ch != -1 && m3dData[ch].mHandle == *h_) \
{
#define FOR_ALL_VOICES_POST_3D \
} \
h_++; \
}
#define FOR_ALL_VOICES_PRE_EXT \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
mSoloud->lockAudioMutex_internal(); \
h_ = mSoloud->voiceGroupHandleToArray_internal(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = mSoloud->getVoiceFromHandle_internal(*h_); \
if (ch != -1) \
{
#define FOR_ALL_VOICES_POST_EXT \
} \
h_++; \
} \
mSoloud->unlockAudioMutex_internal();
#define FOR_ALL_VOICES_PRE_3D_EXT \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
h_ = mSoloud->voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = (*h_ & 0xfff) - 1; \
if (ch != -1 && mSoloud->m3dData[ch].mHandle == *h_) \
{
#define FOR_ALL_VOICES_POST_3D_EXT \
} \
h_++; \
}
#endif

@ -1,75 +1,80 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_LOFIFILTER_H
#define SOLOUD_LOFIFILTER_H
#include "soloud.h"
namespace SoLoud
{
class LofiFilter;
struct LofiChannelData
{
float mSample;
float mSamplesToSkip;
};
class LofiFilterInstance : public FilterInstance
{
enum FILTERPARAMS
{
WET,
SAMPLERATE,
BITDEPTH
};
LofiChannelData mChannelData[2];
LofiFilter *mParent;
public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~LofiFilterInstance();
LofiFilterInstance(LofiFilter *aParent);
};
class LofiFilter : public Filter
{
public:
enum FILTERPARAMS
{
WET,
SAMPLERATE,
BITDEPTH
};
float mSampleRate;
float mBitdepth;
virtual LofiFilterInstance *createInstance();
LofiFilter();
result setParams(float aSampleRate, float aBitdepth);
virtual ~LofiFilter();
};
}
/*
SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_LOFIFILTER_H
#define SOLOUD_LOFIFILTER_H
#include "soloud.h"
namespace SoLoud
{
class LofiFilter;
struct LofiChannelData
{
float mSample;
float mSamplesToSkip;
};
class LofiFilterInstance : public FilterInstance
{
enum FILTERPARAMS
{
WET,
SAMPLERATE,
BITDEPTH
};
LofiChannelData mChannelData[2];
LofiFilter *mParent;
public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~LofiFilterInstance();
LofiFilterInstance(LofiFilter *aParent);
};
class LofiFilter : public Filter
{
public:
enum FILTERPARAMS
{
WET,
SAMPLERATE,
BITDEPTH
};
float mSampleRate;
float mBitdepth;
virtual LofiFilterInstance *createInstance();
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
LofiFilter();
result setParams(float aSampleRate, float aBitdepth);
virtual ~LofiFilter();
};
}
#endif

@ -0,0 +1,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,116 +1,110 @@
/*
MONOTONE module for SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef MONOTONE_H
#define MONOTONE_H
#include "soloud.h"
namespace SoLoud
{
class Monotone;
class File;
struct MonotoneSong
{
char *mTitle;
char *mComment;
unsigned char mVersion; // must be 1
unsigned char mTotalPatterns;
unsigned char mTotalTracks;
unsigned char mCellSize; // must be 2 for version 1
unsigned char mOrder[256];
unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks
};
struct MonotoneChannel
{
int mEnabled;
int mActive;
int mFreq[3];
int mPortamento;
int mArpCounter;
int mArp;
int mLastNote;
int mPortamentoToNote;
int mVibrato;
int mVibratoIndex;
int mVibratoDepth;
int mVibratoSpeed;
};
struct MonotoneHardwareChannel
{
int mEnabled;
float mSamplePos;
float mSamplePosInc;
};
class MonotoneInstance : public AudioSourceInstance
{
Monotone *mParent;
public:
MonotoneChannel mChannel[12];
MonotoneHardwareChannel mOutput[12];
int mNextChannel;
int mTempo; // ticks / row. Tick = 60hz. Default 4.
int mOrder;
int mRow;
int mSampleCount;
int mRowTick;
MonotoneInstance(Monotone *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
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];
int mHardwareChannels;
int mWaveform;
MonotoneSong mSong;
Monotone();
~Monotone();
result setParams(int aHardwareChannels, int aWaveform = SQUARE);
result load(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
public:
void clear();
};
};
/*
MONOTONE module for SoLoud audio engine
Copyright (c) 2013-2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef MONOTONE_H
#define MONOTONE_H
#include "soloud.h"
#include "soloud_misc.h"
namespace SoLoud
{
class Monotone;
class File;
struct MonotoneSong
{
char *mTitle;
char *mComment;
unsigned char mVersion; // must be 1
unsigned char mTotalPatterns;
unsigned char mTotalTracks;
unsigned char mCellSize; // must be 2 for version 1
unsigned char mOrder[256];
unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks
};
struct MonotoneChannel
{
int mEnabled;
int mActive;
int mFreq[3];
int mPortamento;
int mArpCounter;
int mArp;
int mLastNote;
int mPortamentoToNote;
int mVibrato;
int mVibratoIndex;
int mVibratoDepth;
int mVibratoSpeed;
};
struct MonotoneHardwareChannel
{
int mEnabled;
float mSamplePos;
float mSamplePosInc;
};
class MonotoneInstance : public AudioSourceInstance
{
Monotone *mParent;
public:
MonotoneChannel mChannel[12];
MonotoneHardwareChannel mOutput[12];
int mNextChannel;
int mTempo; // ticks / row. Tick = 60hz. Default 4.
int mOrder;
int mRow;
int mSampleCount;
int mRowTick;
MonotoneInstance(Monotone *aParent);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize);
virtual bool hasEnded();
};
class Monotone : public AudioSource
{
public:
int mNotesHz[800];
int mVibTable[32];
int mHardwareChannels;
int mWaveform;
MonotoneSong mSong;
Monotone();
~Monotone();
result setParams(int aHardwareChannels, int aWaveform = Soloud::WAVE_SQUARE);
result load(const char *aFilename);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
public:
void clear();
};
};
#endif

@ -0,0 +1,74 @@
/*
SoLoud audio engine
Copyright (c) 2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_NOISE_H
#define SOLOUD_NOISE_H
#include "soloud.h"
#include "soloud_misc.h"
namespace SoLoud
{
class Noise;
class NoiseInstance : public AudioSourceInstance
{
public:
NoiseInstance(Noise *aParent);
~NoiseInstance();
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
public:
float mOctaveScale[10];
Misc::Prg mPrg;
};
class Noise : public AudioSource
{
public:
enum NOISETYPES
{
WHITE = 0,
PINK,
BROWNISH,
BLUEISH
};
Noise();
void setOctaveScale(float aOct0, float aOct1, float aOct2, float aOct3, float aOct4, float aOct5, float aOct6, float aOct7, float aOct8, float aOct9);
void setType(int aType);
virtual ~Noise();
public:
virtual AudioSourceInstance *createInstance();
float mOctaveScale[10];
};
};
#endif

@ -1,62 +1,62 @@
/*
Openmpt module for SoLoud audio engine
Copyright (c) 2016 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef OPENMPT_H
#define OPENMPT_H
#include "soloud.h"
namespace SoLoud
{
class Openmpt;
class File;
class OpenmptInstance : public AudioSourceInstance
{
Openmpt *mParent;
void *mModfile;
int mPlaying;
public:
OpenmptInstance(Openmpt *aParent);
virtual ~OpenmptInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded();
};
class Openmpt : public AudioSource
{
public:
char *mData;
unsigned int mDataLen;
Openmpt();
virtual ~Openmpt();
result load(const char* aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
};
};
/*
Openmpt module for SoLoud audio engine
Copyright (c) 2016 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef OPENMPT_H
#define OPENMPT_H
#include "soloud.h"
namespace SoLoud
{
class Openmpt;
class File;
class OpenmptInstance : public AudioSourceInstance
{
Openmpt *mParent;
void *mModfile;
int mPlaying;
public:
OpenmptInstance(Openmpt *aParent);
virtual ~OpenmptInstance();
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
};
class Openmpt : public AudioSource
{
public:
char *mData;
unsigned int mDataLen;
Openmpt();
virtual ~Openmpt();
result load(const char* aFilename);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
};
};
#endif

@ -0,0 +1,72 @@
/*
SoLoud audio engine
Copyright (c) 2013-2018 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_QUEUE_H
#define SOLOUD_QUEUE_H
#include "soloud.h"
#define SOLOUD_QUEUE_MAX 32
namespace SoLoud
{
class Queue;
class QueueInstance : public AudioSourceInstance
{
Queue *mParent;
public:
QueueInstance(Queue *aParent);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
virtual ~QueueInstance();
};
class Queue : public AudioSource
{
public:
Queue();
virtual QueueInstance *createInstance();
// Play sound through the queue
result play(AudioSource &aSound);
// Number of audio sources queued for replay
unsigned int getQueueCount();
// Is this audio source currently playing?
bool isCurrentlyPlaying(AudioSource &aSound);
// Set params by reading them from an audio source
result setParamsFromAudioSource(AudioSource &aSound);
// Set params manually
result setParams(float aSamplerate, unsigned int aChannels = 2);
public:
unsigned int mReadIndex, mWriteIndex, mCount;
AudioSourceInstance *mSource[SOLOUD_QUEUE_MAX];
QueueInstance *mInstance;
handle mQueueHandle;
void findQueueHandle();
};
};
#endif

@ -0,0 +1,72 @@
/*
SoLoud audio engine
Copyright (c) 2020 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_ROBOTIZEFILTER_H
#define SOLOUD_ROBOTIZEFILTER_H
#include "soloud.h"
#include "soloud_filter.h"
#include "soloud_misc.h"
namespace SoLoud
{
class RobotizeFilter;
class RobotizeFilterInstance : public FilterInstance
{
enum FILTERATTRIBUTE
{
WET = 0,
FREQ,
WAVE
};
RobotizeFilter *mParent;
public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
RobotizeFilterInstance(RobotizeFilter *aParent);
};
class RobotizeFilter : public Filter
{
public:
enum FILTERATTRIBUTE
{
WET = 0,
FREQ,
WAVE
};
float mFreq;
int mWave;
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
void setParams(float aFreq, int aWaveform);
virtual FilterInstance *createInstance();
RobotizeFilter();
};
}
#endif

@ -1,169 +1,159 @@
/*
SFXR module for SoLoud audio engine
Copyright (c) 2014 Jari Komppa
Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SFXR_H
#define SFXR_H
#include "soloud.h"
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;
float p_base_freq;
float p_freq_limit;
float p_freq_ramp;
float p_freq_dramp;
float p_duty;
float p_duty_ramp;
float p_vib_strength;
float p_vib_speed;
float p_vib_delay;
float p_env_attack;
float p_env_sustain;
float p_env_decay;
float p_env_punch;
bool filter_on;
float p_lpf_resonance;
float p_lpf_freq;
float p_lpf_ramp;
float p_hpf_freq;
float p_hpf_ramp;
float p_pha_offset;
float p_pha_ramp;
float p_repeat_speed;
float p_arp_speed;
float p_arp_mod;
float master_vol;
float sound_vol;
};
class Sfxr;
class SfxrInstance : public AudioSourceInstance
{
Sfxr *mParent;
Prg mRand;
SfxrParams mParams;
bool playing_sample;
int phase;
double fperiod;
double fmaxperiod;
double fslide;
double fdslide;
int period;
float square_duty;
float square_slide;
int env_stage;
int env_time;
int env_length[3];
float env_vol;
float fphase;
float fdphase;
int iphase;
float phaser_buffer[1024];
int ipp;
float noise_buffer[32];
float fltp;
float fltdp;
float fltw;
float fltw_d;
float fltdmp;
float fltphp;
float flthp;
float flthp_d;
float vib_phase;
float vib_speed;
float vib_amp;
int rep_time;
int rep_limit;
int arp_time;
int arp_limit;
double arp_mod;
void resetSample(bool aRestart);
public:
SfxrInstance(Sfxr *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded();
};
class Sfxr : public AudioSource
{
public:
SfxrParams mParams;
enum SFXR_PRESETS
{
COIN,
LASER,
EXPLOSION,
POWERUP,
HURT,
JUMP,
BLIP
};
Prg mRand;
Sfxr();
virtual ~Sfxr();
void resetParams();
result loadParams(const char* aFilename);
result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadParamsFile(File *aFile);
result loadPreset(int aPresetNo, int aRandSeed);
virtual AudioSourceInstance *createInstance();
};
};
/*
SFXR module for SoLoud audio engine
Copyright (c) 2014 Jari Komppa
Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SFXR_H
#define SFXR_H
#include "soloud.h"
#include "soloud_misc.h"
namespace SoLoud
{
class File;
struct SfxrParams
{
int wave_type;
float p_base_freq;
float p_freq_limit;
float p_freq_ramp;
float p_freq_dramp;
float p_duty;
float p_duty_ramp;
float p_vib_strength;
float p_vib_speed;
float p_vib_delay;
float p_env_attack;
float p_env_sustain;
float p_env_decay;
float p_env_punch;
bool filter_on;
float p_lpf_resonance;
float p_lpf_freq;
float p_lpf_ramp;
float p_hpf_freq;
float p_hpf_ramp;
float p_pha_offset;
float p_pha_ramp;
float p_repeat_speed;
float p_arp_speed;
float p_arp_mod;
float master_vol;
float sound_vol;
};
class Sfxr;
class SfxrInstance : public AudioSourceInstance
{
Sfxr *mParent;
Misc::Prg mRand;
SfxrParams mParams;
bool playing_sample;
int phase;
double fperiod;
double fmaxperiod;
double fslide;
double fdslide;
int period;
float square_duty;
float square_slide;
int env_stage;
int env_time;
int env_length[3];
float env_vol;
float fphase;
float fdphase;
int iphase;
float phaser_buffer[1024];
int ipp;
float noise_buffer[32];
float fltp;
float fltdp;
float fltw;
float fltw_d;
float fltdmp;
float fltphp;
float flthp;
float flthp_d;
float vib_phase;
float vib_speed;
float vib_amp;
int rep_time;
int rep_limit;
int arp_time;
int arp_limit;
double arp_mod;
void resetSample(bool aRestart);
public:
SfxrInstance(Sfxr *aParent);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
};
class Sfxr : public AudioSource
{
public:
SfxrParams mParams;
enum SFXR_PRESETS
{
COIN,
LASER,
EXPLOSION,
POWERUP,
HURT,
JUMP,
BLIP
};
Misc::Prg mRand;
Sfxr();
virtual ~Sfxr();
void resetParams();
result loadParams(const char* aFilename);
result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadParamsFile(File *aFile);
result loadPreset(int aPresetNo, int aRandSeed);
virtual AudioSourceInstance *createInstance();
};
};
#endif

@ -1,63 +1,79 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_SPEECH_H
#define SOLOUD_SPEECH_H
#include "soloud.h"
#include "../src/audiosource/speech/darray.h"
#include "../src/audiosource/speech/klatt.h"
#include "../src/audiosource/speech/tts.h"
namespace SoLoud
{
class Speech;
class Speech : public AudioSource
{
public:
int mFrames;
darray mElement;
Speech();
result setText(const char *aText);
virtual ~Speech();
virtual AudioSourceInstance *createInstance();
};
class SpeechInstance : public AudioSourceInstance
{
klatt mSynth;
Speech *mParent;
short *mSample;
int mSampleCount;
int mOffset;
public:
SpeechInstance(Speech *aParent);
virtual ~SpeechInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind();
virtual bool hasEnded();
};
};
#endif
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_SPEECH_H
#define SOLOUD_SPEECH_H
#include "soloud.h"
#include "../src/audiosource/speech/darray.h"
#include "../src/audiosource/speech/klatt.h"
#include "../src/audiosource/speech/tts.h"
namespace SoLoud
{
class Speech;
class Speech : public AudioSource
{
// copy of the enum in klatt.h for codegen purposes
enum KLATT_WAVEFORM
{
KW_SAW,
KW_TRIANGLE,
KW_SIN,
KW_SQUARE,
KW_PULSE,
KW_NOISE,
KW_WARBLE
};
public:
int mBaseFrequency;
float mBaseSpeed;
float mBaseDeclination;
int mBaseWaveform;
int mFrames;
darray mElement;
Speech();
result setText(const char *aText);
result setParams(unsigned int aBaseFrequency = 1330, float aBaseSpeed = 10.0f, float aBaseDeclination = 0.5f, int aBaseWaveform = KW_TRIANGLE);
virtual ~Speech();
virtual AudioSourceInstance *createInstance();
};
class SpeechInstance : public AudioSourceInstance
{
klatt mSynth;
Speech *mParent;
short *mSample;
int mSampleCount;
int mOffset;
public:
SpeechInstance(Speech *aParent);
virtual ~SpeechInstance();
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual result rewind();
virtual bool hasEnded();
};
};
#endif

@ -1,74 +1,72 @@
/*
TED/SID module for SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef TEDSID_H
#define TEDSID_H
#include "soloud.h"
class SIDsound;
class TED;
namespace SoLoud
{
class TedSid;
class File;
class TedSidInstance : public AudioSourceInstance
{
TedSid *mParent;
SIDsound *mSID;
TED *mTED;
unsigned int mSampleCount;
int mNextReg;
int mNextVal;
int mRegValues[128];
public:
TedSidInstance(TedSid *aParent);
~TedSidInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual void tick();
virtual bool hasEnded();
virtual float getInfo(unsigned int aInfoKey);
};
class TedSid : public AudioSource
{
public:
File *mFile;
int mModel;
bool mFileOwned;
TedSid();
~TedSid();
result load(const char *aFilename);
result loadToMem(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFileToMem(File *aFile);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
};
};
/*
TED/SID module for SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef TEDSID_H
#define TEDSID_H
#include "soloud.h"
class SIDsound;
class TED;
namespace SoLoud
{
class TedSid;
class File;
class TedSidInstance : public AudioSourceInstance
{
TedSid *mParent;
SIDsound *mSID;
TED *mTED;
int mPos;
unsigned int mSampleCount;
int mRegValues[128];
public:
TedSidInstance(TedSid *aParent);
~TedSidInstance();
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual void tick();
virtual bool hasEnded();
virtual float getInfo(unsigned int aInfoKey);
};
class TedSid : public AudioSource
{
public:
int mLooppos;
int mLength;
unsigned short* mOps;
int mModel;
TedSid();
~TedSid();
result load(const char *aFilename);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
};
};
#endif

@ -1,83 +1,84 @@
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_THREAD_H
#define SOLOUD_THREAD_H
#include "soloud.h"
namespace SoLoud
{
namespace Thread
{
typedef void (*threadFunction)(void *aParam);
struct ThreadHandleData;
typedef ThreadHandleData* ThreadHandle;
void * createMutex();
void destroyMutex(void *aHandle);
void lockMutex(void *aHandle);
void unlockMutex(void *aHandle);
ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter);
void sleep(int aMSec);
void wait(ThreadHandle aThreadHandle);
void release(ThreadHandle aThreadHandle);
#define MAX_THREADPOOL_TASKS 1024
class PoolTask
{
public:
virtual void work() = 0;
};
class Pool
{
public:
// Initialize and run thread pool. For thread count 0, work is done at addWork call.
void init(int aThreadCount);
// Ctor, sets known state
Pool();
// Dtor. Waits for the threads to finish. Work may be unfinished.
~Pool();
// Add work to work list. Object is not automatically deleted when work is done.
void addWork(PoolTask *aTask);
// Called from worker thread to get a new task. Returns null if no work available.
PoolTask *getWork();
public:
int mThreadCount; // number of threads
ThreadHandle *mThread; // array of thread handles
void *mWorkMutex; // mutex to protect task array/maxtask
PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks
int mMaxTask; // how many tasks are pending
int mRobin; // cyclic counter, used to pick jobs for threads
volatile int mRunning; // running flag, used to flag threads to stop
};
}
}
/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_THREAD_H
#define SOLOUD_THREAD_H
#include "soloud.h"
namespace SoLoud
{
namespace Thread
{
typedef void (*threadFunction)(void *aParam);
struct ThreadHandleData;
typedef ThreadHandleData* ThreadHandle;
void * createMutex();
void destroyMutex(void *aHandle);
void lockMutex(void *aHandle);
void unlockMutex(void *aHandle);
ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter);
void sleep(int aMSec);
void wait(ThreadHandle aThreadHandle);
void release(ThreadHandle aThreadHandle);
int getTimeMillis();
#define MAX_THREADPOOL_TASKS 1024
class PoolTask
{
public:
virtual void work() = 0;
};
class Pool
{
public:
// Initialize and run thread pool. For thread count 0, work is done at addWork call.
void init(int aThreadCount);
// Ctor, sets known state
Pool();
// Dtor. Waits for the threads to finish. Work may be unfinished.
~Pool();
// Add work to work list. Object is not automatically deleted when work is done.
void addWork(PoolTask *aTask);
// Called from worker thread to get a new task. Returns null if no work available.
PoolTask *getWork();
public:
int mThreadCount; // number of threads
ThreadHandle *mThread; // array of thread handles
void *mWorkMutex; // mutex to protect task array/maxtask
PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks
int mMaxTask; // how many tasks are pending
int mRobin; // cyclic counter, used to pick jobs for threads
volatile int mRunning; // running flag, used to flag threads to stop
};
}
}
#endif

@ -1,108 +1,108 @@
/*
SoLoud audio engine
Copyright (c) 2015 Jari Komppa
VIC 6560/6561 sound chip emulator
Copyright (c) 2015 Petri Hakkinen
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_VIC_H
#define SOLOUD_VIC_H
#include "soloud.h"
/*
A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models.
Bass, alto and soprano should be quite close to original vic, noise probably not so.
The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency.
The highest bit of each oscillator register switches the oscillator on/off.
The fourth oscillator generates a noise waveform.
VIC-20 does not have per channel volume control, only global volume,
which you can change by setting audio source's volume.
To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0.
*/
namespace SoLoud
{
class Vic;
class VicInstance : public AudioSourceInstance
{
public:
VicInstance(Vic *aParent);
~VicInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded();
private:
Vic* m_parent;
unsigned int m_phase[4];
unsigned int m_noisePos;
};
class Vic : public AudioSource
{
public:
// VIC model
enum
{
PAL = 0,
NTSC,
};
// VIC sound registers
enum
{
BASS = 0,
ALTO,
SOPRANO,
NOISE,
MAX_REGS
};
Vic();
virtual ~Vic();
void setModel(int model);
int getModel() const;
void setRegister(int reg, unsigned char value) { m_regs[reg] = value; }
unsigned char getRegister(int reg) const { return m_regs[reg]; }
virtual AudioSourceInstance *createInstance();
private:
friend class VicInstance;
int m_model;
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
unsigned char m_regs[MAX_REGS];
unsigned char m_noise[8192];
};
};
#endif
/*
SoLoud audio engine
Copyright (c) 2015 Jari Komppa
VIC 6560/6561 sound chip emulator
Copyright (c) 2015 Petri Hakkinen
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_VIC_H
#define SOLOUD_VIC_H
#include "soloud.h"
/*
A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models.
Bass, alto and soprano should be quite close to original vic, noise probably not so.
The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency.
The highest bit of each oscillator register switches the oscillator on/off.
The fourth oscillator generates a noise waveform.
VIC-20 does not have per channel volume control, only global volume,
which you can change by setting audio source's volume.
To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0.
*/
namespace SoLoud
{
class Vic;
class VicInstance : public AudioSourceInstance
{
public:
VicInstance(Vic *aParent);
~VicInstance();
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual bool hasEnded();
public:
Vic* m_parent;
unsigned int m_phase[4];
unsigned int m_noisePos;
};
class Vic : public AudioSource
{
public:
// VIC model
enum
{
PAL = 0,
NTSC
};
// VIC sound registers
enum
{
BASS = 0,
ALTO,
SOPRANO,
NOISE,
MAX_REGS
};
Vic();
virtual ~Vic();
void setModel(int model);
int getModel() const;
void setRegister(int reg, unsigned char value);
unsigned char getRegister(int reg);
public:
virtual AudioSourceInstance *createInstance();
int m_model;
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
unsigned char m_regs[MAX_REGS];
unsigned char m_noise[8192];
};
};
#endif

@ -0,0 +1,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,68 +1,74 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAV_H
#define SOLOUD_WAV_H
#include "soloud.h"
struct stb_vorbis;
namespace SoLoud
{
class Wav;
class File;
class WavInstance : public AudioSourceInstance
{
Wav *mParent;
unsigned int mOffset;
public:
WavInstance(Wav *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind();
virtual bool hasEnded();
};
class Wav : public AudioSource
{
result loadwav(File *aReader);
result loadogg(File *aReader);
result testAndLoadFile(File *aReader);
public:
float *mData;
unsigned int mSampleCount;
Wav();
virtual ~Wav();
result load(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance();
time getLength();
};
};
#endif
/*
SoLoud audio engine
Copyright (c) 2013-2018 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAV_H
#define SOLOUD_WAV_H
#include "soloud.h"
struct stb_vorbis;
namespace SoLoud
{
class Wav;
class File;
class MemoryFile;
class WavInstance : public AudioSourceInstance
{
Wav *mParent;
unsigned int mOffset;
public:
WavInstance(Wav *aParent);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual result rewind();
virtual bool hasEnded();
};
class Wav : public AudioSource
{
result loadwav(MemoryFile *aReader);
result loadogg(MemoryFile *aReader);
result loadmp3(MemoryFile *aReader);
result loadflac(MemoryFile *aReader);
result testAndLoadFile(MemoryFile *aReader);
public:
float *mData;
unsigned int mSampleCount;
Wav();
virtual ~Wav();
result load(const char *aFilename);
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile);
result loadRawWave8(unsigned char *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1);
result loadRawWave16(short *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1);
result loadRawWave(float *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1, bool aCopy = false, bool aTakeOwnership = true);
virtual AudioSourceInstance *createInstance();
time getLength();
};
};
#endif

@ -0,0 +1,63 @@
/*
SoLoud audio engine
Copyright (c) 2013-2018 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAVESHAPERFILTER_H
#define SOLOUD_WAVESHAPERFILTER_H
#include "soloud.h"
namespace SoLoud
{
class WaveShaperFilter;
class WaveShaperFilterInstance : public FilterInstance
{
WaveShaperFilter *mParent;
public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~WaveShaperFilterInstance();
WaveShaperFilterInstance(WaveShaperFilter *aParent);
};
class WaveShaperFilter : public Filter
{
public:
enum FILTERPARAMS {
WET = 0,
AMOUNT
};
float mAmount;
virtual WaveShaperFilterInstance *createInstance();
result setParams(float aAmount);
WaveShaperFilter();
virtual ~WaveShaperFilter();
virtual int getParamCount();
virtual const char* getParamName(unsigned int aParamIndex);
virtual unsigned int getParamType(unsigned int aParamIndex);
virtual float getParamMax(unsigned int aParamIndex);
virtual float getParamMin(unsigned int aParamIndex);
};
}
#endif

@ -1,83 +1,106 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAVSTREAM_H
#define SOLOUD_WAVSTREAM_H
#include <stdio.h>
#include "soloud.h"
struct stb_vorbis;
namespace SoLoud
{
class WavStream;
class File;
class WavStreamInstance : public AudioSourceInstance
{
WavStream *mParent;
unsigned int mOffset;
File *mFile;
stb_vorbis *mOgg;
unsigned int mOggFrameSize;
unsigned int mOggFrameOffset;
float **mOggOutputs;
public:
WavStreamInstance(WavStream *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind();
virtual bool hasEnded();
virtual ~WavStreamInstance();
};
class WavStream : public AudioSource
{
result loadwav(File * fp);
result loadogg(File * fp);
public:
int mOgg;
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 loadToMem(const char *aFilename);
result loadFile(File *aFile);
result loadFileToMem(File *aFile);
virtual AudioSourceInstance *createInstance();
time getLength();
public:
result parse(File *aFile);
};
};
/*
SoLoud audio engine
Copyright (c) 2013-2018 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAVSTREAM_H
#define SOLOUD_WAVSTREAM_H
#include <stdio.h>
#include "soloud.h"
struct stb_vorbis;
#ifndef dr_flac_h
struct drflac;
#endif
#ifndef dr_mp3_h
struct drmp3;
#endif
#ifndef dr_wav_h
struct drwav;
#endif
namespace SoLoud
{
class WavStream;
class File;
class WavStreamInstance : public AudioSourceInstance
{
WavStream *mParent;
unsigned int mOffset;
File *mFile;
union codec
{
stb_vorbis *mOgg;
drflac *mFlac;
drmp3 *mMp3;
drwav *mWav;
} mCodec;
unsigned int mOggFrameSize;
unsigned int mOggFrameOffset;
float **mOggOutputs;
public:
WavStreamInstance(WavStream *aParent);
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
virtual result rewind();
virtual bool hasEnded();
virtual ~WavStreamInstance();
};
enum WAVSTREAM_FILETYPE
{
WAVSTREAM_WAV = 0,
WAVSTREAM_OGG = 1,
WAVSTREAM_FLAC = 2,
WAVSTREAM_MP3 = 3
};
class WavStream : public AudioSource
{
result loadwav(File *fp);
result loadogg(File *fp);
result loadflac(File *fp);
result loadmp3(File *fp);
public:
int mFiletype;
char *mFilename;
File *mMemFile;
File *mStreamFile;
unsigned int mSampleCount;
WavStream();
virtual ~WavStream();
result load(const char *aFilename);
result loadMem(const unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true);
result loadToMem(const char *aFilename);
result loadFile(File *aFile);
result loadFileToMem(File *aFile);
virtual AudioSourceInstance *createInstance();
time getLength();
public:
result parse(File *aFile);
};
};
#endif

@ -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,8 +59,9 @@ 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->buckets[i] = array_new(struct Hashmap_Entry);
hashmap->iter_bucket = 0;
hashmap->iter_index = -1;
return hashmap;
@ -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
#endif
Loading…
Cancel
Save