parent
120cf39ba0
commit
a53f735155
@ -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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_AUDIOSOURCE_H |
#ifndef SOLOUD_AUDIOSOURCE_H |
||||||
#define SOLOUD_AUDIOSOURCE_H |
#define SOLOUD_AUDIOSOURCE_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
#include "soloud_fader.h" |
#include "soloud_fader.h" |
||||||
#include "soloud_filter.h" |
#include "soloud_filter.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class AudioSource;
|
class AudioSource;
|
||||||
class AudioSourceInstance; |
class AudioSourceInstance; |
||||||
class AudioSourceInstance3dData; |
class AudioSourceInstance3dData; |
||||||
|
|
||||||
struct AudioSourceResampleData |
class AudioCollider |
||||||
{ |
{ |
||||||
AudioSourceResampleData(); |
public: |
||||||
~AudioSourceResampleData(); |
// Calculate volume multiplier. Assumed to return value between 0 and 1.
|
||||||
float *mBuffer; |
virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0; |
||||||
}; |
}; |
||||||
|
|
||||||
class AudioCollider |
class AudioAttenuator |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
// Calculate volume multiplier. Assumed to return value between 0 and 1.
|
virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0; |
||||||
virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0; |
}; |
||||||
}; |
|
||||||
|
class AudioSourceInstance3dData |
||||||
class AudioAttenuator |
{ |
||||||
{ |
public: |
||||||
public: |
// ctor
|
||||||
virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0; |
AudioSourceInstance3dData(); |
||||||
}; |
// Set settings from audiosource
|
||||||
|
void init(AudioSource &aSource); |
||||||
class AudioSourceInstance3dData |
// 3d position
|
||||||
{ |
float m3dPosition[3]; |
||||||
public: |
// 3d velocity
|
||||||
// ctor
|
float m3dVelocity[3]; |
||||||
AudioSourceInstance3dData(); |
// 3d cone direction
|
||||||
// Set settings from audiosource
|
/*
|
||||||
void init(AudioSource &aSource); |
float m3dConeDirection[3]; |
||||||
// 3d position
|
// 3d cone inner angle
|
||||||
float m3dPosition[3]; |
float m3dConeInnerAngle; |
||||||
// 3d velocity
|
// 3d cone outer angle
|
||||||
float m3dVelocity[3]; |
float m3dConeOuterAngle; |
||||||
// 3d cone direction
|
// 3d cone outer volume multiplier
|
||||||
/*
|
float m3dConeOuterVolume; |
||||||
float m3dConeDirection[3]; |
*/ |
||||||
// 3d cone inner angle
|
// 3d min distance
|
||||||
float m3dConeInnerAngle; |
float m3dMinDistance; |
||||||
// 3d cone outer angle
|
// 3d max distance
|
||||||
float m3dConeOuterAngle; |
float m3dMaxDistance; |
||||||
// 3d cone outer volume multiplier
|
// 3d attenuation rolloff factor
|
||||||
float m3dConeOuterVolume; |
float m3dAttenuationRolloff; |
||||||
*/ |
// 3d attenuation model
|
||||||
// 3d min distance
|
unsigned int m3dAttenuationModel; |
||||||
float m3dMinDistance; |
// 3d doppler factor
|
||||||
// 3d max distance
|
float m3dDopplerFactor; |
||||||
float m3dMaxDistance; |
// Pointer to a custom audio collider object
|
||||||
// 3d attenuation rolloff factor
|
AudioCollider *mCollider; |
||||||
float m3dAttenuationRolloff; |
// Pointer to a custom audio attenuator object
|
||||||
// 3d attenuation model
|
AudioAttenuator *mAttenuator; |
||||||
unsigned int m3dAttenuationModel; |
// User data related to audio collider
|
||||||
// 3d doppler factor
|
int mColliderData; |
||||||
float m3dDopplerFactor; |
|
||||||
// Pointer to a custom audio collider object
|
// Doppler sample rate multiplier
|
||||||
AudioCollider *mCollider; |
float mDopplerValue;
|
||||||
// Pointer to a custom audio attenuator object
|
// Overall 3d volume
|
||||||
AudioAttenuator *mAttenuator; |
float m3dVolume; |
||||||
// User data related to audio collider
|
// Channel volume
|
||||||
int mColliderData; |
float mChannelVolume[MAX_CHANNELS]; |
||||||
|
// Copy of flags
|
||||||
// Doppler sample rate multiplier
|
unsigned int mFlags; |
||||||
float mDopplerValue;
|
// Latest handle for this voice
|
||||||
// Overall 3d volume
|
handle mHandle; |
||||||
float m3dVolume; |
}; |
||||||
// Channel volume
|
|
||||||
float mChannelVolume[MAX_CHANNELS]; |
// Base class for audio instances
|
||||||
// Copy of flags
|
class AudioSourceInstance |
||||||
unsigned int mFlags; |
{ |
||||||
// Latest handle for this voice
|
public: |
||||||
handle mHandle; |
enum FLAGS |
||||||
}; |
{
|
||||||
|
// This audio instance loops (if supported)
|
||||||
// Base class for audio instances
|
LOOPING = 1, |
||||||
class AudioSourceInstance |
// This audio instance is protected - won't get stopped if we run out of voices
|
||||||
{ |
PROTECTED = 2, |
||||||
public: |
// This audio instance is paused
|
||||||
enum FLAGS |
PAUSED = 4, |
||||||
{
|
// This audio instance is affected by 3d processing
|
||||||
// This audio instance loops (if supported)
|
PROCESS_3D = 8, |
||||||
LOOPING = 1, |
// This audio instance has listener-relative 3d coordinates
|
||||||
// This audio instance is protected - won't get stopped if we run out of voices
|
LISTENER_RELATIVE = 16, |
||||||
PROTECTED = 2, |
// Currently inaudible
|
||||||
// This audio instance is paused
|
INAUDIBLE = 32, |
||||||
PAUSED = 4, |
// If inaudible, should be killed (default = don't kill kill)
|
||||||
// This audio instance is affected by 3d processing
|
INAUDIBLE_KILL = 64, |
||||||
PROCESS_3D = 8, |
// If inaudible, should still be ticked (default = pause)
|
||||||
// This audio instance has listener-relative 3d coordinates
|
INAUDIBLE_TICK = 128, |
||||||
LISTENER_RELATIVE = 16, |
// Don't auto-stop sound
|
||||||
// Currently inaudible
|
DISABLE_AUTOSTOP = 256 |
||||||
INAUDIBLE = 32, |
}; |
||||||
// If inaudible, should be killed (default = don't kill kill)
|
// Ctor
|
||||||
INAUDIBLE_KILL = 64, |
AudioSourceInstance(); |
||||||
// If inaudible, should still be ticked (default = pause)
|
// Dtor
|
||||||
INAUDIBLE_TICK = 128 |
virtual ~AudioSourceInstance(); |
||||||
}; |
// Play index; used to identify instances from handles
|
||||||
// Ctor
|
unsigned int mPlayIndex; |
||||||
AudioSourceInstance(); |
// Loop count
|
||||||
// Dtor
|
unsigned int mLoopCount; |
||||||
virtual ~AudioSourceInstance(); |
// Flags; see AudioSourceInstance::FLAGS
|
||||||
// Play index; used to identify instances from handles
|
unsigned int mFlags; |
||||||
unsigned int mPlayIndex; |
// Pan value, for getPan()
|
||||||
// Loop count
|
float mPan; |
||||||
unsigned int mLoopCount; |
// Volume for each channel (panning)
|
||||||
// Flags; see AudioSourceInstance::FLAGS
|
float mChannelVolume[MAX_CHANNELS]; |
||||||
unsigned int mFlags; |
// Set volume
|
||||||
// Pan value, for getPan()
|
float mSetVolume; |
||||||
float mPan; |
// Overall volume overall = set * 3d
|
||||||
// Volume for each channel (panning)
|
float mOverallVolume; |
||||||
float mChannelVolume[MAX_CHANNELS]; |
// Base samplerate; samplerate = base samplerate * relative play speed
|
||||||
// Set volume
|
float mBaseSamplerate; |
||||||
float mSetVolume; |
// Samplerate; samplerate = base samplerate * relative play speed
|
||||||
// Overall volume overall = set * 3d
|
float mSamplerate; |
||||||
float mOverallVolume; |
// Number of channels this audio source produces
|
||||||
// Base samplerate; samplerate = base samplerate * relative play speed
|
unsigned int mChannels; |
||||||
float mBaseSamplerate; |
// Relative play speed; samplerate = base samplerate * relative play speed
|
||||||
// Samplerate; samplerate = base samplerate * relative play speed
|
float mSetRelativePlaySpeed; |
||||||
float mSamplerate; |
// Overall relative plays peed; overall = set * 3d
|
||||||
// Number of channels this audio source produces
|
float mOverallRelativePlaySpeed; |
||||||
unsigned int mChannels; |
// How long this stream has played, in seconds.
|
||||||
// Relative play speed; samplerate = base samplerate * relative play speed
|
time mStreamTime; |
||||||
float mSetRelativePlaySpeed; |
// Position of this stream, in seconds.
|
||||||
// Overall relative plays peed; overall = set * 3d
|
time mStreamPosition; |
||||||
float mOverallRelativePlaySpeed; |
// Fader for the audio panning
|
||||||
// How long this stream has played, in seconds.
|
Fader mPanFader; |
||||||
time mStreamTime; |
// Fader for the audio volume
|
||||||
// Fader for the audio panning
|
Fader mVolumeFader; |
||||||
Fader mPanFader; |
// Fader for the relative play speed
|
||||||
// Fader for the audio volume
|
Fader mRelativePlaySpeedFader; |
||||||
Fader mVolumeFader; |
// Fader used to schedule pausing of the stream
|
||||||
// Fader for the relative play speed
|
Fader mPauseScheduler; |
||||||
Fader mRelativePlaySpeedFader; |
// Fader used to schedule stopping of the stream
|
||||||
// Fader used to schedule pausing of the stream
|
Fader mStopScheduler; |
||||||
Fader mPauseScheduler; |
// Affected by some fader
|
||||||
// Fader used to schedule stopping of the stream
|
int mActiveFader; |
||||||
Fader mStopScheduler; |
// Current channel volumes, used to ramp the volume changes to avoid clicks
|
||||||
// Affected by some fader
|
float mCurrentChannelVolume[MAX_CHANNELS]; |
||||||
int mActiveFader; |
// ID of the sound source that generated this instance
|
||||||
// Current channel volumes, used to ramp the volume changes to avoid clicks
|
unsigned int mAudioSourceID; |
||||||
float mCurrentChannelVolume[MAX_CHANNELS]; |
// Handle of the bus this audio instance is playing on. 0 for root.
|
||||||
// ID of the sound source that generated this instance
|
unsigned int mBusHandle; |
||||||
unsigned int mAudioSourceID; |
// Filter pointer
|
||||||
// Handle of the bus this audio instance is playing on. 0 for root.
|
FilterInstance *mFilter[FILTERS_PER_STREAM]; |
||||||
unsigned int mBusHandle; |
// Initialize instance. Mostly internal use.
|
||||||
// Filter pointer
|
void init(AudioSource &aSource, int aPlayIndex); |
||||||
FilterInstance *mFilter[FILTERS_PER_STREAM]; |
// Pointers to buffers for the resampler
|
||||||
// Initialize instance. Mostly internal use.
|
float *mResampleData[2]; |
||||||
void init(AudioSource &aSource, int aPlayIndex); |
// Sub-sample playhead; 16.16 fixed point
|
||||||
// Buffers for the resampler
|
unsigned int mSrcOffset; |
||||||
AudioSourceResampleData *mResampleData[2]; |
// Samples left over from earlier pass
|
||||||
// Sub-sample playhead; 16.16 fixed point
|
unsigned int mLeftoverSamples; |
||||||
unsigned int mSrcOffset; |
// Number of samples to delay streaming
|
||||||
// Samples left over from earlier pass
|
unsigned int mDelaySamples; |
||||||
unsigned int mLeftoverSamples; |
// When looping, start playing from this time
|
||||||
// Number of samples to delay streaming
|
time mLoopPoint; |
||||||
unsigned int mDelaySamples; |
|
||||||
|
// Get N samples from the stream to the buffer. Report samples written.
|
||||||
// Get N samples from the stream to the buffer
|
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize) = 0; |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples) = 0; |
// Has the stream ended?
|
||||||
// Has the stream ended?
|
virtual bool hasEnded() = 0; |
||||||
virtual bool hasEnded() = 0; |
// Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow).
|
||||||
// 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); |
||||||
virtual void seek(time aSeconds, float *mScratch, unsigned int mScratchSize); |
// Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind.
|
||||||
// Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind.
|
virtual result rewind(); |
||||||
virtual result rewind(); |
// Get information. Returns 0 by default.
|
||||||
// Get information. Returns 0 by default.
|
virtual float getInfo(unsigned int aInfoKey); |
||||||
virtual float getInfo(unsigned int aInfoKey); |
}; |
||||||
}; |
|
||||||
|
class Soloud; |
||||||
class Soloud; |
|
||||||
|
// Base class for audio sources
|
||||||
// Base class for audio sources
|
class AudioSource |
||||||
class AudioSource |
{ |
||||||
{ |
public: |
||||||
public: |
enum FLAGS |
||||||
enum FLAGS |
{ |
||||||
{ |
// The instances from this audio source should loop
|
||||||
// The instances from this audio source should loop
|
SHOULD_LOOP = 1, |
||||||
SHOULD_LOOP = 1, |
// Only one instance of this audio source should play at the same time
|
||||||
// Only one instance of this audio source should play at the same time
|
SINGLE_INSTANCE = 2, |
||||||
SINGLE_INSTANCE = 2, |
// Visualization data gathering enabled. Only for busses.
|
||||||
// Visualization data gathering enabled. Only for busses.
|
VISUALIZATION_DATA = 4, |
||||||
VISUALIZATION_DATA = 4, |
// Audio instances created from this source are affected by 3d processing
|
||||||
// Audio instances created from this source are affected by 3d processing
|
PROCESS_3D = 8, |
||||||
PROCESS_3D = 8, |
// Audio instances created from this source have listener-relative 3d coordinates
|
||||||
// Audio instances created from this source have listener-relative 3d coordinates
|
LISTENER_RELATIVE = 16, |
||||||
LISTENER_RELATIVE = 16, |
// Delay start of sound by the distance from listener
|
||||||
// Delay start of sound by the distance from listener
|
DISTANCE_DELAY = 32, |
||||||
DISTANCE_DELAY = 32, |
// If inaudible, should be killed (default)
|
||||||
// If inaudible, should be killed (default)
|
INAUDIBLE_KILL = 64, |
||||||
INAUDIBLE_KILL = 64, |
// If inaudible, should still be ticked (default = pause)
|
||||||
// If inaudible, should still be ticked (default = pause)
|
INAUDIBLE_TICK = 128, |
||||||
INAUDIBLE_TICK = 128 |
// Disable auto-stop
|
||||||
}; |
DISABLE_AUTOSTOP = 256 |
||||||
enum ATTENUATION_MODELS |
}; |
||||||
{ |
enum ATTENUATION_MODELS |
||||||
// No attenuation
|
{ |
||||||
NO_ATTENUATION = 0, |
// No attenuation
|
||||||
// Inverse distance attenuation model
|
NO_ATTENUATION = 0, |
||||||
INVERSE_DISTANCE = 1, |
// Inverse distance attenuation model
|
||||||
// Linear distance attenuation model
|
INVERSE_DISTANCE = 1, |
||||||
LINEAR_DISTANCE = 2, |
// Linear distance attenuation model
|
||||||
// Exponential distance attenuation model
|
LINEAR_DISTANCE = 2, |
||||||
EXPONENTIAL_DISTANCE = 3 |
// Exponential distance attenuation model
|
||||||
}; |
EXPONENTIAL_DISTANCE = 3 |
||||||
|
}; |
||||||
// Flags. See AudioSource::FLAGS
|
|
||||||
unsigned int mFlags; |
// Flags. See AudioSource::FLAGS
|
||||||
// Base sample rate, used to initialize instances
|
unsigned int mFlags; |
||||||
float mBaseSamplerate; |
// Base sample rate, used to initialize instances
|
||||||
// Default volume for created instances
|
float mBaseSamplerate; |
||||||
float mVolume; |
// Default volume for created instances
|
||||||
// Number of channels this audio source produces
|
float mVolume; |
||||||
unsigned int mChannels; |
// Number of channels this audio source produces
|
||||||
// Sound source ID. Assigned by SoLoud the first time it's played.
|
unsigned int mChannels; |
||||||
unsigned int mAudioSourceID; |
// Sound source ID. Assigned by SoLoud the first time it's played.
|
||||||
// 3d min distance
|
unsigned int mAudioSourceID; |
||||||
float m3dMinDistance; |
// 3d min distance
|
||||||
// 3d max distance
|
float m3dMinDistance; |
||||||
float m3dMaxDistance; |
// 3d max distance
|
||||||
// 3d attenuation rolloff factor
|
float m3dMaxDistance; |
||||||
float m3dAttenuationRolloff; |
// 3d attenuation rolloff factor
|
||||||
// 3d attenuation model
|
float m3dAttenuationRolloff; |
||||||
unsigned int m3dAttenuationModel; |
// 3d attenuation model
|
||||||
// 3d doppler factor
|
unsigned int m3dAttenuationModel; |
||||||
float m3dDopplerFactor; |
// 3d doppler factor
|
||||||
// Filter pointer
|
float m3dDopplerFactor; |
||||||
Filter *mFilter[FILTERS_PER_STREAM]; |
// Filter pointer
|
||||||
// Pointer to the Soloud object. Needed to stop all instances in dtor.
|
Filter *mFilter[FILTERS_PER_STREAM]; |
||||||
Soloud *mSoloud; |
// Pointer to the Soloud object. Needed to stop all instances in dtor.
|
||||||
// Pointer to a custom audio collider object
|
Soloud *mSoloud; |
||||||
AudioCollider *mCollider; |
// Pointer to a custom audio collider object
|
||||||
// Pointer to custom attenuator object
|
AudioCollider *mCollider; |
||||||
AudioAttenuator *mAttenuator; |
// Pointer to custom attenuator object
|
||||||
// User data related to audio collider
|
AudioAttenuator *mAttenuator; |
||||||
int mColliderData; |
// User data related to audio collider
|
||||||
|
int mColliderData; |
||||||
// CTor
|
// When looping, start playing from this time
|
||||||
AudioSource(); |
time mLoopPoint; |
||||||
// Set default volume for instances
|
|
||||||
void setVolume(float aVolume); |
// CTor
|
||||||
// Set the looping of the instances created from this audio source
|
AudioSource(); |
||||||
void setLooping(bool aLoop); |
// Set default volume for instances
|
||||||
// Set whether only one instance of this sound should ever be playing at the same time
|
void setVolume(float aVolume); |
||||||
void setSingleInstance(bool aSingleInstance); |
// Set the looping of the instances created from this audio source
|
||||||
|
void setLooping(bool aLoop); |
||||||
// Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol)
|
// Set whether only one instance of this sound should ever be playing at the same time
|
||||||
void set3dMinMaxDistance(float aMinDistance, float aMaxDistance); |
void setSingleInstance(bool aSingleInstance); |
||||||
// Set attenuation model and rolloff factor for 3d audio source
|
// Set whether audio should auto-stop when it ends or not
|
||||||
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
void setAutoStop(bool aAutoStop); |
||||||
// Set doppler factor to reduce or enhance doppler effect, default = 1.0
|
|
||||||
void set3dDopplerFactor(float aDopplerFactor); |
// Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol)
|
||||||
// Enable 3d processing. Implicitly set by play3d calls.
|
void set3dMinMaxDistance(float aMinDistance, float aMaxDistance); |
||||||
void set3dProcessing(bool aDo3dProcessing); |
// Set attenuation model and rolloff factor for 3d audio source
|
||||||
// Set the coordinates for this audio source to be relative to listener's coordinates.
|
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor); |
||||||
void set3dListenerRelative(bool aListenerRelative); |
// Set doppler factor to reduce or enhance doppler effect, default = 1.0
|
||||||
// Enable delaying the start of the sound based on the distance.
|
void set3dDopplerFactor(float aDopplerFactor); |
||||||
void set3dDistanceDelay(bool aDistanceDelay); |
// Set the coordinates for this audio source to be relative to listener's coordinates.
|
||||||
|
void set3dListenerRelative(bool aListenerRelative); |
||||||
// Set a custom 3d audio collider. Set to NULL to disable.
|
// Enable delaying the start of the sound based on the distance.
|
||||||
void set3dCollider(AudioCollider *aCollider, int aUserData = 0); |
void set3dDistanceDelay(bool aDistanceDelay); |
||||||
// Set a custom attenuator. Set to NULL to disable.
|
|
||||||
void set3dAttenuator(AudioAttenuator *aAttenuator); |
// Set a custom 3d audio collider. Set to NULL to disable.
|
||||||
|
void set3dCollider(AudioCollider *aCollider, int aUserData = 0); |
||||||
// Set behavior for inaudible sounds
|
// Set a custom attenuator. Set to NULL to disable.
|
||||||
void setInaudibleBehavior(bool aMustTick, bool aKill); |
void set3dAttenuator(AudioAttenuator *aAttenuator); |
||||||
|
|
||||||
// Set filter. Set to NULL to clear the filter.
|
// Set behavior for inaudible sounds
|
||||||
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); |
void setInaudibleBehavior(bool aMustTick, bool aKill); |
||||||
// DTor
|
|
||||||
virtual ~AudioSource(); |
// Set time to jump to when looping
|
||||||
// Create instance from the audio source. Called from within Soloud class.
|
void setLoopPoint(time aLoopPoint); |
||||||
virtual AudioSourceInstance *createInstance() = 0; |
// Get current loop point value
|
||||||
// Stop all instances of this audio source
|
time getLoopPoint(); |
||||||
void stop(); |
|
||||||
}; |
// Set filter. Set to NULL to clear the filter.
|
||||||
}; |
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); |
||||||
|
// DTor
|
||||||
#endif |
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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_BASSBOOSTFILTER_H |
#ifndef SOLOUD_BASSBOOSTFILTER_H |
||||||
#define SOLOUD_BASSBOOSTFILTER_H |
#define SOLOUD_BASSBOOSTFILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
#include "soloud_fftfilter.h" |
#include "soloud_fftfilter.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class BassboostFilter; |
class BassboostFilter; |
||||||
|
|
||||||
class BassboostFilterInstance : public FFTFilterInstance |
class BassboostFilterInstance : public FFTFilterInstance |
||||||
{ |
{ |
||||||
enum FILTERATTRIBUTE |
enum FILTERATTRIBUTE |
||||||
{ |
{ |
||||||
WET = 0, |
WET = 0, |
||||||
BOOST = 1 |
BOOST = 1 |
||||||
}; |
}; |
||||||
BassboostFilter *mParent; |
BassboostFilter *mParent; |
||||||
public: |
public: |
||||||
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||||
BassboostFilterInstance(BassboostFilter *aParent); |
BassboostFilterInstance(BassboostFilter *aParent); |
||||||
}; |
}; |
||||||
|
|
||||||
class BassboostFilter : public FFTFilter |
class BassboostFilter : public FFTFilter |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
enum FILTERATTRIBUTE |
enum FILTERATTRIBUTE |
||||||
{ |
{ |
||||||
WET = 0, |
WET = 0, |
||||||
BOOST = 1 |
BOOST = 1 |
||||||
}; |
}; |
||||||
float mBoost; |
virtual int getParamCount(); |
||||||
result setParams(float aBoost); |
virtual const char* getParamName(unsigned int aParamIndex); |
||||||
virtual FilterInstance *createInstance(); |
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||||
BassboostFilter(); |
virtual float getParamMax(unsigned int aParamIndex); |
||||||
}; |
virtual float getParamMin(unsigned int aParamIndex); |
||||||
} |
float mBoost; |
||||||
|
result setParams(float aBoost); |
||||||
|
virtual FilterInstance *createInstance(); |
||||||
|
BassboostFilter(); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
#endif |
#endif |
@ -1,91 +1,94 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2014 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_BQRFILTER_H |
#ifndef SOLOUD_BQRFILTER_H |
||||||
#define SOLOUD_BQRFILTER_H |
#define SOLOUD_BQRFILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class BiquadResonantFilter; |
class BiquadResonantFilter; |
||||||
|
|
||||||
struct BQRStateData |
struct BQRStateData |
||||||
{ |
{ |
||||||
float mY1, mY2, mX1, mX2; |
float mY1, mY2, mX1, mX2; |
||||||
}; |
}; |
||||||
|
|
||||||
class BiquadResonantFilterInstance : public FilterInstance |
class BiquadResonantFilterInstance : public FilterInstance |
||||||
{ |
{ |
||||||
enum FILTERATTRIBUTE |
enum FILTERATTRIBUTE |
||||||
{ |
{ |
||||||
WET = 0, |
WET = 0, |
||||||
SAMPLERATE = 1, |
TYPE, |
||||||
FREQUENCY = 2, |
FREQUENCY, |
||||||
RESONANCE = 3 |
RESONANCE |
||||||
}; |
}; |
||||||
|
|
||||||
int mActive; |
BQRStateData mState[8]; |
||||||
BQRStateData mState[2]; |
float mA0, mA1, mA2, mB1, mB2; |
||||||
float mA0, mA1, mA2, mB1, mB2; |
int mDirty; |
||||||
int mDirty; |
float mSamplerate; |
||||||
int mFilterType; |
|
||||||
|
BiquadResonantFilter *mParent; |
||||||
BiquadResonantFilter *mParent; |
void calcBQRParams(); |
||||||
void calcBQRParams(); |
public: |
||||||
public: |
virtual void filterChannel(float *aBuffer, 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 ~BiquadResonantFilterInstance(); |
||||||
virtual ~BiquadResonantFilterInstance(); |
BiquadResonantFilterInstance(BiquadResonantFilter *aParent); |
||||||
BiquadResonantFilterInstance(BiquadResonantFilter *aParent); |
}; |
||||||
}; |
|
||||||
|
class BiquadResonantFilter : public Filter |
||||||
class BiquadResonantFilter : public Filter |
{ |
||||||
{ |
public: |
||||||
public: |
enum FILTERTYPE |
||||||
enum FILTERTYPE |
{ |
||||||
{ |
LOWPASS = 0, |
||||||
NONE = 0, |
HIGHPASS = 1, |
||||||
LOWPASS = 1, |
BANDPASS = 2 |
||||||
HIGHPASS = 2, |
}; |
||||||
BANDPASS = 3 |
enum FILTERATTRIBUTE |
||||||
}; |
{ |
||||||
enum FILTERATTRIBUTE |
WET = 0, |
||||||
{ |
TYPE, |
||||||
WET = 0, |
FREQUENCY, |
||||||
SAMPLERATE = 1, |
RESONANCE |
||||||
FREQUENCY = 2, |
}; |
||||||
RESONANCE = 3 |
int mFilterType; |
||||||
}; |
float mFrequency; |
||||||
int mFilterType; |
float mResonance; |
||||||
float mSampleRate; |
virtual int getParamCount(); |
||||||
float mFrequency; |
virtual const char* getParamName(unsigned int aParamIndex); |
||||||
float mResonance; |
virtual unsigned int getParamType(unsigned int aParamIndex); |
||||||
virtual BiquadResonantFilterInstance *createInstance(); |
virtual float getParamMax(unsigned int aParamIndex); |
||||||
BiquadResonantFilter(); |
virtual float getParamMin(unsigned int aParamIndex); |
||||||
result setParams(int aType, float aSampleRate, float aFrequency, float aResonance); |
|
||||||
virtual ~BiquadResonantFilter(); |
virtual BiquadResonantFilterInstance *createInstance(); |
||||||
}; |
BiquadResonantFilter(); |
||||||
} |
result setParams(int aType, float aFrequency, float aResonance); |
||||||
|
virtual ~BiquadResonantFilter(); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
#endif |
#endif |
@ -1,86 +1,102 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_BUS_H |
#ifndef SOLOUD_BUS_H |
||||||
#define SOLOUD_BUS_H |
#define SOLOUD_BUS_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class Bus; |
class Bus; |
||||||
|
|
||||||
class BusInstance : public AudioSourceInstance |
class BusInstance : public AudioSourceInstance |
||||||
{ |
{ |
||||||
Bus *mParent; |
Bus *mParent; |
||||||
unsigned int mScratchSize; |
unsigned int mScratchSize; |
||||||
AlignedFloatBuffer mScratch; |
AlignedFloatBuffer mScratch; |
||||||
public: |
public: |
||||||
// Mono-mixed wave data for visualization and for visualization FFT input
|
// Approximate volume for channels.
|
||||||
float mVisualizationWaveData[256]; |
float mVisualizationChannelVolume[MAX_CHANNELS]; |
||||||
|
// Mono-mixed wave data for visualization and for visualization FFT input
|
||||||
BusInstance(Bus *aParent); |
float mVisualizationWaveData[256]; |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
|
||||||
virtual bool hasEnded(); |
BusInstance(Bus *aParent); |
||||||
virtual ~BusInstance(); |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
}; |
virtual bool hasEnded(); |
||||||
|
virtual ~BusInstance(); |
||||||
class Bus : public AudioSource |
}; |
||||||
{ |
|
||||||
public: |
class Bus : public AudioSource |
||||||
Bus(); |
{ |
||||||
virtual BusInstance *createInstance(); |
public: |
||||||
// Set filter. Set to NULL to clear the filter.
|
Bus(); |
||||||
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); |
virtual BusInstance *createInstance(); |
||||||
// Play sound through the bus
|
// Set filter. Set to NULL to clear the filter.
|
||||||
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0); |
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); |
||||||
// Play sound through the bus, delayed in relation to other sounds called via this function.
|
// Play sound through the bus
|
||||||
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f); |
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0); |
||||||
// Start playing a 3d audio source through the bus
|
// Play sound through the bus, delayed in relation to other sounds called via this function.
|
||||||
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); |
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f); |
||||||
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
|
// Start playing a 3d audio source through the bus
|
||||||
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); |
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); |
||||||
// Set number of channels for the bus (default 2)
|
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
|
||||||
result setChannels(unsigned int aChannels); |
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); |
||||||
// Enable or disable visualization data gathering
|
// Set number of channels for the bus (default 2)
|
||||||
void setVisualizationEnable(bool aEnable); |
result setChannels(unsigned int aChannels); |
||||||
|
// Enable or disable visualization data gathering
|
||||||
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
|
void setVisualizationEnable(bool aEnable); |
||||||
float *calcFFT(); |
// Move a live sound to this bus
|
||||||
|
void annexSound(handle aVoiceHandle); |
||||||
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
|
|
||||||
float *getWave(); |
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
|
||||||
public: |
float *calcFFT(); |
||||||
BusInstance *mInstance; |
|
||||||
unsigned int mChannelHandle; |
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
|
||||||
// FFT output data
|
float *getWave(); |
||||||
float mFFTData[256]; |
|
||||||
// Snapshot of wave data for visualization
|
// Get approximate volume for output channel for visualization. Visualization has to be enabled before use.
|
||||||
float mWaveData[256]; |
float getApproximateVolume(unsigned int aChannel); |
||||||
// Internal: find the bus' channel
|
|
||||||
void findBusHandle(); |
// 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 |
#endif |
File diff suppressed because it is too large
Load Diff
@ -1,58 +1,58 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_DCREMOVAL_H |
#ifndef SOLOUD_DCREMOVAL_H |
||||||
#define SOLOUD_DCREMOVAL_H |
#define SOLOUD_DCREMOVAL_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class DCRemovalFilter; |
class DCRemovalFilter; |
||||||
|
|
||||||
class DCRemovalFilterInstance : public FilterInstance |
class DCRemovalFilterInstance : public FilterInstance |
||||||
{ |
{ |
||||||
float *mBuffer; |
float *mBuffer; |
||||||
float *mTotals; |
float *mTotals; |
||||||
int mBufferLength; |
int mBufferLength; |
||||||
DCRemovalFilter *mParent; |
DCRemovalFilter *mParent; |
||||||
int mOffset; |
int mOffset; |
||||||
|
|
||||||
public: |
public: |
||||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); |
||||||
virtual ~DCRemovalFilterInstance(); |
virtual ~DCRemovalFilterInstance(); |
||||||
DCRemovalFilterInstance(DCRemovalFilter *aParent); |
DCRemovalFilterInstance(DCRemovalFilter *aParent); |
||||||
}; |
}; |
||||||
|
|
||||||
class DCRemovalFilter : public Filter |
class DCRemovalFilter : public Filter |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
float mLength; |
float mLength; |
||||||
virtual FilterInstance *createInstance(); |
virtual FilterInstance *createInstance(); |
||||||
DCRemovalFilter(); |
DCRemovalFilter(); |
||||||
result setParams(float aLength = 0.1f); |
result setParams(float aLength = 0.1f); |
||||||
}; |
}; |
||||||
} |
} |
||||||
|
|
||||||
#endif |
#endif |
@ -1,59 +1,71 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_ECHOFILTER_H |
#ifndef SOLOUD_ECHOFILTER_H |
||||||
#define SOLOUD_ECHOFILTER_H |
#define SOLOUD_ECHOFILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class EchoFilter; |
class EchoFilter; |
||||||
|
|
||||||
class EchoFilterInstance : public FilterInstance |
class EchoFilterInstance : public FilterInstance |
||||||
{ |
{ |
||||||
float *mBuffer; |
float *mBuffer; |
||||||
int mBufferLength; |
int mBufferLength; |
||||||
EchoFilter *mParent; |
int mBufferMaxLength; |
||||||
int mOffset; |
int mOffset; |
||||||
|
|
||||||
public: |
public: |
||||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); |
||||||
virtual ~EchoFilterInstance(); |
virtual ~EchoFilterInstance(); |
||||||
EchoFilterInstance(EchoFilter *aParent); |
EchoFilterInstance(EchoFilter *aParent); |
||||||
}; |
}; |
||||||
|
|
||||||
class EchoFilter : public Filter |
class EchoFilter : public Filter |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
float mDelay; |
enum FILTERATTRIBUTE |
||||||
float mDecay; |
{ |
||||||
float mFilter; |
WET = 0, |
||||||
virtual FilterInstance *createInstance(); |
DELAY, |
||||||
EchoFilter(); |
DECAY, |
||||||
result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f); |
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 |
#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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2014 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
#ifndef SOLOUD_ERROR_H |
#ifndef SOLOUD_ERROR_H |
||||||
#define SOLOUD_ERROR_H |
#define SOLOUD_ERROR_H |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
enum SOLOUD_ERRORS |
enum SOLOUD_ERRORS |
||||||
{ |
{ |
||||||
SO_NO_ERROR = 0, // No error
|
SO_NO_ERROR = 0, // No error
|
||||||
INVALID_PARAMETER = 1, // Some parameter is invalid
|
INVALID_PARAMETER = 1, // Some parameter is invalid
|
||||||
FILE_NOT_FOUND = 2, // File not found
|
FILE_NOT_FOUND = 2, // File not found
|
||||||
FILE_LOAD_FAILED = 3, // File found, but could not be loaded
|
FILE_LOAD_FAILED = 3, // File found, but could not be loaded
|
||||||
DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL
|
DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL
|
||||||
OUT_OF_MEMORY = 5, // Out of memory
|
OUT_OF_MEMORY = 5, // Out of memory
|
||||||
NOT_IMPLEMENTED = 6, // Feature not implemented
|
NOT_IMPLEMENTED = 6, // Feature not implemented
|
||||||
UNKNOWN_ERROR = 7 // Other error
|
UNKNOWN_ERROR = 7 // Other error
|
||||||
}; |
}; |
||||||
}; |
}; |
||||||
#endif |
#endif |
@ -1,63 +1,63 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2014 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_FADER_H |
#ifndef SOLOUD_FADER_H |
||||||
#define SOLOUD_FADER_H |
#define SOLOUD_FADER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
// Helper class to process faders
|
// Helper class to process faders
|
||||||
class Fader |
class Fader |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
// Value to fade from
|
// Value to fade from
|
||||||
float mFrom; |
float mFrom; |
||||||
// Value to fade to
|
// Value to fade to
|
||||||
float mTo; |
float mTo; |
||||||
// Delta between from and to
|
// Delta between from and to
|
||||||
float mDelta; |
float mDelta; |
||||||
// Total time to fade
|
// Total time to fade
|
||||||
time mTime; |
time mTime; |
||||||
// Time fading started
|
// Time fading started
|
||||||
time mStartTime; |
time mStartTime; |
||||||
// Time fading will end
|
// Time fading will end
|
||||||
time mEndTime; |
time mEndTime; |
||||||
// Current value. Used in case time rolls over.
|
// Current value. Used in case time rolls over.
|
||||||
float mCurrent; |
float mCurrent; |
||||||
// Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped
|
// Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped
|
||||||
int mActive; |
int mActive; |
||||||
// Ctor
|
// Ctor
|
||||||
Fader(); |
Fader(); |
||||||
// Set up LFO
|
// Set up LFO
|
||||||
void setLFO(float aFrom, float aTo, time aTime, time aStartTime); |
void setLFO(float aFrom, float aTo, time aTime, time aStartTime); |
||||||
// Set up fader
|
// Set up fader
|
||||||
void set(float aFrom, float aTo, time aTime, time aStartTime); |
void set(float aFrom, float aTo, time aTime, time aStartTime); |
||||||
// Get the current fading value
|
// Get the current fading value
|
||||||
float get(time aCurrentTime); |
float get(time aCurrentTime); |
||||||
};
|
};
|
||||||
}; |
}; |
||||||
|
|
||||||
#endif |
#endif |
@ -1,45 +1,51 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_FFT_H |
#ifndef SOLOUD_FFT_H |
||||||
#define SOLOUD_FFT_H |
#define SOLOUD_FFT_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
namespace FFT |
namespace FFT |
||||||
{ |
{ |
||||||
// Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten
|
// Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten
|
||||||
void fft1024(float *aBuffer); |
void fft1024(float *aBuffer); |
||||||
|
|
||||||
// Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten
|
// Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten
|
||||||
void fft256(float *aBuffer); |
void fft256(float *aBuffer); |
||||||
|
|
||||||
// Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten
|
// Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten
|
||||||
void ifft256(float *aBuffer); |
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 |
#endif |
@ -1,57 +1,66 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_FFTFILTER_H |
#ifndef SOLOUD_FFTFILTER_H |
||||||
#define SOLOUD_FFTFILTER_H |
#define SOLOUD_FFTFILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class FFTFilter; |
class FFTFilter; |
||||||
|
|
||||||
class FFTFilterInstance : public FilterInstance |
class FFTFilterInstance : public FilterInstance |
||||||
{ |
{ |
||||||
float *mTemp; |
float *mTemp; |
||||||
float *mInputBuffer; |
float *mInputBuffer; |
||||||
float *mMixBuffer; |
float *mMixBuffer; |
||||||
unsigned int mOffset[MAX_CHANNELS]; |
float *mLastPhase; |
||||||
FFTFilter *mParent; |
float *mSumPhase; |
||||||
public: |
unsigned int mInputOffset[MAX_CHANNELS]; |
||||||
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
unsigned int mMixOffset[MAX_CHANNELS]; |
||||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
unsigned int mReadOffset[MAX_CHANNELS]; |
||||||
virtual ~FFTFilterInstance(); |
FFTFilter *mParent; |
||||||
FFTFilterInstance(FFTFilter *aParent); |
public: |
||||||
FFTFilterInstance(); |
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(); |
||||||
class FFTFilter : public Filter |
FFTFilterInstance(FFTFilter *aParent); |
||||||
{ |
FFTFilterInstance(); |
||||||
public: |
void comp2MagPhase(float* aFFTBuffer, unsigned int aSamples); |
||||||
virtual FilterInstance *createInstance(); |
void magPhase2MagFreq(float* aFFTBuffer, unsigned int aSamples, float aSamplerate, unsigned int aChannel); |
||||||
FFTFilter(); |
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 |
#endif |
@ -1,35 +1,36 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
/*
|
/*
|
||||||
See soloud_file_hack_on.h |
See soloud_file_hack_on.h |
||||||
*/ |
*/ |
||||||
|
|
||||||
#undef FILE |
#undef FILE |
||||||
#undef fgetc |
#undef fgetc |
||||||
#undef fread |
#undef fread |
||||||
#undef fseek |
#undef fseek |
||||||
#undef ftell |
#undef ftell |
||||||
#undef fclose |
#undef fclose |
||||||
#undef fopen |
#undef fopen |
||||||
|
#undef fopen_s |
||||||
|
@ -1,58 +1,60 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
/*
|
/*
|
||||||
This is a "hack" header to fool third party code to use our File stuff instead |
This is a "hack" header to fool third party code to use our File stuff instead |
||||||
of stdio FILE* stuff. |
of stdio FILE* stuff. |
||||||
You can use soloud_file_hack_off.h to undef the stuff defined here. |
You can use soloud_file_hack_off.h to undef the stuff defined here. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SEEK_SET |
#ifndef SEEK_SET |
||||||
#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio. |
#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio. |
||||||
#endif |
#endif |
||||||
|
|
||||||
typedef void* Soloud_Filehack; |
typedef void* Soloud_Filehack; |
||||||
|
|
||||||
#ifdef __cplusplus |
#ifdef __cplusplus |
||||||
extern "C" { |
extern "C" { |
||||||
#endif |
#endif |
||||||
|
|
||||||
extern int Soloud_Filehack_fgetc(Soloud_Filehack *f); |
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_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_fseek(Soloud_Filehack *f, int idx, int base); |
||||||
extern int Soloud_Filehack_ftell(Soloud_Filehack *f); |
extern int Soloud_Filehack_ftell(Soloud_Filehack *f); |
||||||
extern int Soloud_Filehack_fclose(Soloud_Filehack *f); |
extern int Soloud_Filehack_fclose(Soloud_Filehack *f); |
||||||
extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode); |
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 |
|
||||||
} |
#ifdef __cplusplus |
||||||
#endif |
} |
||||||
|
#endif |
||||||
#define FILE Soloud_Filehack |
|
||||||
#define fgetc Soloud_Filehack_fgetc |
#define FILE Soloud_Filehack |
||||||
#define fread Soloud_Filehack_fread |
#define fgetc Soloud_Filehack_fgetc |
||||||
#define fseek Soloud_Filehack_fseek |
#define fread Soloud_Filehack_fread |
||||||
#define ftell Soloud_Filehack_ftell |
#define fseek Soloud_Filehack_fseek |
||||||
#define fclose Soloud_Filehack_fclose |
#define ftell Soloud_Filehack_ftell |
||||||
#define fopen Soloud_Filehack_fopen |
#define fclose Soloud_Filehack_fclose |
||||||
|
#define fopen Soloud_Filehack_fopen |
||||||
|
#define fopen_s Soloud_Filehack_fopen_s |
||||||
|
@ -1,64 +1,76 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2014 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_FILTER_H |
#ifndef SOLOUD_FILTER_H |
||||||
#define SOLOUD_FILTER_H |
#define SOLOUD_FILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class Fader; |
class Fader; |
||||||
|
|
||||||
class FilterInstance |
class FilterInstance |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
unsigned int mNumParams; |
unsigned int mNumParams; |
||||||
unsigned int mParamChanged; |
unsigned int mParamChanged; |
||||||
float *mParam; |
float *mParam; |
||||||
Fader *mParamFader; |
Fader *mParamFader; |
||||||
|
|
||||||
|
|
||||||
FilterInstance(); |
FilterInstance(); |
||||||
virtual result initParams(int aNumParams); |
virtual result initParams(int aNumParams); |
||||||
virtual void updateParams(time aTime); |
virtual void updateParams(time aTime); |
||||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); |
||||||
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); |
||||||
virtual float getFilterParameter(unsigned int aAttributeId); |
virtual float getFilterParameter(unsigned int aAttributeId); |
||||||
virtual void setFilterParameter(unsigned int aAttributeId, float aValue); |
virtual void setFilterParameter(unsigned int aAttributeId, float aValue); |
||||||
virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime); |
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 void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime); |
||||||
virtual ~FilterInstance(); |
virtual ~FilterInstance(); |
||||||
}; |
}; |
||||||
|
|
||||||
class Filter |
class Filter |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
Filter(); |
enum PARAMTYPE |
||||||
virtual FilterInstance *createInstance() = 0; |
{ |
||||||
virtual ~Filter(); |
FLOAT_PARAM = 0, |
||||||
}; |
INT_PARAM, |
||||||
}; |
BOOL_PARAM |
||||||
|
}; |
||||||
#endif |
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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_FLANGERFILTER_H |
#ifndef SOLOUD_FLANGERFILTER_H |
||||||
#define SOLOUD_FLANGERFILTER_H |
#define SOLOUD_FLANGERFILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class FlangerFilter; |
class FlangerFilter; |
||||||
|
|
||||||
class FlangerFilterInstance : public FilterInstance |
class FlangerFilterInstance : public FilterInstance |
||||||
{ |
{ |
||||||
float *mBuffer; |
float *mBuffer; |
||||||
int mBufferLength; |
unsigned int mBufferLength; |
||||||
FlangerFilter *mParent; |
FlangerFilter *mParent; |
||||||
int mOffset; |
unsigned int mOffset; |
||||||
double mIndex; |
double mIndex; |
||||||
|
|
||||||
public: |
public: |
||||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); |
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); |
||||||
virtual ~FlangerFilterInstance(); |
virtual ~FlangerFilterInstance(); |
||||||
FlangerFilterInstance(FlangerFilter *aParent); |
FlangerFilterInstance(FlangerFilter *aParent); |
||||||
}; |
}; |
||||||
|
|
||||||
class FlangerFilter : public Filter |
class FlangerFilter : public Filter |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
enum FILTERPARAMS |
enum FILTERPARAMS |
||||||
{ |
{ |
||||||
WET, |
WET, |
||||||
DELAY, |
DELAY, |
||||||
FREQ |
FREQ |
||||||
}; |
}; |
||||||
float mDelay; |
float mDelay; |
||||||
float mFreq; |
float mFreq; |
||||||
virtual FilterInstance *createInstance(); |
virtual int getParamCount(); |
||||||
FlangerFilter(); |
virtual const char* getParamName(unsigned int aParamIndex); |
||||||
result setParams(float aDelay, float aFreq); |
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 |
#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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_INTERNAL_H |
#ifndef SOLOUD_INTERNAL_H |
||||||
#define SOLOUD_INTERNAL_H |
#define SOLOUD_INTERNAL_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
// SDL back-end initialization call
|
// SDL1 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); |
result sdl1_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||||
|
|
||||||
// SDL "non-dynamic" back-end initialization call
|
// SDL2 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); |
result sdl2_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
|
// SDL1 "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); |
result sdl1static_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
|
// SDL2 "non-dynamic" 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); |
result sdl2static_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
|
// OpenAL 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); |
result openal_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
|
// Core Audio driver 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); |
result coreaudio_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
|
// OpenSL ES 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); |
result opensles_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
|
// PortAudio 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); |
result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||||
|
|
||||||
// XAudio2 back-end initialization call
|
// WinMM 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); |
result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); |
||||||
|
|
||||||
// WASAPI back-end initialization call
|
// XAudio2 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); |
result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||||
|
|
||||||
// OSS back-end initialization call
|
// WASAPI 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); |
result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); |
||||||
|
|
||||||
// PS Vita homebrew back-end initialization call
|
// OSS 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); |
result oss_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
|
// PS Vita homebrew 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); |
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); |
||||||
|
|
||||||
// null driver back-end initialization call
|
// ALSA 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); |
result alsa_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
|
// JACK back-end initialization call
|
||||||
void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); |
result jack_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
|
// MiniAudio back-end initialization call
|
||||||
void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); |
result miniaudio_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||||
|
|
||||||
// Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212
|
// nosound back-end initialization call
|
||||||
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels); |
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
|
||||||
#define FOR_ALL_VOICES_PRE \ |
result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); |
||||||
handle *h_ = NULL; \
|
|
||||||
handle th_[2] = { aVoiceHandle, 0 }; \
|
// Interlace samples in a buffer. From 11112222 to 12121212
|
||||||
lockAudioMutex(); \
|
void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels, unsigned int aStride); |
||||||
h_ = voiceGroupHandleToArray(aVoiceHandle); \
|
|
||||||
if (h_ == NULL) h_ = th_; \
|
// Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212
|
||||||
while (*h_) \
|
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels, unsigned int aStride); |
||||||
{ \
|
}; |
||||||
int ch = getVoiceFromHandle(*h_); \
|
|
||||||
if (ch != -1) \
|
#define FOR_ALL_VOICES_PRE \ |
||||||
{ |
handle *h_ = NULL; \
|
||||||
|
handle th_[2] = { aVoiceHandle, 0 }; \
|
||||||
#define FOR_ALL_VOICES_POST \ |
lockAudioMutex_internal(); \
|
||||||
} \
|
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
|
||||||
h_++; \
|
if (h_ == NULL) h_ = th_; \
|
||||||
} \
|
while (*h_) \
|
||||||
unlockAudioMutex(); |
{ \
|
||||||
|
int ch = getVoiceFromHandle_internal(*h_); \
|
||||||
#define FOR_ALL_VOICES_PRE_3D \ |
if (ch != -1) \
|
||||||
handle *h_ = NULL; \
|
{ |
||||||
handle th_[2] = { aVoiceHandle, 0 }; \
|
|
||||||
h_ = voiceGroupHandleToArray(aVoiceHandle); \
|
#define FOR_ALL_VOICES_POST \ |
||||||
if (h_ == NULL) h_ = th_; \
|
} \
|
||||||
while (*h_) \
|
h_++; \
|
||||||
{ \
|
} \
|
||||||
int ch = (*h_ & 0xfff) - 1; \
|
unlockAudioMutex_internal(); |
||||||
if (ch != -1 && m3dData[ch].mHandle == *h_) \
|
|
||||||
{ |
#define FOR_ALL_VOICES_PRE_3D \ |
||||||
|
handle *h_ = NULL; \
|
||||||
#define FOR_ALL_VOICES_POST_3D \ |
handle th_[2] = { aVoiceHandle, 0 }; \
|
||||||
} \
|
h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \
|
||||||
h_++; \
|
if (h_ == NULL) h_ = th_; \
|
||||||
}
|
while (*h_) \
|
||||||
|
{ \
|
||||||
#endif |
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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_LOFIFILTER_H |
#ifndef SOLOUD_LOFIFILTER_H |
||||||
#define SOLOUD_LOFIFILTER_H |
#define SOLOUD_LOFIFILTER_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class LofiFilter; |
class LofiFilter; |
||||||
|
|
||||||
struct LofiChannelData |
struct LofiChannelData |
||||||
{ |
{ |
||||||
float mSample; |
float mSample; |
||||||
float mSamplesToSkip; |
float mSamplesToSkip; |
||||||
}; |
}; |
||||||
|
|
||||||
class LofiFilterInstance : public FilterInstance |
class LofiFilterInstance : public FilterInstance |
||||||
{ |
{ |
||||||
enum FILTERPARAMS |
enum FILTERPARAMS |
||||||
{ |
{ |
||||||
WET, |
WET, |
||||||
SAMPLERATE, |
SAMPLERATE, |
||||||
BITDEPTH |
BITDEPTH |
||||||
}; |
}; |
||||||
LofiChannelData mChannelData[2]; |
LofiChannelData mChannelData[2]; |
||||||
|
|
||||||
LofiFilter *mParent; |
LofiFilter *mParent; |
||||||
public: |
public: |
||||||
virtual void filterChannel(float *aBuffer, 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 ~LofiFilterInstance(); |
virtual ~LofiFilterInstance(); |
||||||
LofiFilterInstance(LofiFilter *aParent); |
LofiFilterInstance(LofiFilter *aParent); |
||||||
}; |
}; |
||||||
|
|
||||||
class LofiFilter : public Filter |
class LofiFilter : public Filter |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
enum FILTERPARAMS |
enum FILTERPARAMS |
||||||
{ |
{ |
||||||
WET, |
WET, |
||||||
SAMPLERATE, |
SAMPLERATE, |
||||||
BITDEPTH |
BITDEPTH |
||||||
}; |
}; |
||||||
float mSampleRate; |
float mSampleRate; |
||||||
float mBitdepth; |
float mBitdepth; |
||||||
virtual LofiFilterInstance *createInstance(); |
virtual LofiFilterInstance *createInstance(); |
||||||
LofiFilter(); |
virtual int getParamCount(); |
||||||
result setParams(float aSampleRate, float aBitdepth); |
virtual const char* getParamName(unsigned int aParamIndex); |
||||||
virtual ~LofiFilter(); |
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 |
#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 |
MONOTONE module for SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2020 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef MONOTONE_H |
#ifndef MONOTONE_H |
||||||
#define MONOTONE_H |
#define MONOTONE_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
#include "soloud_misc.h" |
||||||
namespace SoLoud |
|
||||||
{ |
namespace SoLoud |
||||||
class Monotone; |
{ |
||||||
class File; |
class Monotone; |
||||||
|
class File; |
||||||
struct MonotoneSong |
|
||||||
{ |
struct MonotoneSong |
||||||
char *mTitle; |
{ |
||||||
char *mComment; |
char *mTitle; |
||||||
unsigned char mVersion; // must be 1
|
char *mComment; |
||||||
unsigned char mTotalPatterns; |
unsigned char mVersion; // must be 1
|
||||||
unsigned char mTotalTracks; |
unsigned char mTotalPatterns; |
||||||
unsigned char mCellSize; // must be 2 for version 1
|
unsigned char mTotalTracks; |
||||||
unsigned char mOrder[256]; |
unsigned char mCellSize; // must be 2 for version 1
|
||||||
unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks
|
unsigned char mOrder[256]; |
||||||
}; |
unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks
|
||||||
|
}; |
||||||
struct MonotoneChannel |
|
||||||
{ |
struct MonotoneChannel |
||||||
int mEnabled;
|
{ |
||||||
int mActive; |
int mEnabled;
|
||||||
int mFreq[3]; |
int mActive; |
||||||
int mPortamento; |
int mFreq[3]; |
||||||
int mArpCounter; |
int mPortamento; |
||||||
int mArp; |
int mArpCounter; |
||||||
int mLastNote; |
int mArp; |
||||||
int mPortamentoToNote; |
int mLastNote; |
||||||
int mVibrato; |
int mPortamentoToNote; |
||||||
int mVibratoIndex; |
int mVibrato; |
||||||
int mVibratoDepth; |
int mVibratoIndex; |
||||||
int mVibratoSpeed; |
int mVibratoDepth; |
||||||
}; |
int mVibratoSpeed; |
||||||
|
}; |
||||||
struct MonotoneHardwareChannel |
|
||||||
{ |
struct MonotoneHardwareChannel |
||||||
int mEnabled; |
{ |
||||||
float mSamplePos; |
int mEnabled; |
||||||
float mSamplePosInc; |
float mSamplePos; |
||||||
}; |
float mSamplePosInc; |
||||||
|
}; |
||||||
class MonotoneInstance : public AudioSourceInstance |
|
||||||
{ |
class MonotoneInstance : public AudioSourceInstance |
||||||
Monotone *mParent;
|
{ |
||||||
public: |
Monotone *mParent;
|
||||||
MonotoneChannel mChannel[12]; |
public: |
||||||
MonotoneHardwareChannel mOutput[12]; |
MonotoneChannel mChannel[12]; |
||||||
int mNextChannel; |
MonotoneHardwareChannel mOutput[12]; |
||||||
int mTempo; // ticks / row. Tick = 60hz. Default 4.
|
int mNextChannel; |
||||||
int mOrder; |
int mTempo; // ticks / row. Tick = 60hz. Default 4.
|
||||||
int mRow; |
int mOrder; |
||||||
int mSampleCount; |
int mRow; |
||||||
int mRowTick; |
int mSampleCount; |
||||||
|
int mRowTick; |
||||||
MonotoneInstance(Monotone *aParent); |
|
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
MonotoneInstance(Monotone *aParent); |
||||||
virtual bool hasEnded(); |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize); |
||||||
}; |
virtual bool hasEnded(); |
||||||
|
}; |
||||||
class Monotone : public AudioSource |
|
||||||
{ |
class Monotone : public AudioSource |
||||||
public: |
{ |
||||||
enum MONOTONE_WAVEFORMS |
public: |
||||||
{ |
|
||||||
SQUARE = 0, |
int mNotesHz[800]; |
||||||
SAW = 1, |
int mVibTable[32]; |
||||||
SIN = 2, |
int mHardwareChannels; |
||||||
SAWSIN = 3 |
int mWaveform; |
||||||
}; |
MonotoneSong mSong; |
||||||
|
Monotone(); |
||||||
int mNotesHz[800]; |
~Monotone(); |
||||||
int mVibTable[32]; |
result setParams(int aHardwareChannels, int aWaveform = Soloud::WAVE_SQUARE); |
||||||
int mHardwareChannels; |
result load(const char *aFilename); |
||||||
int mWaveform; |
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||||
MonotoneSong mSong; |
result loadFile(File *aFile); |
||||||
Monotone(); |
virtual AudioSourceInstance *createInstance(); |
||||||
~Monotone(); |
public: |
||||||
result setParams(int aHardwareChannels, int aWaveform = SQUARE); |
void clear(); |
||||||
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(); |
|
||||||
}; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif |
#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 |
Openmpt module for SoLoud audio engine |
||||||
Copyright (c) 2016 Jari Komppa |
Copyright (c) 2016 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef OPENMPT_H |
#ifndef OPENMPT_H |
||||||
#define OPENMPT_H |
#define OPENMPT_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class Openmpt; |
class Openmpt; |
||||||
class File; |
class File; |
||||||
|
|
||||||
class OpenmptInstance : public AudioSourceInstance |
class OpenmptInstance : public AudioSourceInstance |
||||||
{ |
{ |
||||||
Openmpt *mParent; |
Openmpt *mParent; |
||||||
void *mModfile; |
void *mModfile; |
||||||
int mPlaying; |
int mPlaying; |
||||||
|
|
||||||
public: |
public: |
||||||
OpenmptInstance(Openmpt *aParent); |
OpenmptInstance(Openmpt *aParent); |
||||||
virtual ~OpenmptInstance(); |
virtual ~OpenmptInstance(); |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
virtual bool hasEnded(); |
virtual bool hasEnded(); |
||||||
}; |
}; |
||||||
|
|
||||||
class Openmpt : public AudioSource |
class Openmpt : public AudioSource |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
char *mData; |
char *mData; |
||||||
unsigned int mDataLen; |
unsigned int mDataLen; |
||||||
Openmpt(); |
Openmpt(); |
||||||
virtual ~Openmpt(); |
virtual ~Openmpt(); |
||||||
result load(const char* aFilename); |
result load(const char* aFilename); |
||||||
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||||
result loadFile(File *aFile); |
result loadFile(File *aFile); |
||||||
virtual AudioSourceInstance *createInstance(); |
virtual AudioSourceInstance *createInstance(); |
||||||
}; |
}; |
||||||
}; |
}; |
||||||
|
|
||||||
#endif |
#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 |
SFXR module for SoLoud audio engine |
||||||
Copyright (c) 2014 Jari Komppa |
Copyright (c) 2014 Jari Komppa |
||||||
Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission |
Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SFXR_H |
#ifndef SFXR_H |
||||||
#define SFXR_H |
#define SFXR_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
#include "soloud_misc.h" |
||||||
namespace SoLoud |
|
||||||
{ |
namespace SoLoud |
||||||
class File; |
{ |
||||||
|
class File; |
||||||
class Prg |
|
||||||
{ |
struct SfxrParams |
||||||
public: |
{ |
||||||
// random generator
|
int wave_type; |
||||||
Prg(); |
|
||||||
unsigned int state[16]; |
float p_base_freq; |
||||||
unsigned int index; |
float p_freq_limit; |
||||||
unsigned int rand(); |
float p_freq_ramp; |
||||||
void srand(int aSeed); |
float p_freq_dramp; |
||||||
}; |
float p_duty; |
||||||
|
float p_duty_ramp; |
||||||
struct SfxrParams |
|
||||||
{ |
float p_vib_strength; |
||||||
int wave_type; |
float p_vib_speed; |
||||||
|
float p_vib_delay; |
||||||
float p_base_freq; |
|
||||||
float p_freq_limit; |
float p_env_attack; |
||||||
float p_freq_ramp; |
float p_env_sustain; |
||||||
float p_freq_dramp; |
float p_env_decay; |
||||||
float p_duty; |
float p_env_punch; |
||||||
float p_duty_ramp; |
|
||||||
|
bool filter_on; |
||||||
float p_vib_strength; |
float p_lpf_resonance; |
||||||
float p_vib_speed; |
float p_lpf_freq; |
||||||
float p_vib_delay; |
float p_lpf_ramp; |
||||||
|
float p_hpf_freq; |
||||||
float p_env_attack; |
float p_hpf_ramp; |
||||||
float p_env_sustain; |
|
||||||
float p_env_decay; |
float p_pha_offset; |
||||||
float p_env_punch; |
float p_pha_ramp; |
||||||
|
|
||||||
bool filter_on; |
float p_repeat_speed; |
||||||
float p_lpf_resonance; |
|
||||||
float p_lpf_freq; |
float p_arp_speed; |
||||||
float p_lpf_ramp; |
float p_arp_mod; |
||||||
float p_hpf_freq; |
|
||||||
float p_hpf_ramp; |
float master_vol; |
||||||
|
|
||||||
float p_pha_offset; |
float sound_vol; |
||||||
float p_pha_ramp; |
}; |
||||||
|
|
||||||
float p_repeat_speed; |
class Sfxr; |
||||||
|
|
||||||
float p_arp_speed; |
class SfxrInstance : public AudioSourceInstance |
||||||
float p_arp_mod; |
{ |
||||||
|
Sfxr *mParent; |
||||||
float master_vol; |
|
||||||
|
Misc::Prg mRand; |
||||||
float sound_vol; |
SfxrParams mParams; |
||||||
}; |
|
||||||
|
bool playing_sample; |
||||||
class Sfxr; |
int phase; |
||||||
|
double fperiod; |
||||||
class SfxrInstance : public AudioSourceInstance |
double fmaxperiod; |
||||||
{ |
double fslide; |
||||||
Sfxr *mParent; |
double fdslide; |
||||||
|
int period; |
||||||
Prg mRand; |
float square_duty; |
||||||
SfxrParams mParams; |
float square_slide; |
||||||
|
int env_stage; |
||||||
bool playing_sample; |
int env_time; |
||||||
int phase; |
int env_length[3]; |
||||||
double fperiod; |
float env_vol; |
||||||
double fmaxperiod; |
float fphase; |
||||||
double fslide; |
float fdphase; |
||||||
double fdslide; |
int iphase; |
||||||
int period; |
float phaser_buffer[1024]; |
||||||
float square_duty; |
int ipp; |
||||||
float square_slide; |
float noise_buffer[32]; |
||||||
int env_stage; |
float fltp; |
||||||
int env_time; |
float fltdp; |
||||||
int env_length[3]; |
float fltw; |
||||||
float env_vol; |
float fltw_d; |
||||||
float fphase; |
float fltdmp; |
||||||
float fdphase; |
float fltphp; |
||||||
int iphase; |
float flthp; |
||||||
float phaser_buffer[1024]; |
float flthp_d; |
||||||
int ipp; |
float vib_phase; |
||||||
float noise_buffer[32]; |
float vib_speed; |
||||||
float fltp; |
float vib_amp; |
||||||
float fltdp; |
int rep_time; |
||||||
float fltw; |
int rep_limit; |
||||||
float fltw_d; |
int arp_time; |
||||||
float fltdmp; |
int arp_limit; |
||||||
float fltphp; |
double arp_mod; |
||||||
float flthp; |
|
||||||
float flthp_d; |
void resetSample(bool aRestart); |
||||||
float vib_phase; |
|
||||||
float vib_speed; |
public: |
||||||
float vib_amp; |
SfxrInstance(Sfxr *aParent); |
||||||
int rep_time; |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
int rep_limit; |
virtual bool hasEnded(); |
||||||
int arp_time; |
}; |
||||||
int arp_limit; |
|
||||||
double arp_mod; |
class Sfxr : public AudioSource |
||||||
|
{ |
||||||
void resetSample(bool aRestart); |
public: |
||||||
|
SfxrParams mParams; |
||||||
public: |
|
||||||
SfxrInstance(Sfxr *aParent); |
enum SFXR_PRESETS
|
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
{ |
||||||
virtual bool hasEnded(); |
COIN, |
||||||
}; |
LASER, |
||||||
|
EXPLOSION, |
||||||
class Sfxr : public AudioSource |
POWERUP, |
||||||
{ |
HURT, |
||||||
public: |
JUMP, |
||||||
SfxrParams mParams; |
BLIP |
||||||
|
}; |
||||||
enum SFXR_PRESETS
|
|
||||||
{ |
Misc::Prg mRand; |
||||||
COIN, |
|
||||||
LASER, |
Sfxr(); |
||||||
EXPLOSION, |
virtual ~Sfxr(); |
||||||
POWERUP, |
void resetParams(); |
||||||
HURT, |
result loadParams(const char* aFilename); |
||||||
JUMP, |
result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||||
BLIP |
result loadParamsFile(File *aFile); |
||||||
}; |
|
||||||
|
result loadPreset(int aPresetNo, int aRandSeed); |
||||||
Prg mRand; |
virtual AudioSourceInstance *createInstance(); |
||||||
|
}; |
||||||
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 |
#endif |
@ -1,63 +1,79 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
#ifndef SOLOUD_SPEECH_H |
#ifndef SOLOUD_SPEECH_H |
||||||
#define SOLOUD_SPEECH_H |
#define SOLOUD_SPEECH_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
#include "../src/audiosource/speech/darray.h" |
#include "../src/audiosource/speech/darray.h" |
||||||
#include "../src/audiosource/speech/klatt.h" |
#include "../src/audiosource/speech/klatt.h" |
||||||
#include "../src/audiosource/speech/tts.h" |
#include "../src/audiosource/speech/tts.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class Speech; |
class Speech; |
||||||
|
|
||||||
class Speech : public AudioSource |
class Speech : public AudioSource |
||||||
{ |
{ |
||||||
public: |
// copy of the enum in klatt.h for codegen purposes
|
||||||
int mFrames; |
enum KLATT_WAVEFORM |
||||||
darray mElement; |
{ |
||||||
Speech(); |
KW_SAW, |
||||||
result setText(const char *aText); |
KW_TRIANGLE, |
||||||
virtual ~Speech(); |
KW_SIN, |
||||||
virtual AudioSourceInstance *createInstance(); |
KW_SQUARE, |
||||||
}; |
KW_PULSE, |
||||||
|
KW_NOISE, |
||||||
class SpeechInstance : public AudioSourceInstance |
KW_WARBLE |
||||||
{ |
}; |
||||||
klatt mSynth; |
public: |
||||||
Speech *mParent; |
int mBaseFrequency; |
||||||
short *mSample; |
float mBaseSpeed; |
||||||
int mSampleCount; |
float mBaseDeclination; |
||||||
int mOffset; |
int mBaseWaveform; |
||||||
public: |
int mFrames; |
||||||
SpeechInstance(Speech *aParent); |
darray mElement; |
||||||
virtual ~SpeechInstance(); |
Speech(); |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
result setText(const char *aText); |
||||||
virtual result rewind(); |
result setParams(unsigned int aBaseFrequency = 1330, float aBaseSpeed = 10.0f, float aBaseDeclination = 0.5f, int aBaseWaveform = KW_TRIANGLE); |
||||||
virtual bool hasEnded(); |
virtual ~Speech(); |
||||||
}; |
virtual AudioSourceInstance *createInstance(); |
||||||
}; |
}; |
||||||
|
|
||||||
#endif |
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 |
TED/SID module for SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2015 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef TEDSID_H |
#ifndef TEDSID_H |
||||||
#define TEDSID_H |
#define TEDSID_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
class SIDsound; |
class SIDsound; |
||||||
class TED; |
class TED; |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class TedSid; |
class TedSid; |
||||||
class File; |
class File; |
||||||
|
|
||||||
class TedSidInstance : public AudioSourceInstance |
class TedSidInstance : public AudioSourceInstance |
||||||
{ |
{ |
||||||
TedSid *mParent;
|
TedSid *mParent;
|
||||||
SIDsound *mSID; |
SIDsound *mSID; |
||||||
TED *mTED; |
TED *mTED; |
||||||
unsigned int mSampleCount; |
int mPos; |
||||||
int mNextReg; |
unsigned int mSampleCount; |
||||||
int mNextVal; |
int mRegValues[128]; |
||||||
int mRegValues[128]; |
public: |
||||||
public: |
|
||||||
|
TedSidInstance(TedSid *aParent); |
||||||
TedSidInstance(TedSid *aParent); |
~TedSidInstance(); |
||||||
~TedSidInstance(); |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
virtual void tick(); |
||||||
virtual void tick(); |
virtual bool hasEnded(); |
||||||
virtual bool hasEnded(); |
virtual float getInfo(unsigned int aInfoKey); |
||||||
virtual float getInfo(unsigned int aInfoKey); |
}; |
||||||
}; |
|
||||||
|
class TedSid : public AudioSource |
||||||
class TedSid : public AudioSource |
{ |
||||||
{ |
public: |
||||||
public: |
int mLooppos; |
||||||
File *mFile; |
int mLength; |
||||||
int mModel; |
unsigned short* mOps; |
||||||
bool mFileOwned; |
int mModel; |
||||||
TedSid(); |
TedSid(); |
||||||
~TedSid(); |
~TedSid(); |
||||||
result load(const char *aFilename); |
result load(const char *aFilename); |
||||||
result loadToMem(const char *aFilename); |
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||||
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
result loadFile(File *aFile); |
||||||
result loadFileToMem(File *aFile); |
virtual AudioSourceInstance *createInstance(); |
||||||
result loadFile(File *aFile); |
}; |
||||||
virtual AudioSourceInstance *createInstance(); |
}; |
||||||
}; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif |
#endif |
@ -1,83 +1,84 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2013-2014 Jari Komppa |
Copyright (c) 2013-2014 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_THREAD_H |
#ifndef SOLOUD_THREAD_H |
||||||
#define SOLOUD_THREAD_H |
#define SOLOUD_THREAD_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
namespace Thread |
namespace Thread |
||||||
{ |
{ |
||||||
typedef void (*threadFunction)(void *aParam); |
typedef void (*threadFunction)(void *aParam); |
||||||
|
|
||||||
struct ThreadHandleData; |
struct ThreadHandleData; |
||||||
typedef ThreadHandleData* ThreadHandle; |
typedef ThreadHandleData* ThreadHandle; |
||||||
|
|
||||||
void * createMutex(); |
void * createMutex(); |
||||||
void destroyMutex(void *aHandle); |
void destroyMutex(void *aHandle); |
||||||
void lockMutex(void *aHandle); |
void lockMutex(void *aHandle); |
||||||
void unlockMutex(void *aHandle); |
void unlockMutex(void *aHandle); |
||||||
|
|
||||||
ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter); |
ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter); |
||||||
|
|
||||||
void sleep(int aMSec); |
void sleep(int aMSec); |
||||||
void wait(ThreadHandle aThreadHandle); |
void wait(ThreadHandle aThreadHandle); |
||||||
void release(ThreadHandle aThreadHandle); |
void release(ThreadHandle aThreadHandle); |
||||||
|
int getTimeMillis(); |
||||||
#define MAX_THREADPOOL_TASKS 1024 |
|
||||||
|
#define MAX_THREADPOOL_TASKS 1024 |
||||||
class PoolTask |
|
||||||
{ |
class PoolTask |
||||||
public: |
{ |
||||||
virtual void work() = 0; |
public: |
||||||
}; |
virtual void work() = 0; |
||||||
|
}; |
||||||
class Pool |
|
||||||
{ |
class Pool |
||||||
public: |
{ |
||||||
// Initialize and run thread pool. For thread count 0, work is done at addWork call.
|
public: |
||||||
void init(int aThreadCount); |
// Initialize and run thread pool. For thread count 0, work is done at addWork call.
|
||||||
// Ctor, sets known state
|
void init(int aThreadCount); |
||||||
Pool(); |
// Ctor, sets known state
|
||||||
// Dtor. Waits for the threads to finish. Work may be unfinished.
|
Pool(); |
||||||
~Pool(); |
// Dtor. Waits for the threads to finish. Work may be unfinished.
|
||||||
// Add work to work list. Object is not automatically deleted when work is done.
|
~Pool(); |
||||||
void addWork(PoolTask *aTask); |
// Add work to work list. Object is not automatically deleted when work is done.
|
||||||
// Called from worker thread to get a new task. Returns null if no work available.
|
void addWork(PoolTask *aTask); |
||||||
PoolTask *getWork(); |
// Called from worker thread to get a new task. Returns null if no work available.
|
||||||
public: |
PoolTask *getWork(); |
||||||
int mThreadCount; // number of threads
|
public: |
||||||
ThreadHandle *mThread; // array of thread handles
|
int mThreadCount; // number of threads
|
||||||
void *mWorkMutex; // mutex to protect task array/maxtask
|
ThreadHandle *mThread; // array of thread handles
|
||||||
PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks
|
void *mWorkMutex; // mutex to protect task array/maxtask
|
||||||
int mMaxTask; // how many tasks are pending
|
PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks
|
||||||
int mRobin; // cyclic counter, used to pick jobs for threads
|
int mMaxTask; // how many tasks are pending
|
||||||
volatile int mRunning; // running flag, used to flag threads to stop
|
int mRobin; // cyclic counter, used to pick jobs for threads
|
||||||
}; |
volatile int mRunning; // running flag, used to flag threads to stop
|
||||||
} |
}; |
||||||
} |
} |
||||||
|
} |
||||||
|
|
||||||
#endif |
#endif |
@ -1,108 +1,108 @@ |
|||||||
/*
|
/*
|
||||||
SoLoud audio engine |
SoLoud audio engine |
||||||
Copyright (c) 2015 Jari Komppa |
Copyright (c) 2015 Jari Komppa |
||||||
|
|
||||||
VIC 6560/6561 sound chip emulator |
VIC 6560/6561 sound chip emulator |
||||||
Copyright (c) 2015 Petri Hakkinen |
Copyright (c) 2015 Petri Hakkinen |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_VIC_H |
#ifndef SOLOUD_VIC_H |
||||||
#define SOLOUD_VIC_H |
#define SOLOUD_VIC_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
/*
|
/*
|
||||||
A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models. |
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. |
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 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 highest bit of each oscillator register switches the oscillator on/off. |
||||||
The fourth oscillator generates a noise waveform. |
The fourth oscillator generates a noise waveform. |
||||||
|
|
||||||
VIC-20 does not have per channel volume control, only global volume, |
VIC-20 does not have per channel volume control, only global volume, |
||||||
which you can change by setting audio source's 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 |
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. |
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0. |
||||||
*/ |
*/ |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class Vic; |
class Vic; |
||||||
|
|
||||||
class VicInstance : public AudioSourceInstance |
class VicInstance : public AudioSourceInstance |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
VicInstance(Vic *aParent); |
VicInstance(Vic *aParent); |
||||||
~VicInstance(); |
~VicInstance(); |
||||||
|
|
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
virtual bool hasEnded(); |
virtual bool hasEnded(); |
||||||
|
|
||||||
private: |
public: |
||||||
Vic* m_parent; |
Vic* m_parent; |
||||||
unsigned int m_phase[4]; |
unsigned int m_phase[4]; |
||||||
unsigned int m_noisePos; |
unsigned int m_noisePos; |
||||||
}; |
}; |
||||||
|
|
||||||
class Vic : public AudioSource |
class Vic : public AudioSource |
||||||
{ |
{ |
||||||
public: |
public: |
||||||
// VIC model
|
// VIC model
|
||||||
enum |
enum |
||||||
{ |
{ |
||||||
PAL = 0, |
PAL = 0, |
||||||
NTSC, |
NTSC |
||||||
}; |
}; |
||||||
|
|
||||||
// VIC sound registers
|
// VIC sound registers
|
||||||
enum |
enum |
||||||
{ |
{ |
||||||
BASS = 0, |
BASS = 0, |
||||||
ALTO, |
ALTO, |
||||||
SOPRANO, |
SOPRANO, |
||||||
NOISE, |
NOISE, |
||||||
MAX_REGS |
MAX_REGS |
||||||
}; |
}; |
||||||
|
|
||||||
Vic(); |
Vic(); |
||||||
virtual ~Vic(); |
|
||||||
|
virtual ~Vic(); |
||||||
void setModel(int model); |
|
||||||
int getModel() const; |
void setModel(int model); |
||||||
|
|
||||||
void setRegister(int reg, unsigned char value) { m_regs[reg] = value; } |
int getModel() const; |
||||||
unsigned char getRegister(int reg) const { return m_regs[reg]; } |
|
||||||
|
void setRegister(int reg, unsigned char value); |
||||||
virtual AudioSourceInstance *createInstance(); |
|
||||||
|
unsigned char getRegister(int reg); |
||||||
private: |
|
||||||
friend class VicInstance; |
public: |
||||||
|
virtual AudioSourceInstance *createInstance(); |
||||||
int m_model; |
int m_model; |
||||||
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
|
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
|
||||||
unsigned char m_regs[MAX_REGS];
|
unsigned char m_regs[MAX_REGS];
|
||||||
unsigned char m_noise[8192]; |
unsigned char m_noise[8192]; |
||||||
}; |
}; |
||||||
}; |
}; |
||||||
|
|
||||||
#endif |
#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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2018 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_WAV_H |
#ifndef SOLOUD_WAV_H |
||||||
#define SOLOUD_WAV_H |
#define SOLOUD_WAV_H |
||||||
|
|
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
struct stb_vorbis; |
struct stb_vorbis; |
||||||
|
|
||||||
namespace SoLoud |
namespace SoLoud |
||||||
{ |
{ |
||||||
class Wav; |
class Wav; |
||||||
class File; |
class File; |
||||||
|
class MemoryFile; |
||||||
class WavInstance : public AudioSourceInstance |
|
||||||
{ |
class WavInstance : public AudioSourceInstance |
||||||
Wav *mParent; |
{ |
||||||
unsigned int mOffset; |
Wav *mParent; |
||||||
public: |
unsigned int mOffset; |
||||||
WavInstance(Wav *aParent); |
public: |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
WavInstance(Wav *aParent); |
||||||
virtual result rewind(); |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
virtual bool hasEnded(); |
virtual result rewind(); |
||||||
}; |
virtual bool hasEnded(); |
||||||
|
}; |
||||||
class Wav : public AudioSource |
|
||||||
{ |
class Wav : public AudioSource |
||||||
result loadwav(File *aReader); |
{ |
||||||
result loadogg(File *aReader); |
result loadwav(MemoryFile *aReader); |
||||||
result testAndLoadFile(File *aReader); |
result loadogg(MemoryFile *aReader); |
||||||
public: |
result loadmp3(MemoryFile *aReader); |
||||||
float *mData; |
result loadflac(MemoryFile *aReader); |
||||||
unsigned int mSampleCount; |
result testAndLoadFile(MemoryFile *aReader); |
||||||
|
public: |
||||||
Wav(); |
float *mData; |
||||||
virtual ~Wav(); |
unsigned int mSampleCount; |
||||||
result load(const char *aFilename); |
|
||||||
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
Wav(); |
||||||
result loadFile(File *aFile); |
virtual ~Wav(); |
||||||
|
result load(const char *aFilename); |
||||||
virtual AudioSourceInstance *createInstance(); |
result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); |
||||||
time getLength(); |
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); |
||||||
#endif |
|
||||||
|
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 |
SoLoud audio engine |
||||||
Copyright (c) 2013-2015 Jari Komppa |
Copyright (c) 2013-2018 Jari Komppa |
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied |
This software is provided 'as-is', without any express or implied |
||||||
warranty. In no event will the authors be held liable for any damages |
warranty. In no event will the authors be held liable for any damages |
||||||
arising from the use of this software. |
arising from the use of this software. |
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose, |
Permission is granted to anyone to use this software for any purpose, |
||||||
including commercial applications, and to alter it and redistribute it |
including commercial applications, and to alter it and redistribute it |
||||||
freely, subject to the following restrictions: |
freely, subject to the following restrictions: |
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not |
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 |
claim that you wrote the original software. If you use this software |
||||||
in a product, an acknowledgment in the product documentation would be |
in a product, an acknowledgment in the product documentation would be |
||||||
appreciated but is not required. |
appreciated but is not required. |
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be |
2. Altered source versions must be plainly marked as such, and must not be |
||||||
misrepresented as being the original software. |
misrepresented as being the original software. |
||||||
|
|
||||||
3. This notice may not be removed or altered from any source |
3. This notice may not be removed or altered from any source |
||||||
distribution. |
distribution. |
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef SOLOUD_WAVSTREAM_H |
#ifndef SOLOUD_WAVSTREAM_H |
||||||
#define SOLOUD_WAVSTREAM_H |
#define SOLOUD_WAVSTREAM_H |
||||||
|
|
||||||
#include <stdio.h> |
#include <stdio.h> |
||||||
#include "soloud.h" |
#include "soloud.h" |
||||||
|
|
||||||
|
struct stb_vorbis; |
||||||
struct stb_vorbis; |
#ifndef dr_flac_h |
||||||
|
struct drflac; |
||||||
namespace SoLoud |
#endif |
||||||
{ |
#ifndef dr_mp3_h |
||||||
class WavStream; |
struct drmp3; |
||||||
class File; |
#endif |
||||||
|
#ifndef dr_wav_h |
||||||
class WavStreamInstance : public AudioSourceInstance |
struct drwav; |
||||||
{ |
#endif |
||||||
WavStream *mParent; |
|
||||||
unsigned int mOffset; |
namespace SoLoud |
||||||
File *mFile; |
{ |
||||||
stb_vorbis *mOgg; |
class WavStream; |
||||||
unsigned int mOggFrameSize; |
class File; |
||||||
unsigned int mOggFrameOffset; |
|
||||||
float **mOggOutputs; |
class WavStreamInstance : public AudioSourceInstance |
||||||
public: |
{ |
||||||
WavStreamInstance(WavStream *aParent); |
WavStream *mParent; |
||||||
virtual void getAudio(float *aBuffer, unsigned int aSamples); |
unsigned int mOffset; |
||||||
virtual result rewind(); |
File *mFile; |
||||||
virtual bool hasEnded(); |
union codec |
||||||
virtual ~WavStreamInstance(); |
{ |
||||||
}; |
stb_vorbis *mOgg; |
||||||
|
drflac *mFlac; |
||||||
class WavStream : public AudioSource |
drmp3 *mMp3; |
||||||
{ |
drwav *mWav; |
||||||
result loadwav(File * fp); |
} mCodec; |
||||||
result loadogg(File * fp); |
unsigned int mOggFrameSize; |
||||||
public: |
unsigned int mOggFrameOffset; |
||||||
int mOgg; |
float **mOggOutputs; |
||||||
char *mFilename; |
public: |
||||||
File *mMemFile; |
WavStreamInstance(WavStream *aParent); |
||||||
File *mStreamFile; |
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); |
||||||
unsigned int mDataOffset; |
virtual result rewind(); |
||||||
unsigned int mBits; |
virtual bool hasEnded(); |
||||||
unsigned int mSampleCount; |
virtual ~WavStreamInstance(); |
||||||
|
}; |
||||||
WavStream(); |
|
||||||
virtual ~WavStream(); |
enum WAVSTREAM_FILETYPE |
||||||
result load(const char *aFilename); |
{ |
||||||
result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true); |
WAVSTREAM_WAV = 0, |
||||||
result loadToMem(const char *aFilename); |
WAVSTREAM_OGG = 1, |
||||||
result loadFile(File *aFile); |
WAVSTREAM_FLAC = 2, |
||||||
result loadFileToMem(File *aFile);
|
WAVSTREAM_MP3 = 3 |
||||||
virtual AudioSourceInstance *createInstance(); |
}; |
||||||
time getLength(); |
|
||||||
public: |
class WavStream : public AudioSource |
||||||
result parse(File *aFile); |
{ |
||||||
}; |
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 |
#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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue