diff --git a/assets/entities/door_red_green.symtres b/assets/entities/door_red_green.symtres new file mode 100644 index 0000000..9b94c6d --- /dev/null +++ b/assets/entities/door_red_green.symtres @@ -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 +} + diff --git a/include/common/soloud/soloud.h b/include/common/soloud/soloud.h index bc5c83d..734f5f2 100755 --- a/include/common/soloud/soloud.h +++ b/include/common/soloud/soloud.h @@ -1,481 +1,587 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_H -#define SOLOUD_H - -#include // rand -#include // sin - -#ifndef M_PI -#define M_PI 3.14159265359 -#endif - -#if defined(_WIN32)||defined(_WIN64) -#define WINDOWS_VERSION -#endif - -#if !defined(DISABLE_SIMD) -#if defined(__x86_64__) || defined( _M_X64 ) || defined( __i386 ) || defined( _M_IX86 ) -#define SOLOUD_SSE_INTRINSICS -#endif -#endif - -#define SOLOUD_VERSION 111 - -///////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////// -// Configuration defines - -// Maximum number of filters per stream -#define FILTERS_PER_STREAM 8 - -// Number of samples to process on one go -#define SAMPLE_GRANULARITY 512 - -// Maximum number of concurrent voices (hard limit is 4095) -#define VOICE_COUNT 1024 - -// Use linear resampler -#define RESAMPLER_LINEAR - -// 1)mono, 2)stereo 4)quad 6)5.1 -#define MAX_CHANNELS 6 - -// -///////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////// - -// Typedefs have to be made before the includes, as the -// includes depend on them. -namespace SoLoud -{ - class Soloud; - typedef void (*mutexCallFunction)(void *aMutexPtr); - typedef void (*soloudCallFunction)(Soloud *aSoloud); - typedef unsigned int result; - typedef unsigned int handle; - typedef double time; -}; - -namespace SoLoud -{ - // Class that handles aligned allocations to support vectorized operations - class AlignedFloatBuffer - { - public: - float *mData; // aligned pointer - unsigned char *mBasePtr; // raw allocated pointer (for delete) - - // ctor - AlignedFloatBuffer(); - // Allocate and align buffer - result init(unsigned int aFloats); - // dtor - ~AlignedFloatBuffer(); - }; -}; - -#include "soloud_filter.h" -#include "soloud_fader.h" -#include "soloud_audiosource.h" -#include "soloud_bus.h" -#include "soloud_error.h" - -namespace SoLoud -{ - - // Soloud core class. - class Soloud - { - public: - // Back-end data; content is up to the back-end implementation. - void * mBackendData; - // Pointer for the audio thread mutex. - void * mAudioThreadMutex; - // Called by SoLoud to shut down the back-end. If NULL, not called. Should be set by back-end. - soloudCallFunction mBackendCleanupFunc; - - // CTor - Soloud(); - // DTor - ~Soloud(); - - enum BACKENDS - { - AUTO = 0, - SDL, - SDL2, - PORTAUDIO, - WINMM, - XAUDIO2, - WASAPI, - ALSA, - OSS, - OPENAL, - COREAUDIO, - OPENSLES, - VITA_HOMEBREW, - NULLDRIVER, - BACKEND_MAX, - }; - - enum FLAGS - { - // Use round-off clipper - CLIP_ROUNDOFF = 1, - ENABLE_VISUALIZATION = 2, - LEFT_HANDED_3D = 4 - }; - - // Initialize SoLoud. Must be called before SoLoud can be used. - result init(unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aBackend = Soloud::AUTO, unsigned int aSamplerate = Soloud::AUTO, unsigned int aBufferSize = Soloud::AUTO, unsigned int aChannels = 2); - - // Deinitialize SoLoud. Must be called before shutting down. - void deinit(); - - // Query SoLoud version number (should equal to SOLOUD_VERSION macro) - unsigned int getVersion() const; - - // Translate error number to an asciiz string - const char * getErrorString(result aErrorCode) const; - - // Returns current backend ID (BACKENDS enum) - unsigned int getBackendId(); - // Returns current backend string. May be NULL. - const char * getBackendString(); - // Returns current backend channel count (1 mono, 2 stereo, etc) - unsigned int getBackendChannels(); - // Returns current backend sample rate - unsigned int getBackendSamplerate(); - // Returns current backend buffer size - unsigned int getBackendBufferSize(); - - // Set speaker position in 3d space - result setSpeakerPosition(unsigned int aChannel, float aX, float aY, float aZ); - - // Start playing a sound. Returns voice handle, which can be ignored or used to alter the playing sound's parameters. Negative volume means to use default. - handle play(AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, bool aPaused = 0, unsigned int aBus = 0); - // Start playing a sound delayed in relation to other sounds called via this function. Negative volume means to use default. - handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, unsigned int aBus = 0); - // Start playing a 3d audio source - handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0, unsigned int aBus = 0); - // Start playing a 3d audio source, delayed in relation to other sounds called via this function. - handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, unsigned int aBus = 0); - // Start playing a sound without any panning. It will be played at full volume. - handle playBackground(AudioSource &aSound, float aVolume = -1.0f, bool aPaused = 0, unsigned int aBus = 0); - - // Seek the audio stream to certain point in time. Some streams can't seek backwards. Relative play speed affects time. - void seek(handle aVoiceHandle, time aSeconds); - // Stop the sound. - void stop(handle aVoiceHandle); - // Stop all voices. - void stopAll(); - // Stop all voices that play this sound source - void stopAudioSource(AudioSource &aSound); - - // Set a live filter parameter. Use 0 for the global filters. - void setFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); - // Get a live filter parameter. Use 0 for the global filters. - float getFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); - // Fade a live filter parameter. Use 0 for the global filters. - void fadeFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, time aTime); - // Oscillate a live filter parameter. Use 0 for the global filters. - void oscillateFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, time aTime); - - // Get current play time, in seconds. - time getStreamTime(handle aVoiceHandle); - // Get current pause state. - bool getPause(handle aVoiceHandle); - // Get current volume. - float getVolume(handle aVoiceHandle); - // Get current overall volume (set volume * 3d volume) - float getOverallVolume(handle aVoiceHandle); - // Get current pan. - float getPan(handle aVoiceHandle); - // Get current sample rate. - float getSamplerate(handle aVoiceHandle); - // Get current voice protection state. - bool getProtectVoice(handle aVoiceHandle); - // Get the current number of busy voices. - unsigned int getActiveVoiceCount(); - // Get the current number of voices in SoLoud - unsigned int getVoiceCount(); - // Check if the handle is still valid, or if the sound has stopped. - bool isValidVoiceHandle(handle aVoiceHandle); - // Get current relative play speed. - float getRelativePlaySpeed(handle aVoiceHandle); - // Get current post-clip scaler value. - float getPostClipScaler() const; - // Get current global volume - float getGlobalVolume() const; - // Get current maximum active voice setting - unsigned int getMaxActiveVoiceCount() const; - // Query whether a voice is set to loop. - bool getLooping(handle aVoiceHandle); - - // Set voice's loop state - void setLooping(handle aVoiceHandle, bool aLooping); - // Set current maximum active voice setting - result setMaxActiveVoiceCount(unsigned int aVoiceCount); - // Set behavior for inaudible sounds - void setInaudibleBehavior(handle aVoiceHandle, bool aMustTick, bool aKill); - // Set the global volume - void setGlobalVolume(float aVolume); - // Set the post clip scaler value - void setPostClipScaler(float aScaler); - // Set the pause state - void setPause(handle aVoiceHandle, bool aPause); - // Pause all voices - void setPauseAll(bool aPause); - // Set the relative play speed - result setRelativePlaySpeed(handle aVoiceHandle, float aSpeed); - // Set the voice protection state - void setProtectVoice(handle aVoiceHandle, bool aProtect); - // Set the sample rate - void setSamplerate(handle aVoiceHandle, float aSamplerate); - // Set panning value; -1 is left, 0 is center, 1 is right - void setPan(handle aVoiceHandle, float aPan); - // Set absolute left/right volumes - void setPanAbsolute(handle aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume = 0, float aRBVolume = 0, float aCVolume = 0, float aSVolume = 0); - // Set overall volume - void setVolume(handle aVoiceHandle, float aVolume); - // Set delay, in samples, before starting to play samples. Calling this on a live sound will cause glitches. - void setDelaySamples(handle aVoiceHandle, unsigned int aSamples); - - // Set up volume fader - void fadeVolume(handle aVoiceHandle, float aTo, time aTime); - // Set up panning fader - void fadePan(handle aVoiceHandle, float aTo, time aTime); - // Set up relative play speed fader - void fadeRelativePlaySpeed(handle aVoiceHandle, float aTo, time aTime); - // Set up global volume fader - void fadeGlobalVolume(float aTo, time aTime); - // Schedule a stream to pause - void schedulePause(handle aVoiceHandle, time aTime); - // Schedule a stream to stop - void scheduleStop(handle aVoiceHandle, time aTime); - - // Set up volume oscillator - void oscillateVolume(handle aVoiceHandle, float aFrom, float aTo, time aTime); - // Set up panning oscillator - void oscillatePan(handle aVoiceHandle, float aFrom, float aTo, time aTime); - // Set up relative play speed oscillator - void oscillateRelativePlaySpeed(handle aVoiceHandle, float aFrom, float aTo, time aTime); - // Set up global volume oscillator - void oscillateGlobalVolume(float aFrom, float aTo, time aTime); - - // Set global filters. Set to NULL to clear the filter. - void setGlobalFilter(unsigned int aFilterId, Filter *aFilter); - - // Enable or disable visualization data gathering - void setVisualizationEnable(bool aEnable); - - // Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use. - float *calcFFT(); - - // Get 256 floats of wave data for visualization. Visualization has to be enabled before use. - float *getWave(); - - // Get current loop count. Returns 0 if handle is not valid. (All audio sources may not update loop count) - unsigned int getLoopCount(handle aVoiceHandle); - - // Get audiosource-specific information from a voice. - float getInfo(handle aVoiceHandle, unsigned int aInfoKey); - - // Create a voice group. Returns 0 if unable (out of voice groups / out of memory) - handle createVoiceGroup(); - // Destroy a voice group. - result destroyVoiceGroup(handle aVoiceGroupHandle); - // Add a voice handle to a voice group - result addVoiceToGroup(handle aVoiceGroupHandle, handle aVoiceHandle); - // Is this handle a valid voice group? - bool isVoiceGroup(handle aVoiceGroupHandle); - // Is this voice group empty? - bool isVoiceGroupEmpty(handle aVoiceGroupHandle); - - // Perform 3d audio parameter update - void update3dAudio(); - - // Set the speed of sound constant for doppler - result set3dSoundSpeed(float aSpeed); - // Get the current speed of sound constant for doppler - float get3dSoundSpeed(); - // Set 3d listener parameters - void set3dListenerParameters(float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); - // Set 3d listener position - void set3dListenerPosition(float aPosX, float aPosY, float aPosZ); - // Set 3d listener "at" vector - void set3dListenerAt(float aAtX, float aAtY, float aAtZ); - // set 3d listener "up" vector - void set3dListenerUp(float aUpX, float aUpY, float aUpZ); - // Set 3d listener velocity - void set3dListenerVelocity(float aVelocityX, float aVelocityY, float aVelocityZ); - - // Set 3d audio source parameters - void set3dSourceParameters(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); - // Set 3d audio source position - void set3dSourcePosition(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ); - // Set 3d audio source velocity - void set3dSourceVelocity(handle aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); - // Set 3d audio source min/max distance (distance < min means max volume) - void set3dSourceMinMaxDistance(handle aVoiceHandle, float aMinDistance, float aMaxDistance); - // Set 3d audio source attenuation parameters - void set3dSourceAttenuation(handle aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); - // Set 3d audio source doppler factor to reduce or enhance doppler effect. Default = 1.0 - void set3dSourceDopplerFactor(handle aVoiceHandle, float aDopplerFactor); - - // Rest of the stuff is used internally. - - // Returns mixed float samples in buffer. Called by the back-end, or user with null driver. - void mix(float *aBuffer, unsigned int aSamples); - // Returns mixed 16-bit signed integer samples in buffer. Called by the back-end, or user with null driver. - void mixSigned16(short *aBuffer, unsigned int aSamples); - public: - // Mix N samples * M channels. Called by other mix_ functions. - void mix_internal(unsigned int aSamples); - - // Handle rest of initialization (called from backend) - void postinit(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels); - - // Update list of active voices - void calcActiveVoices(); - // Perform mixing for a specific bus - void mixBus(float *aBuffer, unsigned int aSamples, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels); - // Max. number of active voices. Busses and tickable inaudibles also count against this. - unsigned int mMaxActiveVoices; - // Highest voice in use so far - unsigned int mHighestVoice; - // Scratch buffer, used for resampling. - AlignedFloatBuffer mScratch; - // Current size of the scratch, in samples. - unsigned int mScratchSize; - // Amount of scratch needed. - unsigned int mScratchNeeded; - // Output scratch buffer, used in mix_(). - AlignedFloatBuffer mOutputScratch; - // Audio voices. - AudioSourceInstance *mVoice[VOICE_COUNT]; - // Output sample rate (not float) - unsigned int mSamplerate; - // Output channel count - unsigned int mChannels; - // Current backend ID - unsigned int mBackendID; - // Current backend string - const char * mBackendString; - // Maximum size of output buffer; used to calculate needed scratch. - unsigned int mBufferSize; - // Flags; see Soloud::FLAGS - unsigned int mFlags; - // Global volume. Applied before clipping. - float mGlobalVolume; - // Post-clip scaler. Applied after clipping. - float mPostClipScaler; - // Current play index. Used to create audio handles. - unsigned int mPlayIndex; - // Current sound source index. Used to create sound source IDs. - unsigned int mAudioSourceID; - // Fader for the global volume. - Fader mGlobalVolumeFader; - // Global stream time, for the global volume fader. - time mStreamTime; - // Last time seen by the playClocked call - time mLastClockedTime; - // Global filter - Filter *mFilter[FILTERS_PER_STREAM]; - // Global filter instance - FilterInstance *mFilterInstance[FILTERS_PER_STREAM]; - // Find a free voice, stopping the oldest if no free voice is found. - int findFreeVoice(); - // Converts handle to voice, if the handle is valid. Returns -1 if not. - int getVoiceFromHandle(handle aVoiceHandle) const; - // Converts voice + playindex into handle - handle getHandleFromVoice(unsigned int aVoice) const; - // Stop voice (not handle). - void stopVoice(unsigned int aVoice); - // Set voice (not handle) pan. - void setVoicePan(unsigned int aVoice, float aPan); - // Set voice (not handle) relative play speed. - result setVoiceRelativePlaySpeed(unsigned int aVoice, float aSpeed); - // Set voice (not handle) volume. - void setVoiceVolume(unsigned int aVoice, float aVolume); - // Set voice (not handle) pause state. - void setVoicePause(unsigned int aVoice, int aPause); - // Update overall volume from set and 3d volumes - void updateVoiceVolume(unsigned int aVoice); - // Update overall relative play speed from set and 3d speeds - void updateVoiceRelativePlaySpeed(unsigned int aVoice); - // Perform 3d audio calculation for array of voices - void update3dVoices(unsigned int *aVoiceList, unsigned int aVoiceCount); - // Clip the samples in the buffer - void clip(AlignedFloatBuffer &aBuffer, AlignedFloatBuffer &aDestBuffer, unsigned int aSamples, float aVolume0, float aVolume1); - // Mono-mixed wave data for visualization and for visualization FFT input - float mVisualizationWaveData[256]; - // FFT output data - float mFFTData[256]; - // Snapshot of wave data for visualization - float mWaveData[256]; - - // 3d listener position - float m3dPosition[3]; - // 3d listener look-at - float m3dAt[3]; - // 3d listener up - float m3dUp[3]; - // 3d listener velocity - float m3dVelocity[3]; - // 3d speed of sound (for doppler) - float m3dSoundSpeed; - - // 3d position of speakers - float m3dSpeakerPosition[3 * MAX_CHANNELS]; - - // Data related to 3d processing, separate from AudioSource so we can do 3d calculations without audio mutex. - AudioSourceInstance3dData m3dData[VOICE_COUNT]; - - // For each voice group, first int is number of ints alocated. - unsigned int **mVoiceGroup; - unsigned int mVoiceGroupCount; - - // List of currently active voices - unsigned int mActiveVoice[VOICE_COUNT]; - // Number of currently active voices - unsigned int mActiveVoiceCount; - // Active voices list needs to be recalculated - bool mActiveVoiceDirty; - - // Remove all non-active voices from group - void trimVoiceGroup(handle aVoiceGroupHandle); - // Get pointer to the zero-terminated array of voice handles in a voice group - handle * voiceGroupHandleToArray(handle aVoiceGroupHandle) const; - - // Lock audio thread mutex. - void lockAudioMutex(); - // Unlock audio thread mutex. - void unlockAudioMutex(); - }; -}; - -#endif +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_H +#define SOLOUD_H + +#include // rand +#include // sin + +#ifdef SOLOUD_NO_ASSERTS +#define SOLOUD_ASSERT(x) +#else +#ifdef _MSC_VER +#include // for sprintf in asserts +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include // only needed for OutputDebugStringA, should be solved somehow. +#define SOLOUD_ASSERT(x) if (!(x)) { char temp[200]; sprintf(temp, "%s(%d): assert(%s) failed.\n", __FILE__, __LINE__, #x); OutputDebugStringA(temp); __debugbreak(); } +#else +#include // assert +#define SOLOUD_ASSERT(x) assert(x) +#endif +#endif + +#ifdef WITH_SDL +#undef WITH_SDL2 +#undef WITH_SDL1 +#define WITH_SDL1 +#define WITH_SDL2 +#endif + +#ifdef WITH_SDL_STATIC +#undef WITH_SDL1_STATIC +#define WITH_SDL1_STATIC +#endif + +#ifndef M_PI +#define M_PI 3.14159265359 +#endif + +#if defined(_WIN32)||defined(_WIN64) +#define WINDOWS_VERSION +#endif + +#if !defined(DISABLE_SIMD) +#if defined(__x86_64__) || defined( _M_X64 ) || defined( __i386 ) || defined( _M_IX86 ) +#define SOLOUD_SSE_INTRINSICS +#endif +#endif + +#define SOLOUD_VERSION 202002 + +///////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////// +// Configuration defines + +// Maximum number of filters per stream +#define FILTERS_PER_STREAM 8 + +// Number of samples to process on one go +#define SAMPLE_GRANULARITY 512 + +// Maximum number of concurrent voices (hard limit is 4095) +#define VOICE_COUNT 1024 + +// 1)mono, 2)stereo 4)quad 6)5.1 8)7.1 +#define MAX_CHANNELS 8 + +// Default resampler for both main and bus mixers +#define SOLOUD_DEFAULT_RESAMPLER SoLoud::Soloud::RESAMPLER_LINEAR + +// +///////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////// + +// Typedefs have to be made before the includes, as the +// includes depend on them. +namespace SoLoud +{ + class Soloud; + typedef void (*mutexCallFunction)(void *aMutexPtr); + typedef void (*soloudCallFunction)(Soloud *aSoloud); + typedef unsigned int result; + typedef unsigned int handle; + typedef double time; +}; + +namespace SoLoud +{ + // Class that handles aligned allocations to support vectorized operations + class AlignedFloatBuffer + { + public: + float *mData; // aligned pointer + unsigned char *mBasePtr; // raw allocated pointer (for delete) + int mFloats; // size of buffer (w/out padding) + + // ctor + AlignedFloatBuffer(); + // Allocate and align buffer + result init(unsigned int aFloats); + // Clear data to zero. + void clear(); + // dtor + ~AlignedFloatBuffer(); + }; + + // Lightweight class that handles small aligned buffer to support vectorized operations + class TinyAlignedFloatBuffer + { + public: + float *mData; // aligned pointer + unsigned char mActualData[sizeof(float) * 16 + 16]; + + // ctor + TinyAlignedFloatBuffer(); + }; +}; + +#include "soloud_filter.h" +#include "soloud_fader.h" +#include "soloud_audiosource.h" +#include "soloud_bus.h" +#include "soloud_queue.h" +#include "soloud_error.h" + +namespace SoLoud +{ + + // Soloud core class. + class Soloud + { + public: + // Back-end data; content is up to the back-end implementation. + void * mBackendData; + // Pointer for the audio thread mutex. + void * mAudioThreadMutex; + // Flag for when we're inside the mutex, used for debugging. + bool mInsideAudioThreadMutex; + // Called by SoLoud to shut down the back-end. If NULL, not called. Should be set by back-end. + soloudCallFunction mBackendCleanupFunc; + + // CTor + Soloud(); + // DTor + ~Soloud(); + + enum BACKENDS + { + AUTO = 0, + SDL1, + SDL2, + PORTAUDIO, + WINMM, + XAUDIO2, + WASAPI, + ALSA, + JACK, + OSS, + OPENAL, + COREAUDIO, + OPENSLES, + VITA_HOMEBREW, + MINIAUDIO, + NOSOUND, + NULLDRIVER, + BACKEND_MAX, + }; + + enum FLAGS + { + // Use round-off clipper + CLIP_ROUNDOFF = 1, + ENABLE_VISUALIZATION = 2, + LEFT_HANDED_3D = 4, + NO_FPU_REGISTER_CHANGE = 8 + }; + + enum WAVEFORM + { + WAVE_SQUARE = 0, + WAVE_SAW, + WAVE_SIN, + WAVE_TRIANGLE, + WAVE_BOUNCE, + WAVE_JAWS, + WAVE_HUMPS, + WAVE_FSQUARE, + WAVE_FSAW + }; + + enum RESAMPLER + { + RESAMPLER_POINT, + RESAMPLER_LINEAR, + RESAMPLER_CATMULLROM + }; + + // Initialize SoLoud. Must be called before SoLoud can be used. + result init(unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aBackend = Soloud::AUTO, unsigned int aSamplerate = Soloud::AUTO, unsigned int aBufferSize = Soloud::AUTO, unsigned int aChannels = 2); + + // Deinitialize SoLoud. Must be called before shutting down. + void deinit(); + + // Query SoLoud version number (should equal to SOLOUD_VERSION macro) + unsigned int getVersion() const; + + // Translate error number to an asciiz string + const char * getErrorString(result aErrorCode) const; + + // Returns current backend ID (BACKENDS enum) + unsigned int getBackendId(); + // Returns current backend string. May be NULL. + const char * getBackendString(); + // Returns current backend channel count (1 mono, 2 stereo, etc) + unsigned int getBackendChannels(); + // Returns current backend sample rate + unsigned int getBackendSamplerate(); + // Returns current backend buffer size + unsigned int getBackendBufferSize(); + + // Set speaker position in 3d space + result setSpeakerPosition(unsigned int aChannel, float aX, float aY, float aZ); + // Get speaker position in 3d space + result getSpeakerPosition(unsigned int aChannel, float &aX, float &aY, float &aZ); + + // Start playing a sound. Returns voice handle, which can be ignored or used to alter the playing sound's parameters. Negative volume means to use default. + handle play(AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, bool aPaused = 0, unsigned int aBus = 0); + // Start playing a sound delayed in relation to other sounds called via this function. Negative volume means to use default. + handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, unsigned int aBus = 0); + // Start playing a 3d audio source + handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0, unsigned int aBus = 0); + // Start playing a 3d audio source, delayed in relation to other sounds called via this function. + handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, unsigned int aBus = 0); + // Start playing a sound without any panning. It will be played at full volume. + handle playBackground(AudioSource &aSound, float aVolume = -1.0f, bool aPaused = 0, unsigned int aBus = 0); + + // Seek the audio stream to certain point in time. Some streams can't seek backwards. Relative play speed affects time. + result seek(handle aVoiceHandle, time aSeconds); + // Stop the sound. + void stop(handle aVoiceHandle); + // Stop all voices. + void stopAll(); + // Stop all voices that play this sound source + void stopAudioSource(AudioSource &aSound); + // Count voices that play this audio source + int countAudioSource(AudioSource &aSound); + + // Set a live filter parameter. Use 0 for the global filters. + void setFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); + // Get a live filter parameter. Use 0 for the global filters. + float getFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); + // Fade a live filter parameter. Use 0 for the global filters. + void fadeFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, time aTime); + // Oscillate a live filter parameter. Use 0 for the global filters. + void oscillateFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, time aTime); + + // Get current play time, in seconds. + time getStreamTime(handle aVoiceHandle); + // Get current sample position, in seconds. + time getStreamPosition(handle aVoiceHandle); + // Get current pause state. + bool getPause(handle aVoiceHandle); + // Get current volume. + float getVolume(handle aVoiceHandle); + // Get current overall volume (set volume * 3d volume) + float getOverallVolume(handle aVoiceHandle); + // Get current pan. + float getPan(handle aVoiceHandle); + // Get current sample rate. + float getSamplerate(handle aVoiceHandle); + // Get current voice protection state. + bool getProtectVoice(handle aVoiceHandle); + // Get the current number of busy voices. + unsigned int getActiveVoiceCount(); + // Get the current number of voices in SoLoud + unsigned int getVoiceCount(); + // Check if the handle is still valid, or if the sound has stopped. + bool isValidVoiceHandle(handle aVoiceHandle); + // Get current relative play speed. + float getRelativePlaySpeed(handle aVoiceHandle); + // Get current post-clip scaler value. + float getPostClipScaler() const; + // Get the current main resampler + unsigned int getMainResampler() const; + // Get current global volume + float getGlobalVolume() const; + // Get current maximum active voice setting + unsigned int getMaxActiveVoiceCount() const; + // Query whether a voice is set to loop. + bool getLooping(handle aVoiceHandle); + // Query whether a voice is set to auto-stop when it ends. + bool getAutoStop(handle aVoiceHandle); + // Get voice loop point value + time getLoopPoint(handle aVoiceHandle); + + // Set voice loop point value + void setLoopPoint(handle aVoiceHandle, time aLoopPoint); + // Set voice's loop state + void setLooping(handle aVoiceHandle, bool aLooping); + // Set whether sound should auto-stop when it ends + void setAutoStop(handle aVoiceHandle, bool aAutoStop); + // Set current maximum active voice setting + result setMaxActiveVoiceCount(unsigned int aVoiceCount); + // Set behavior for inaudible sounds + void setInaudibleBehavior(handle aVoiceHandle, bool aMustTick, bool aKill); + // Set the global volume + void setGlobalVolume(float aVolume); + // Set the post clip scaler value + void setPostClipScaler(float aScaler); + // Set the main resampler + void setMainResampler(unsigned int aResampler); + // Set the pause state + void setPause(handle aVoiceHandle, bool aPause); + // Pause all voices + void setPauseAll(bool aPause); + // Set the relative play speed + result setRelativePlaySpeed(handle aVoiceHandle, float aSpeed); + // Set the voice protection state + void setProtectVoice(handle aVoiceHandle, bool aProtect); + // Set the sample rate + void setSamplerate(handle aVoiceHandle, float aSamplerate); + // Set panning value; -1 is left, 0 is center, 1 is right + void setPan(handle aVoiceHandle, float aPan); + // Set absolute left/right volumes + void setPanAbsolute(handle aVoiceHandle, float aLVolume, float aRVolume); + // Set channel volume (volume for a specific speaker) + void setChannelVolume(handle aVoiceHandle, unsigned int aChannel, float aVolume); + // Set overall volume + void setVolume(handle aVoiceHandle, float aVolume); + // Set delay, in samples, before starting to play samples. Calling this on a live sound will cause glitches. + void setDelaySamples(handle aVoiceHandle, unsigned int aSamples); + + // Set up volume fader + void fadeVolume(handle aVoiceHandle, float aTo, time aTime); + // Set up panning fader + void fadePan(handle aVoiceHandle, float aTo, time aTime); + // Set up relative play speed fader + void fadeRelativePlaySpeed(handle aVoiceHandle, float aTo, time aTime); + // Set up global volume fader + void fadeGlobalVolume(float aTo, time aTime); + // Schedule a stream to pause + void schedulePause(handle aVoiceHandle, time aTime); + // Schedule a stream to stop + void scheduleStop(handle aVoiceHandle, time aTime); + + // Set up volume oscillator + void oscillateVolume(handle aVoiceHandle, float aFrom, float aTo, time aTime); + // Set up panning oscillator + void oscillatePan(handle aVoiceHandle, float aFrom, float aTo, time aTime); + // Set up relative play speed oscillator + void oscillateRelativePlaySpeed(handle aVoiceHandle, float aFrom, float aTo, time aTime); + // Set up global volume oscillator + void oscillateGlobalVolume(float aFrom, float aTo, time aTime); + + // Set global filters. Set to NULL to clear the filter. + void setGlobalFilter(unsigned int aFilterId, Filter *aFilter); + + // Enable or disable visualization data gathering + void setVisualizationEnable(bool aEnable); + + // Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use. + float *calcFFT(); + + // Get 256 floats of wave data for visualization. Visualization has to be enabled before use. + float *getWave(); + + // Get approximate output volume for a channel for visualization. Visualization has to be enabled before use. + float getApproximateVolume(unsigned int aChannel); + + // Get current loop count. Returns 0 if handle is not valid. (All audio sources may not update loop count) + unsigned int getLoopCount(handle aVoiceHandle); + + // Get audiosource-specific information from a voice. + float getInfo(handle aVoiceHandle, unsigned int aInfoKey); + + // Create a voice group. Returns 0 if unable (out of voice groups / out of memory) + handle createVoiceGroup(); + // Destroy a voice group. + result destroyVoiceGroup(handle aVoiceGroupHandle); + // Add a voice handle to a voice group + result addVoiceToGroup(handle aVoiceGroupHandle, handle aVoiceHandle); + // Is this handle a valid voice group? + bool isVoiceGroup(handle aVoiceGroupHandle); + // Is this voice group empty? + bool isVoiceGroupEmpty(handle aVoiceGroupHandle); + + // Perform 3d audio parameter update + void update3dAudio(); + + // Set the speed of sound constant for doppler + result set3dSoundSpeed(float aSpeed); + // Get the current speed of sound constant for doppler + float get3dSoundSpeed(); + // Set 3d listener parameters + void set3dListenerParameters(float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); + // Set 3d listener position + void set3dListenerPosition(float aPosX, float aPosY, float aPosZ); + // Set 3d listener "at" vector + void set3dListenerAt(float aAtX, float aAtY, float aAtZ); + // set 3d listener "up" vector + void set3dListenerUp(float aUpX, float aUpY, float aUpZ); + // Set 3d listener velocity + void set3dListenerVelocity(float aVelocityX, float aVelocityY, float aVelocityZ); + + // Set 3d audio source parameters + void set3dSourceParameters(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); + // Set 3d audio source position + void set3dSourcePosition(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ); + // Set 3d audio source velocity + void set3dSourceVelocity(handle aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); + // Set 3d audio source min/max distance (distance < min means max volume) + void set3dSourceMinMaxDistance(handle aVoiceHandle, float aMinDistance, float aMaxDistance); + // Set 3d audio source attenuation parameters + void set3dSourceAttenuation(handle aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); + // Set 3d audio source doppler factor to reduce or enhance doppler effect. Default = 1.0 + void set3dSourceDopplerFactor(handle aVoiceHandle, float aDopplerFactor); + + // Rest of the stuff is used internally. + + // Returns mixed float samples in buffer. Called by the back-end, or user with null driver. + void mix(float *aBuffer, unsigned int aSamples); + // Returns mixed 16-bit signed integer samples in buffer. Called by the back-end, or user with null driver. + void mixSigned16(short *aBuffer, unsigned int aSamples); + public: + // Mix N samples * M channels. Called by other mix_ functions. + void mix_internal(unsigned int aSamples, unsigned int aStride); + + // Handle rest of initialization (called from backend) + void postinit_internal(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels); + + // Update list of active voices + void calcActiveVoices_internal(); + // Map resample buffers to active voices + void mapResampleBuffers_internal(); + // Perform mixing for a specific bus + void mixBus_internal(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels, unsigned int aResampler); + // Find a free voice, stopping the oldest if no free voice is found. + int findFreeVoice_internal(); + // Converts handle to voice, if the handle is valid. Returns -1 if not. + int getVoiceFromHandle_internal(handle aVoiceHandle) const; + // Converts voice + playindex into handle + handle getHandleFromVoice_internal(unsigned int aVoice) const; + // Stop voice (not handle). + void stopVoice_internal(unsigned int aVoice); + // Set voice (not handle) pan. + void setVoicePan_internal(unsigned int aVoice, float aPan); + // Set voice (not handle) relative play speed. + result setVoiceRelativePlaySpeed_internal(unsigned int aVoice, float aSpeed); + // Set voice (not handle) volume. + void setVoiceVolume_internal(unsigned int aVoice, float aVolume); + // Set voice (not handle) pause state. + void setVoicePause_internal(unsigned int aVoice, int aPause); + // Update overall volume from set and 3d volumes + void updateVoiceVolume_internal(unsigned int aVoice); + // Update overall relative play speed from set and 3d speeds + void updateVoiceRelativePlaySpeed_internal(unsigned int aVoice); + // Perform 3d audio calculation for array of voices + void update3dVoices_internal(unsigned int *aVoiceList, unsigned int aVoiceCount); + // Clip the samples in the buffer + void clip_internal(AlignedFloatBuffer &aBuffer, AlignedFloatBuffer &aDestBuffer, unsigned int aSamples, float aVolume0, float aVolume1); + // Remove all non-active voices from group + void trimVoiceGroup_internal(handle aVoiceGroupHandle); + // Get pointer to the zero-terminated array of voice handles in a voice group + handle * voiceGroupHandleToArray_internal(handle aVoiceGroupHandle) const; + + // Lock audio thread mutex. + void lockAudioMutex_internal(); + // Unlock audio thread mutex. + void unlockAudioMutex_internal(); + + // Max. number of active voices. Busses and tickable inaudibles also count against this. + unsigned int mMaxActiveVoices; + // Highest voice in use so far + unsigned int mHighestVoice; + // Scratch buffer, used for resampling. + AlignedFloatBuffer mScratch; + // Current size of the scratch, in samples. + unsigned int mScratchSize; + // Output scratch buffer, used in mix_(). + AlignedFloatBuffer mOutputScratch; + // Pointers to resampler buffers, two per active voice. + float **mResampleData; + // Actual allocated memory for resampler buffers + AlignedFloatBuffer mResampleDataBuffer; + // Owners of the resample data + AudioSourceInstance **mResampleDataOwner; + // Audio voices. + AudioSourceInstance *mVoice[VOICE_COUNT]; + // Resampler for the main bus + unsigned int mResampler; + // Output sample rate (not float) + unsigned int mSamplerate; + // Output channel count + unsigned int mChannels; + // Current backend ID + unsigned int mBackendID; + // Current backend string + const char * mBackendString; + // Maximum size of output buffer; used to calculate needed scratch. + unsigned int mBufferSize; + // Flags; see Soloud::FLAGS + unsigned int mFlags; + // Global volume. Applied before clipping. + float mGlobalVolume; + // Post-clip scaler. Applied after clipping. + float mPostClipScaler; + // Current play index. Used to create audio handles. + unsigned int mPlayIndex; + // Current sound source index. Used to create sound source IDs. + unsigned int mAudioSourceID; + // Fader for the global volume. + Fader mGlobalVolumeFader; + // Global stream time, for the global volume fader. + time mStreamTime; + // Last time seen by the playClocked call + time mLastClockedTime; + // Global filter + Filter *mFilter[FILTERS_PER_STREAM]; + // Global filter instance + FilterInstance *mFilterInstance[FILTERS_PER_STREAM]; + + // Approximate volume for channels. + float mVisualizationChannelVolume[MAX_CHANNELS]; + // Mono-mixed wave data for visualization and for visualization FFT input + float mVisualizationWaveData[256]; + // FFT output data + float mFFTData[256]; + // Snapshot of wave data for visualization + float mWaveData[256]; + + // 3d listener position + float m3dPosition[3]; + // 3d listener look-at + float m3dAt[3]; + // 3d listener up + float m3dUp[3]; + // 3d listener velocity + float m3dVelocity[3]; + // 3d speed of sound (for doppler) + float m3dSoundSpeed; + + // 3d position of speakers + float m3dSpeakerPosition[3 * MAX_CHANNELS]; + + // Data related to 3d processing, separate from AudioSource so we can do 3d calculations without audio mutex. + AudioSourceInstance3dData m3dData[VOICE_COUNT]; + + // For each voice group, first int is number of ints alocated. + unsigned int **mVoiceGroup; + unsigned int mVoiceGroupCount; + + // List of currently active voices + unsigned int mActiveVoice[VOICE_COUNT]; + // Number of currently active voices + unsigned int mActiveVoiceCount; + // Active voices list needs to be recalculated + bool mActiveVoiceDirty; + }; +}; + +#endif diff --git a/include/common/soloud/soloud_audiosource.h b/include/common/soloud/soloud_audiosource.h index 0b39bc2..c155705 100755 --- a/include/common/soloud/soloud_audiosource.h +++ b/include/common/soloud/soloud_audiosource.h @@ -1,313 +1,321 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_AUDIOSOURCE_H -#define SOLOUD_AUDIOSOURCE_H - -#include "soloud.h" -#include "soloud_fader.h" -#include "soloud_filter.h" - -namespace SoLoud -{ - class AudioSource; - class AudioSourceInstance; - class AudioSourceInstance3dData; - - struct AudioSourceResampleData - { - AudioSourceResampleData(); - ~AudioSourceResampleData(); - float *mBuffer; - }; - - class AudioCollider - { - public: - // Calculate volume multiplier. Assumed to return value between 0 and 1. - virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0; - }; - - class AudioAttenuator - { - public: - virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0; - }; - - class AudioSourceInstance3dData - { - public: - // ctor - AudioSourceInstance3dData(); - // Set settings from audiosource - void init(AudioSource &aSource); - // 3d position - float m3dPosition[3]; - // 3d velocity - float m3dVelocity[3]; - // 3d cone direction - /* - float m3dConeDirection[3]; - // 3d cone inner angle - float m3dConeInnerAngle; - // 3d cone outer angle - float m3dConeOuterAngle; - // 3d cone outer volume multiplier - float m3dConeOuterVolume; - */ - // 3d min distance - float m3dMinDistance; - // 3d max distance - float m3dMaxDistance; - // 3d attenuation rolloff factor - float m3dAttenuationRolloff; - // 3d attenuation model - unsigned int m3dAttenuationModel; - // 3d doppler factor - float m3dDopplerFactor; - // Pointer to a custom audio collider object - AudioCollider *mCollider; - // Pointer to a custom audio attenuator object - AudioAttenuator *mAttenuator; - // User data related to audio collider - int mColliderData; - - // Doppler sample rate multiplier - float mDopplerValue; - // Overall 3d volume - float m3dVolume; - // Channel volume - float mChannelVolume[MAX_CHANNELS]; - // Copy of flags - unsigned int mFlags; - // Latest handle for this voice - handle mHandle; - }; - - // Base class for audio instances - class AudioSourceInstance - { - public: - enum FLAGS - { - // This audio instance loops (if supported) - LOOPING = 1, - // This audio instance is protected - won't get stopped if we run out of voices - PROTECTED = 2, - // This audio instance is paused - PAUSED = 4, - // This audio instance is affected by 3d processing - PROCESS_3D = 8, - // This audio instance has listener-relative 3d coordinates - LISTENER_RELATIVE = 16, - // Currently inaudible - INAUDIBLE = 32, - // If inaudible, should be killed (default = don't kill kill) - INAUDIBLE_KILL = 64, - // If inaudible, should still be ticked (default = pause) - INAUDIBLE_TICK = 128 - }; - // Ctor - AudioSourceInstance(); - // Dtor - virtual ~AudioSourceInstance(); - // Play index; used to identify instances from handles - unsigned int mPlayIndex; - // Loop count - unsigned int mLoopCount; - // Flags; see AudioSourceInstance::FLAGS - unsigned int mFlags; - // Pan value, for getPan() - float mPan; - // Volume for each channel (panning) - float mChannelVolume[MAX_CHANNELS]; - // Set volume - float mSetVolume; - // Overall volume overall = set * 3d - float mOverallVolume; - // Base samplerate; samplerate = base samplerate * relative play speed - float mBaseSamplerate; - // Samplerate; samplerate = base samplerate * relative play speed - float mSamplerate; - // Number of channels this audio source produces - unsigned int mChannels; - // Relative play speed; samplerate = base samplerate * relative play speed - float mSetRelativePlaySpeed; - // Overall relative plays peed; overall = set * 3d - float mOverallRelativePlaySpeed; - // How long this stream has played, in seconds. - time mStreamTime; - // Fader for the audio panning - Fader mPanFader; - // Fader for the audio volume - Fader mVolumeFader; - // Fader for the relative play speed - Fader mRelativePlaySpeedFader; - // Fader used to schedule pausing of the stream - Fader mPauseScheduler; - // Fader used to schedule stopping of the stream - Fader mStopScheduler; - // Affected by some fader - int mActiveFader; - // Current channel volumes, used to ramp the volume changes to avoid clicks - float mCurrentChannelVolume[MAX_CHANNELS]; - // ID of the sound source that generated this instance - unsigned int mAudioSourceID; - // Handle of the bus this audio instance is playing on. 0 for root. - unsigned int mBusHandle; - // Filter pointer - FilterInstance *mFilter[FILTERS_PER_STREAM]; - // Initialize instance. Mostly internal use. - void init(AudioSource &aSource, int aPlayIndex); - // Buffers for the resampler - AudioSourceResampleData *mResampleData[2]; - // Sub-sample playhead; 16.16 fixed point - unsigned int mSrcOffset; - // Samples left over from earlier pass - unsigned int mLeftoverSamples; - // Number of samples to delay streaming - unsigned int mDelaySamples; - - // Get N samples from the stream to the buffer - virtual void getAudio(float *aBuffer, unsigned int aSamples) = 0; - // Has the stream ended? - virtual bool hasEnded() = 0; - // Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow). - virtual void seek(time aSeconds, float *mScratch, unsigned int mScratchSize); - // Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind. - virtual result rewind(); - // Get information. Returns 0 by default. - virtual float getInfo(unsigned int aInfoKey); - }; - - class Soloud; - - // Base class for audio sources - class AudioSource - { - public: - enum FLAGS - { - // The instances from this audio source should loop - SHOULD_LOOP = 1, - // Only one instance of this audio source should play at the same time - SINGLE_INSTANCE = 2, - // Visualization data gathering enabled. Only for busses. - VISUALIZATION_DATA = 4, - // Audio instances created from this source are affected by 3d processing - PROCESS_3D = 8, - // Audio instances created from this source have listener-relative 3d coordinates - LISTENER_RELATIVE = 16, - // Delay start of sound by the distance from listener - DISTANCE_DELAY = 32, - // If inaudible, should be killed (default) - INAUDIBLE_KILL = 64, - // If inaudible, should still be ticked (default = pause) - INAUDIBLE_TICK = 128 - }; - enum ATTENUATION_MODELS - { - // No attenuation - NO_ATTENUATION = 0, - // Inverse distance attenuation model - INVERSE_DISTANCE = 1, - // Linear distance attenuation model - LINEAR_DISTANCE = 2, - // Exponential distance attenuation model - EXPONENTIAL_DISTANCE = 3 - }; - - // Flags. See AudioSource::FLAGS - unsigned int mFlags; - // Base sample rate, used to initialize instances - float mBaseSamplerate; - // Default volume for created instances - float mVolume; - // Number of channels this audio source produces - unsigned int mChannels; - // Sound source ID. Assigned by SoLoud the first time it's played. - unsigned int mAudioSourceID; - // 3d min distance - float m3dMinDistance; - // 3d max distance - float m3dMaxDistance; - // 3d attenuation rolloff factor - float m3dAttenuationRolloff; - // 3d attenuation model - unsigned int m3dAttenuationModel; - // 3d doppler factor - float m3dDopplerFactor; - // Filter pointer - Filter *mFilter[FILTERS_PER_STREAM]; - // Pointer to the Soloud object. Needed to stop all instances in dtor. - Soloud *mSoloud; - // Pointer to a custom audio collider object - AudioCollider *mCollider; - // Pointer to custom attenuator object - AudioAttenuator *mAttenuator; - // User data related to audio collider - int mColliderData; - - // CTor - AudioSource(); - // Set default volume for instances - void setVolume(float aVolume); - // Set the looping of the instances created from this audio source - void setLooping(bool aLoop); - // Set whether only one instance of this sound should ever be playing at the same time - void setSingleInstance(bool aSingleInstance); - - // Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol) - void set3dMinMaxDistance(float aMinDistance, float aMaxDistance); - // Set attenuation model and rolloff factor for 3d audio source - void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor); - // Set doppler factor to reduce or enhance doppler effect, default = 1.0 - void set3dDopplerFactor(float aDopplerFactor); - // Enable 3d processing. Implicitly set by play3d calls. - void set3dProcessing(bool aDo3dProcessing); - // Set the coordinates for this audio source to be relative to listener's coordinates. - void set3dListenerRelative(bool aListenerRelative); - // Enable delaying the start of the sound based on the distance. - void set3dDistanceDelay(bool aDistanceDelay); - - // Set a custom 3d audio collider. Set to NULL to disable. - void set3dCollider(AudioCollider *aCollider, int aUserData = 0); - // Set a custom attenuator. Set to NULL to disable. - void set3dAttenuator(AudioAttenuator *aAttenuator); - - // Set behavior for inaudible sounds - void setInaudibleBehavior(bool aMustTick, bool aKill); - - // Set filter. Set to NULL to clear the filter. - virtual void setFilter(unsigned int aFilterId, Filter *aFilter); - // DTor - virtual ~AudioSource(); - // Create instance from the audio source. Called from within Soloud class. - virtual AudioSourceInstance *createInstance() = 0; - // Stop all instances of this audio source - void stop(); - }; -}; - -#endif +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_AUDIOSOURCE_H +#define SOLOUD_AUDIOSOURCE_H + +#include "soloud.h" +#include "soloud_fader.h" +#include "soloud_filter.h" + +namespace SoLoud +{ + class AudioSource; + class AudioSourceInstance; + class AudioSourceInstance3dData; + + class AudioCollider + { + public: + // Calculate volume multiplier. Assumed to return value between 0 and 1. + virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0; + }; + + class AudioAttenuator + { + public: + virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0; + }; + + class AudioSourceInstance3dData + { + public: + // ctor + AudioSourceInstance3dData(); + // Set settings from audiosource + void init(AudioSource &aSource); + // 3d position + float m3dPosition[3]; + // 3d velocity + float m3dVelocity[3]; + // 3d cone direction + /* + float m3dConeDirection[3]; + // 3d cone inner angle + float m3dConeInnerAngle; + // 3d cone outer angle + float m3dConeOuterAngle; + // 3d cone outer volume multiplier + float m3dConeOuterVolume; + */ + // 3d min distance + float m3dMinDistance; + // 3d max distance + float m3dMaxDistance; + // 3d attenuation rolloff factor + float m3dAttenuationRolloff; + // 3d attenuation model + unsigned int m3dAttenuationModel; + // 3d doppler factor + float m3dDopplerFactor; + // Pointer to a custom audio collider object + AudioCollider *mCollider; + // Pointer to a custom audio attenuator object + AudioAttenuator *mAttenuator; + // User data related to audio collider + int mColliderData; + + // Doppler sample rate multiplier + float mDopplerValue; + // Overall 3d volume + float m3dVolume; + // Channel volume + float mChannelVolume[MAX_CHANNELS]; + // Copy of flags + unsigned int mFlags; + // Latest handle for this voice + handle mHandle; + }; + + // Base class for audio instances + class AudioSourceInstance + { + public: + enum FLAGS + { + // This audio instance loops (if supported) + LOOPING = 1, + // This audio instance is protected - won't get stopped if we run out of voices + PROTECTED = 2, + // This audio instance is paused + PAUSED = 4, + // This audio instance is affected by 3d processing + PROCESS_3D = 8, + // This audio instance has listener-relative 3d coordinates + LISTENER_RELATIVE = 16, + // Currently inaudible + INAUDIBLE = 32, + // If inaudible, should be killed (default = don't kill kill) + INAUDIBLE_KILL = 64, + // If inaudible, should still be ticked (default = pause) + INAUDIBLE_TICK = 128, + // Don't auto-stop sound + DISABLE_AUTOSTOP = 256 + }; + // Ctor + AudioSourceInstance(); + // Dtor + virtual ~AudioSourceInstance(); + // Play index; used to identify instances from handles + unsigned int mPlayIndex; + // Loop count + unsigned int mLoopCount; + // Flags; see AudioSourceInstance::FLAGS + unsigned int mFlags; + // Pan value, for getPan() + float mPan; + // Volume for each channel (panning) + float mChannelVolume[MAX_CHANNELS]; + // Set volume + float mSetVolume; + // Overall volume overall = set * 3d + float mOverallVolume; + // Base samplerate; samplerate = base samplerate * relative play speed + float mBaseSamplerate; + // Samplerate; samplerate = base samplerate * relative play speed + float mSamplerate; + // Number of channels this audio source produces + unsigned int mChannels; + // Relative play speed; samplerate = base samplerate * relative play speed + float mSetRelativePlaySpeed; + // Overall relative plays peed; overall = set * 3d + float mOverallRelativePlaySpeed; + // How long this stream has played, in seconds. + time mStreamTime; + // Position of this stream, in seconds. + time mStreamPosition; + // Fader for the audio panning + Fader mPanFader; + // Fader for the audio volume + Fader mVolumeFader; + // Fader for the relative play speed + Fader mRelativePlaySpeedFader; + // Fader used to schedule pausing of the stream + Fader mPauseScheduler; + // Fader used to schedule stopping of the stream + Fader mStopScheduler; + // Affected by some fader + int mActiveFader; + // Current channel volumes, used to ramp the volume changes to avoid clicks + float mCurrentChannelVolume[MAX_CHANNELS]; + // ID of the sound source that generated this instance + unsigned int mAudioSourceID; + // Handle of the bus this audio instance is playing on. 0 for root. + unsigned int mBusHandle; + // Filter pointer + FilterInstance *mFilter[FILTERS_PER_STREAM]; + // Initialize instance. Mostly internal use. + void init(AudioSource &aSource, int aPlayIndex); + // Pointers to buffers for the resampler + float *mResampleData[2]; + // Sub-sample playhead; 16.16 fixed point + unsigned int mSrcOffset; + // Samples left over from earlier pass + unsigned int mLeftoverSamples; + // Number of samples to delay streaming + unsigned int mDelaySamples; + // When looping, start playing from this time + time mLoopPoint; + + // Get N samples from the stream to the buffer. Report samples written. + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize) = 0; + // Has the stream ended? + virtual bool hasEnded() = 0; + // Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow). + virtual result seek(time aSeconds, float *mScratch, unsigned int mScratchSize); + // Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind. + virtual result rewind(); + // Get information. Returns 0 by default. + virtual float getInfo(unsigned int aInfoKey); + }; + + class Soloud; + + // Base class for audio sources + class AudioSource + { + public: + enum FLAGS + { + // The instances from this audio source should loop + SHOULD_LOOP = 1, + // Only one instance of this audio source should play at the same time + SINGLE_INSTANCE = 2, + // Visualization data gathering enabled. Only for busses. + VISUALIZATION_DATA = 4, + // Audio instances created from this source are affected by 3d processing + PROCESS_3D = 8, + // Audio instances created from this source have listener-relative 3d coordinates + LISTENER_RELATIVE = 16, + // Delay start of sound by the distance from listener + DISTANCE_DELAY = 32, + // If inaudible, should be killed (default) + INAUDIBLE_KILL = 64, + // If inaudible, should still be ticked (default = pause) + INAUDIBLE_TICK = 128, + // Disable auto-stop + DISABLE_AUTOSTOP = 256 + }; + enum ATTENUATION_MODELS + { + // No attenuation + NO_ATTENUATION = 0, + // Inverse distance attenuation model + INVERSE_DISTANCE = 1, + // Linear distance attenuation model + LINEAR_DISTANCE = 2, + // Exponential distance attenuation model + EXPONENTIAL_DISTANCE = 3 + }; + + // Flags. See AudioSource::FLAGS + unsigned int mFlags; + // Base sample rate, used to initialize instances + float mBaseSamplerate; + // Default volume for created instances + float mVolume; + // Number of channels this audio source produces + unsigned int mChannels; + // Sound source ID. Assigned by SoLoud the first time it's played. + unsigned int mAudioSourceID; + // 3d min distance + float m3dMinDistance; + // 3d max distance + float m3dMaxDistance; + // 3d attenuation rolloff factor + float m3dAttenuationRolloff; + // 3d attenuation model + unsigned int m3dAttenuationModel; + // 3d doppler factor + float m3dDopplerFactor; + // Filter pointer + Filter *mFilter[FILTERS_PER_STREAM]; + // Pointer to the Soloud object. Needed to stop all instances in dtor. + Soloud *mSoloud; + // Pointer to a custom audio collider object + AudioCollider *mCollider; + // Pointer to custom attenuator object + AudioAttenuator *mAttenuator; + // User data related to audio collider + int mColliderData; + // When looping, start playing from this time + time mLoopPoint; + + // CTor + AudioSource(); + // Set default volume for instances + void setVolume(float aVolume); + // Set the looping of the instances created from this audio source + void setLooping(bool aLoop); + // Set whether only one instance of this sound should ever be playing at the same time + void setSingleInstance(bool aSingleInstance); + // Set whether audio should auto-stop when it ends or not + void setAutoStop(bool aAutoStop); + + // Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol) + void set3dMinMaxDistance(float aMinDistance, float aMaxDistance); + // Set attenuation model and rolloff factor for 3d audio source + void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor); + // Set doppler factor to reduce or enhance doppler effect, default = 1.0 + void set3dDopplerFactor(float aDopplerFactor); + // Set the coordinates for this audio source to be relative to listener's coordinates. + void set3dListenerRelative(bool aListenerRelative); + // Enable delaying the start of the sound based on the distance. + void set3dDistanceDelay(bool aDistanceDelay); + + // Set a custom 3d audio collider. Set to NULL to disable. + void set3dCollider(AudioCollider *aCollider, int aUserData = 0); + // Set a custom attenuator. Set to NULL to disable. + void set3dAttenuator(AudioAttenuator *aAttenuator); + + // Set behavior for inaudible sounds + void setInaudibleBehavior(bool aMustTick, bool aKill); + + // Set time to jump to when looping + void setLoopPoint(time aLoopPoint); + // Get current loop point value + time getLoopPoint(); + + // Set filter. Set to NULL to clear the filter. + virtual void setFilter(unsigned int aFilterId, Filter *aFilter); + // DTor + virtual ~AudioSource(); + // Create instance from the audio source. Called from within Soloud class. + virtual AudioSourceInstance *createInstance() = 0; + // Stop all instances of this audio source + void stop(); + }; +}; + +#endif diff --git a/include/common/soloud/soloud_ay.h b/include/common/soloud/soloud_ay.h new file mode 100644 index 0000000..d683530 --- /dev/null +++ b/include/common/soloud/soloud_ay.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_bassboostfilter.h b/include/common/soloud/soloud_bassboostfilter.h index ec91b04..074f745 100755 --- a/include/common/soloud/soloud_bassboostfilter.h +++ b/include/common/soloud/soloud_bassboostfilter.h @@ -1,63 +1,68 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_BASSBOOSTFILTER_H -#define SOLOUD_BASSBOOSTFILTER_H - -#include "soloud.h" -#include "soloud_fftfilter.h" - -namespace SoLoud -{ - class BassboostFilter; - - class BassboostFilterInstance : public FFTFilterInstance - { - enum FILTERATTRIBUTE - { - WET = 0, - BOOST = 1 - }; - BassboostFilter *mParent; - public: - virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); - BassboostFilterInstance(BassboostFilter *aParent); - }; - - class BassboostFilter : public FFTFilter - { - public: - enum FILTERATTRIBUTE - { - WET = 0, - BOOST = 1 - }; - float mBoost; - result setParams(float aBoost); - virtual FilterInstance *createInstance(); - BassboostFilter(); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_BASSBOOSTFILTER_H +#define SOLOUD_BASSBOOSTFILTER_H + +#include "soloud.h" +#include "soloud_fftfilter.h" + +namespace SoLoud +{ + class BassboostFilter; + + class BassboostFilterInstance : public FFTFilterInstance + { + enum FILTERATTRIBUTE + { + WET = 0, + BOOST = 1 + }; + BassboostFilter *mParent; + public: + virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); + BassboostFilterInstance(BassboostFilter *aParent); + }; + + class BassboostFilter : public FFTFilter + { + public: + enum FILTERATTRIBUTE + { + WET = 0, + BOOST = 1 + }; + virtual int getParamCount(); + virtual const char* getParamName(unsigned int aParamIndex); + virtual unsigned int getParamType(unsigned int aParamIndex); + virtual float getParamMax(unsigned int aParamIndex); + virtual float getParamMin(unsigned int aParamIndex); + float mBoost; + result setParams(float aBoost); + virtual FilterInstance *createInstance(); + BassboostFilter(); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_biquadresonantfilter.h b/include/common/soloud/soloud_biquadresonantfilter.h index cdf4a45..53cfe66 100755 --- a/include/common/soloud/soloud_biquadresonantfilter.h +++ b/include/common/soloud/soloud_biquadresonantfilter.h @@ -1,91 +1,94 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_BQRFILTER_H -#define SOLOUD_BQRFILTER_H - -#include "soloud.h" - -namespace SoLoud -{ - class BiquadResonantFilter; - - struct BQRStateData - { - float mY1, mY2, mX1, mX2; - }; - - class BiquadResonantFilterInstance : public FilterInstance - { - enum FILTERATTRIBUTE - { - WET = 0, - SAMPLERATE = 1, - FREQUENCY = 2, - RESONANCE = 3 - }; - - int mActive; - BQRStateData mState[2]; - float mA0, mA1, mA2, mB1, mB2; - int mDirty; - int mFilterType; - - BiquadResonantFilter *mParent; - void calcBQRParams(); - public: - virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); - virtual ~BiquadResonantFilterInstance(); - BiquadResonantFilterInstance(BiquadResonantFilter *aParent); - }; - - class BiquadResonantFilter : public Filter - { - public: - enum FILTERTYPE - { - NONE = 0, - LOWPASS = 1, - HIGHPASS = 2, - BANDPASS = 3 - }; - enum FILTERATTRIBUTE - { - WET = 0, - SAMPLERATE = 1, - FREQUENCY = 2, - RESONANCE = 3 - }; - int mFilterType; - float mSampleRate; - float mFrequency; - float mResonance; - virtual BiquadResonantFilterInstance *createInstance(); - BiquadResonantFilter(); - result setParams(int aType, float aSampleRate, float aFrequency, float aResonance); - virtual ~BiquadResonantFilter(); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2014 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_BQRFILTER_H +#define SOLOUD_BQRFILTER_H + +#include "soloud.h" + +namespace SoLoud +{ + class BiquadResonantFilter; + + struct BQRStateData + { + float mY1, mY2, mX1, mX2; + }; + + class BiquadResonantFilterInstance : public FilterInstance + { + enum FILTERATTRIBUTE + { + WET = 0, + TYPE, + FREQUENCY, + RESONANCE + }; + + BQRStateData mState[8]; + float mA0, mA1, mA2, mB1, mB2; + int mDirty; + float mSamplerate; + + BiquadResonantFilter *mParent; + void calcBQRParams(); + public: + virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); + virtual ~BiquadResonantFilterInstance(); + BiquadResonantFilterInstance(BiquadResonantFilter *aParent); + }; + + class BiquadResonantFilter : public Filter + { + public: + enum FILTERTYPE + { + LOWPASS = 0, + HIGHPASS = 1, + BANDPASS = 2 + }; + enum FILTERATTRIBUTE + { + WET = 0, + TYPE, + FREQUENCY, + RESONANCE + }; + int mFilterType; + float mFrequency; + float mResonance; + virtual int getParamCount(); + virtual const char* getParamName(unsigned int aParamIndex); + virtual unsigned int getParamType(unsigned int aParamIndex); + virtual float getParamMax(unsigned int aParamIndex); + virtual float getParamMin(unsigned int aParamIndex); + + virtual BiquadResonantFilterInstance *createInstance(); + BiquadResonantFilter(); + result setParams(int aType, float aFrequency, float aResonance); + virtual ~BiquadResonantFilter(); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_bus.h b/include/common/soloud/soloud_bus.h index 495c154..8bf3713 100755 --- a/include/common/soloud/soloud_bus.h +++ b/include/common/soloud/soloud_bus.h @@ -1,86 +1,102 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_BUS_H -#define SOLOUD_BUS_H - -#include "soloud.h" - -namespace SoLoud -{ - class Bus; - - class BusInstance : public AudioSourceInstance - { - Bus *mParent; - unsigned int mScratchSize; - AlignedFloatBuffer mScratch; - public: - // Mono-mixed wave data for visualization and for visualization FFT input - float mVisualizationWaveData[256]; - - BusInstance(Bus *aParent); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual bool hasEnded(); - virtual ~BusInstance(); - }; - - class Bus : public AudioSource - { - public: - Bus(); - virtual BusInstance *createInstance(); - // Set filter. Set to NULL to clear the filter. - virtual void setFilter(unsigned int aFilterId, Filter *aFilter); - // Play sound through the bus - handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0); - // Play sound through the bus, delayed in relation to other sounds called via this function. - handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f); - // Start playing a 3d audio source through the bus - handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0); - // Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function. - handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f); - // Set number of channels for the bus (default 2) - result setChannels(unsigned int aChannels); - // Enable or disable visualization data gathering - void setVisualizationEnable(bool aEnable); - - // Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use. - float *calcFFT(); - - // Get 256 floats of wave data for visualization. Visualization has to be enabled before use. - float *getWave(); - public: - BusInstance *mInstance; - unsigned int mChannelHandle; - // FFT output data - float mFFTData[256]; - // Snapshot of wave data for visualization - float mWaveData[256]; - // Internal: find the bus' channel - void findBusHandle(); - }; -}; - +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_BUS_H +#define SOLOUD_BUS_H + +#include "soloud.h" + +namespace SoLoud +{ + class Bus; + + class BusInstance : public AudioSourceInstance + { + Bus *mParent; + unsigned int mScratchSize; + AlignedFloatBuffer mScratch; + public: + // Approximate volume for channels. + float mVisualizationChannelVolume[MAX_CHANNELS]; + // Mono-mixed wave data for visualization and for visualization FFT input + float mVisualizationWaveData[256]; + + BusInstance(Bus *aParent); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual bool hasEnded(); + virtual ~BusInstance(); + }; + + class Bus : public AudioSource + { + public: + Bus(); + virtual BusInstance *createInstance(); + // Set filter. Set to NULL to clear the filter. + virtual void setFilter(unsigned int aFilterId, Filter *aFilter); + // Play sound through the bus + handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0); + // Play sound through the bus, delayed in relation to other sounds called via this function. + handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f); + // Start playing a 3d audio source through the bus + handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0); + // Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function. + handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f); + // Set number of channels for the bus (default 2) + result setChannels(unsigned int aChannels); + // Enable or disable visualization data gathering + void setVisualizationEnable(bool aEnable); + // Move a live sound to this bus + void annexSound(handle aVoiceHandle); + + // Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use. + float *calcFFT(); + + // Get 256 floats of wave data for visualization. Visualization has to be enabled before use. + float *getWave(); + + // Get approximate volume for output channel for visualization. Visualization has to be enabled before use. + float getApproximateVolume(unsigned int aChannel); + + // Get number of immediate child voices to this bus + unsigned int getActiveVoiceCount(); + + // Get current the resampler for this bus + unsigned int getResampler(); + // Set the resampler for this bus + void setResampler(unsigned int aResampler); + public: + BusInstance *mInstance; + unsigned int mChannelHandle; + unsigned int mResampler; + // FFT output data + float mFFTData[256]; + // Snapshot of wave data for visualization + float mWaveData[256]; + // Internal: find the bus' channel + void findBusHandle(); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_c.h b/include/common/soloud/soloud_c.h index 45dc57c..bac939c 100755 --- a/include/common/soloud/soloud_c.h +++ b/include/common/soloud/soloud_c.h @@ -1,490 +1,761 @@ -/* ************************************************** - * WARNING: this is a generated file. Do not edit. * - * Any edits will be overwritten by the generator. * - ************************************************** */ - -/* -SoLoud audio engine -Copyright (c) 2013-2016 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -/* SoLoud C-Api Code Generator (c)2013-2016 Jari Komppa http://iki.fi/sol/ */ - -#ifndef SOLOUD_C_H_INCLUDED -#define SOLOUD_C_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif -// Collected enumerations -enum SOLOUD_ENUMS -{ - SOLOUD_AUTO = 0, - SOLOUD_SDL = 1, - SOLOUD_SDL2 = 2, - SOLOUD_PORTAUDIO = 3, - SOLOUD_WINMM = 4, - SOLOUD_XAUDIO2 = 5, - SOLOUD_WASAPI = 6, - SOLOUD_ALSA = 7, - SOLOUD_OSS = 8, - SOLOUD_OPENAL = 9, - SOLOUD_COREAUDIO = 10, - SOLOUD_OPENSLES = 11, - SOLOUD_NULLDRIVER = 12, - SOLOUD_BACKEND_MAX = 13, - SOLOUD_CLIP_ROUNDOFF = 1, - SOLOUD_ENABLE_VISUALIZATION = 2, - SOLOUD_LEFT_HANDED_3D = 4, - BIQUADRESONANTFILTER_NONE = 0, - BIQUADRESONANTFILTER_LOWPASS = 1, - BIQUADRESONANTFILTER_HIGHPASS = 2, - BIQUADRESONANTFILTER_BANDPASS = 3, - BIQUADRESONANTFILTER_WET = 0, - BIQUADRESONANTFILTER_SAMPLERATE = 1, - BIQUADRESONANTFILTER_FREQUENCY = 2, - BIQUADRESONANTFILTER_RESONANCE = 3, - LOFIFILTER_WET = 0, - LOFIFILTER_SAMPLERATE = 1, - LOFIFILTER_BITDEPTH = 2, - BASSBOOSTFILTER_WET = 0, - BASSBOOSTFILTER_BOOST = 1, - SFXR_COIN = 0, - SFXR_LASER = 1, - SFXR_EXPLOSION = 2, - SFXR_POWERUP = 3, - SFXR_HURT = 4, - SFXR_JUMP = 5, - SFXR_BLIP = 6, - FLANGERFILTER_WET = 0, - FLANGERFILTER_DELAY = 1, - FLANGERFILTER_FREQ = 2, - MONOTONE_SQUARE = 0, - MONOTONE_SAW = 1, - MONOTONE_SIN = 2, - MONOTONE_SAWSIN = 3 -}; - -// Object handle typedefs -typedef void * AlignedFloatBuffer; -typedef void * Soloud; -typedef void * AudioCollider; -typedef void * AudioAttenuator; -typedef void * AudioSource; -typedef void * BiquadResonantFilter; -typedef void * LofiFilter; -typedef void * Bus; -typedef void * EchoFilter; -typedef void * Fader; -typedef void * FFTFilter; -typedef void * BassboostFilter; -typedef void * Filter; -typedef void * Speech; -typedef void * Wav; -typedef void * WavStream; -typedef void * Prg; -typedef void * Sfxr; -typedef void * FlangerFilter; -typedef void * DCRemovalFilter; -typedef void * Openmpt; -typedef void * Monotone; -typedef void * TedSid; -typedef void * File; - -/* - * Soloud - */ -void Soloud_destroy(Soloud * aSoloud); -Soloud * Soloud_create(); -int Soloud_init(Soloud * aSoloud); -int Soloud_initEx(Soloud * aSoloud, unsigned int aFlags /* = Soloud::CLIP_ROUNDOFF */, unsigned int aBackend /* = Soloud::AUTO */, unsigned int aSamplerate /* = Soloud::AUTO */, unsigned int aBufferSize /* = Soloud::AUTO */, unsigned int aChannels /* = 2 */); -void Soloud_deinit(Soloud * aSoloud); -unsigned int Soloud_getVersion(Soloud * aSoloud); -const char * Soloud_getErrorString(Soloud * aSoloud, int aErrorCode); -unsigned int Soloud_getBackendId(Soloud * aSoloud); -const char * Soloud_getBackendString(Soloud * aSoloud); -unsigned int Soloud_getBackendChannels(Soloud * aSoloud); -unsigned int Soloud_getBackendSamplerate(Soloud * aSoloud); -unsigned int Soloud_getBackendBufferSize(Soloud * aSoloud); -int Soloud_setSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float aX, float aY, float aZ); -unsigned int Soloud_play(Soloud * aSoloud, AudioSource * aSound); -unsigned int Soloud_playEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); -unsigned int Soloud_playClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound); -unsigned int Soloud_playClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, unsigned int aBus /* = 0 */); -unsigned int Soloud_play3d(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); -unsigned int Soloud_play3dEx(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); -unsigned int Soloud_play3dClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); -unsigned int Soloud_play3dClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, unsigned int aBus /* = 0 */); -void Soloud_seek(Soloud * aSoloud, unsigned int aVoiceHandle, double aSeconds); -void Soloud_stop(Soloud * aSoloud, unsigned int aVoiceHandle); -void Soloud_stopAll(Soloud * aSoloud); -void Soloud_stopAudioSource(Soloud * aSoloud, AudioSource * aSound); -void Soloud_setFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); -float Soloud_getFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); -void Soloud_fadeFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, double aTime); -void Soloud_oscillateFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, double aTime); -double Soloud_getStreamTime(Soloud * aSoloud, unsigned int aVoiceHandle); -int Soloud_getPause(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getVolume(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getOverallVolume(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getPan(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle); -int Soloud_getProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle); -unsigned int Soloud_getActiveVoiceCount(Soloud * aSoloud); -unsigned int Soloud_getVoiceCount(Soloud * aSoloud); -int Soloud_isValidVoiceHandle(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getPostClipScaler(Soloud * aSoloud); -float Soloud_getGlobalVolume(Soloud * aSoloud); -unsigned int Soloud_getMaxActiveVoiceCount(Soloud * aSoloud); -int Soloud_getLooping(Soloud * aSoloud, unsigned int aVoiceHandle); -void Soloud_setLooping(Soloud * aSoloud, unsigned int aVoiceHandle, int aLooping); -int Soloud_setMaxActiveVoiceCount(Soloud * aSoloud, unsigned int aVoiceCount); -void Soloud_setInaudibleBehavior(Soloud * aSoloud, unsigned int aVoiceHandle, int aMustTick, int aKill); -void Soloud_setGlobalVolume(Soloud * aSoloud, float aVolume); -void Soloud_setPostClipScaler(Soloud * aSoloud, float aScaler); -void Soloud_setPause(Soloud * aSoloud, unsigned int aVoiceHandle, int aPause); -void Soloud_setPauseAll(Soloud * aSoloud, int aPause); -int Soloud_setRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aSpeed); -void Soloud_setProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle, int aProtect); -void Soloud_setSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle, float aSamplerate); -void Soloud_setPan(Soloud * aSoloud, unsigned int aVoiceHandle, float aPan); -void Soloud_setPanAbsolute(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume); -void Soloud_setPanAbsoluteEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume /* = 0 */, float aRBVolume /* = 0 */, float aCVolume /* = 0 */, float aSVolume /* = 0 */); -void Soloud_setVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aVolume); -void Soloud_setDelaySamples(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aSamples); -void Soloud_fadeVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); -void Soloud_fadePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); -void Soloud_fadeRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); -void Soloud_fadeGlobalVolume(Soloud * aSoloud, float aTo, double aTime); -void Soloud_schedulePause(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); -void Soloud_scheduleStop(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); -void Soloud_oscillateVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); -void Soloud_oscillatePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); -void Soloud_oscillateRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); -void Soloud_oscillateGlobalVolume(Soloud * aSoloud, float aFrom, float aTo, double aTime); -void Soloud_setGlobalFilter(Soloud * aSoloud, unsigned int aFilterId, Filter * aFilter); -void Soloud_setVisualizationEnable(Soloud * aSoloud, int aEnable); -float * Soloud_calcFFT(Soloud * aSoloud); -float * Soloud_getWave(Soloud * aSoloud); -unsigned int Soloud_getLoopCount(Soloud * aSoloud, unsigned int aVoiceHandle); -float Soloud_getInfo(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aInfoKey); -unsigned int Soloud_createVoiceGroup(Soloud * aSoloud); -int Soloud_destroyVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); -int Soloud_addVoiceToGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle, unsigned int aVoiceHandle); -int Soloud_isVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); -int Soloud_isVoiceGroupEmpty(Soloud * aSoloud, unsigned int aVoiceGroupHandle); -void Soloud_update3dAudio(Soloud * aSoloud); -int Soloud_set3dSoundSpeed(Soloud * aSoloud, float aSpeed); -float Soloud_get3dSoundSpeed(Soloud * aSoloud); -void Soloud_set3dListenerParameters(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ); -void Soloud_set3dListenerParametersEx(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); -void Soloud_set3dListenerPosition(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ); -void Soloud_set3dListenerAt(Soloud * aSoloud, float aAtX, float aAtY, float aAtZ); -void Soloud_set3dListenerUp(Soloud * aSoloud, float aUpX, float aUpY, float aUpZ); -void Soloud_set3dListenerVelocity(Soloud * aSoloud, float aVelocityX, float aVelocityY, float aVelocityZ); -void Soloud_set3dSourceParameters(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); -void Soloud_set3dSourceParametersEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); -void Soloud_set3dSourcePosition(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); -void Soloud_set3dSourceVelocity(Soloud * aSoloud, unsigned int aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); -void Soloud_set3dSourceMinMaxDistance(Soloud * aSoloud, unsigned int aVoiceHandle, float aMinDistance, float aMaxDistance); -void Soloud_set3dSourceAttenuation(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Soloud_set3dSourceDopplerFactor(Soloud * aSoloud, unsigned int aVoiceHandle, float aDopplerFactor); -void Soloud_mix(Soloud * aSoloud, float * aBuffer, unsigned int aSamples); -void Soloud_mixSigned16(Soloud * aSoloud, short * aBuffer, unsigned int aSamples); - -/* - * AudioAttenuator - */ -void AudioAttenuator_destroy(AudioAttenuator * aAudioAttenuator); -float AudioAttenuator_attenuate(AudioAttenuator * aAudioAttenuator, float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor); - -/* - * BiquadResonantFilter - */ -void BiquadResonantFilter_destroy(BiquadResonantFilter * aBiquadResonantFilter); -BiquadResonantFilter * BiquadResonantFilter_create(); -int BiquadResonantFilter_setParams(BiquadResonantFilter * aBiquadResonantFilter, int aType, float aSampleRate, float aFrequency, float aResonance); - -/* - * LofiFilter - */ -void LofiFilter_destroy(LofiFilter * aLofiFilter); -LofiFilter * LofiFilter_create(); -int LofiFilter_setParams(LofiFilter * aLofiFilter, float aSampleRate, float aBitdepth); - -/* - * Bus - */ -void Bus_destroy(Bus * aBus); -Bus * Bus_create(); -void Bus_setFilter(Bus * aBus, unsigned int aFilterId, Filter * aFilter); -unsigned int Bus_play(Bus * aBus, AudioSource * aSound); -unsigned int Bus_playEx(Bus * aBus, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */); -unsigned int Bus_playClocked(Bus * aBus, double aSoundTime, AudioSource * aSound); -unsigned int Bus_playClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */); -unsigned int Bus_play3d(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); -unsigned int Bus_play3dEx(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */); -unsigned int Bus_play3dClocked(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); -unsigned int Bus_play3dClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */); -int Bus_setChannels(Bus * aBus, unsigned int aChannels); -void Bus_setVisualizationEnable(Bus * aBus, int aEnable); -float * Bus_calcFFT(Bus * aBus); -float * Bus_getWave(Bus * aBus); -void Bus_setVolume(Bus * aBus, float aVolume); -void Bus_setLooping(Bus * aBus, int aLoop); -void Bus_set3dMinMaxDistance(Bus * aBus, float aMinDistance, float aMaxDistance); -void Bus_set3dAttenuation(Bus * aBus, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Bus_set3dDopplerFactor(Bus * aBus, float aDopplerFactor); -void Bus_set3dProcessing(Bus * aBus, int aDo3dProcessing); -void Bus_set3dListenerRelative(Bus * aBus, int aListenerRelative); -void Bus_set3dDistanceDelay(Bus * aBus, int aDistanceDelay); -void Bus_set3dCollider(Bus * aBus, AudioCollider * aCollider); -void Bus_set3dColliderEx(Bus * aBus, AudioCollider * aCollider, int aUserData /* = 0 */); -void Bus_set3dAttenuator(Bus * aBus, AudioAttenuator * aAttenuator); -void Bus_setInaudibleBehavior(Bus * aBus, int aMustTick, int aKill); -void Bus_stop(Bus * aBus); - -/* - * EchoFilter - */ -void EchoFilter_destroy(EchoFilter * aEchoFilter); -EchoFilter * EchoFilter_create(); -int EchoFilter_setParams(EchoFilter * aEchoFilter, float aDelay); -int EchoFilter_setParamsEx(EchoFilter * aEchoFilter, float aDelay, float aDecay /* = 0.7f */, float aFilter /* = 0.0f */); - -/* - * FFTFilter - */ -void FFTFilter_destroy(FFTFilter * aFFTFilter); -FFTFilter * FFTFilter_create(); - -/* - * BassboostFilter - */ -void BassboostFilter_destroy(BassboostFilter * aBassboostFilter); -int BassboostFilter_setParams(BassboostFilter * aBassboostFilter, float aBoost); -BassboostFilter * BassboostFilter_create(); - -/* - * Speech - */ -void Speech_destroy(Speech * aSpeech); -Speech * Speech_create(); -int Speech_setText(Speech * aSpeech, const char * aText); -void Speech_setVolume(Speech * aSpeech, float aVolume); -void Speech_setLooping(Speech * aSpeech, int aLoop); -void Speech_set3dMinMaxDistance(Speech * aSpeech, float aMinDistance, float aMaxDistance); -void Speech_set3dAttenuation(Speech * aSpeech, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Speech_set3dDopplerFactor(Speech * aSpeech, float aDopplerFactor); -void Speech_set3dProcessing(Speech * aSpeech, int aDo3dProcessing); -void Speech_set3dListenerRelative(Speech * aSpeech, int aListenerRelative); -void Speech_set3dDistanceDelay(Speech * aSpeech, int aDistanceDelay); -void Speech_set3dCollider(Speech * aSpeech, AudioCollider * aCollider); -void Speech_set3dColliderEx(Speech * aSpeech, AudioCollider * aCollider, int aUserData /* = 0 */); -void Speech_set3dAttenuator(Speech * aSpeech, AudioAttenuator * aAttenuator); -void Speech_setInaudibleBehavior(Speech * aSpeech, int aMustTick, int aKill); -void Speech_setFilter(Speech * aSpeech, unsigned int aFilterId, Filter * aFilter); -void Speech_stop(Speech * aSpeech); - -/* - * Wav - */ -void Wav_destroy(Wav * aWav); -Wav * Wav_create(); -int Wav_load(Wav * aWav, const char * aFilename); -int Wav_loadMem(Wav * aWav, unsigned char * aMem, unsigned int aLength); -int Wav_loadMemEx(Wav * aWav, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); -int Wav_loadFile(Wav * aWav, File * aFile); -double Wav_getLength(Wav * aWav); -void Wav_setVolume(Wav * aWav, float aVolume); -void Wav_setLooping(Wav * aWav, int aLoop); -void Wav_set3dMinMaxDistance(Wav * aWav, float aMinDistance, float aMaxDistance); -void Wav_set3dAttenuation(Wav * aWav, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Wav_set3dDopplerFactor(Wav * aWav, float aDopplerFactor); -void Wav_set3dProcessing(Wav * aWav, int aDo3dProcessing); -void Wav_set3dListenerRelative(Wav * aWav, int aListenerRelative); -void Wav_set3dDistanceDelay(Wav * aWav, int aDistanceDelay); -void Wav_set3dCollider(Wav * aWav, AudioCollider * aCollider); -void Wav_set3dColliderEx(Wav * aWav, AudioCollider * aCollider, int aUserData /* = 0 */); -void Wav_set3dAttenuator(Wav * aWav, AudioAttenuator * aAttenuator); -void Wav_setInaudibleBehavior(Wav * aWav, int aMustTick, int aKill); -void Wav_setFilter(Wav * aWav, unsigned int aFilterId, Filter * aFilter); -void Wav_stop(Wav * aWav); - -/* - * WavStream - */ -void WavStream_destroy(WavStream * aWavStream); -WavStream * WavStream_create(); -int WavStream_load(WavStream * aWavStream, const char * aFilename); -int WavStream_loadMem(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen); -int WavStream_loadMemEx(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen, int aCopy /* = false */, int aTakeOwnership /* = true */); -int WavStream_loadToMem(WavStream * aWavStream, const char * aFilename); -int WavStream_loadFile(WavStream * aWavStream, File * aFile); -int WavStream_loadFileToMem(WavStream * aWavStream, File * aFile); -double WavStream_getLength(WavStream * aWavStream); -void WavStream_setVolume(WavStream * aWavStream, float aVolume); -void WavStream_setLooping(WavStream * aWavStream, int aLoop); -void WavStream_set3dMinMaxDistance(WavStream * aWavStream, float aMinDistance, float aMaxDistance); -void WavStream_set3dAttenuation(WavStream * aWavStream, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void WavStream_set3dDopplerFactor(WavStream * aWavStream, float aDopplerFactor); -void WavStream_set3dProcessing(WavStream * aWavStream, int aDo3dProcessing); -void WavStream_set3dListenerRelative(WavStream * aWavStream, int aListenerRelative); -void WavStream_set3dDistanceDelay(WavStream * aWavStream, int aDistanceDelay); -void WavStream_set3dCollider(WavStream * aWavStream, AudioCollider * aCollider); -void WavStream_set3dColliderEx(WavStream * aWavStream, AudioCollider * aCollider, int aUserData /* = 0 */); -void WavStream_set3dAttenuator(WavStream * aWavStream, AudioAttenuator * aAttenuator); -void WavStream_setInaudibleBehavior(WavStream * aWavStream, int aMustTick, int aKill); -void WavStream_setFilter(WavStream * aWavStream, unsigned int aFilterId, Filter * aFilter); -void WavStream_stop(WavStream * aWavStream); - -/* - * Prg - */ -void Prg_destroy(Prg * aPrg); -Prg * Prg_create(); -unsigned int Prg_rand(Prg * aPrg); -void Prg_srand(Prg * aPrg, int aSeed); - -/* - * Sfxr - */ -void Sfxr_destroy(Sfxr * aSfxr); -Sfxr * Sfxr_create(); -void Sfxr_resetParams(Sfxr * aSfxr); -int Sfxr_loadParams(Sfxr * aSfxr, const char * aFilename); -int Sfxr_loadParamsMem(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength); -int Sfxr_loadParamsMemEx(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); -int Sfxr_loadParamsFile(Sfxr * aSfxr, File * aFile); -int Sfxr_loadPreset(Sfxr * aSfxr, int aPresetNo, int aRandSeed); -void Sfxr_setVolume(Sfxr * aSfxr, float aVolume); -void Sfxr_setLooping(Sfxr * aSfxr, int aLoop); -void Sfxr_set3dMinMaxDistance(Sfxr * aSfxr, float aMinDistance, float aMaxDistance); -void Sfxr_set3dAttenuation(Sfxr * aSfxr, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Sfxr_set3dDopplerFactor(Sfxr * aSfxr, float aDopplerFactor); -void Sfxr_set3dProcessing(Sfxr * aSfxr, int aDo3dProcessing); -void Sfxr_set3dListenerRelative(Sfxr * aSfxr, int aListenerRelative); -void Sfxr_set3dDistanceDelay(Sfxr * aSfxr, int aDistanceDelay); -void Sfxr_set3dCollider(Sfxr * aSfxr, AudioCollider * aCollider); -void Sfxr_set3dColliderEx(Sfxr * aSfxr, AudioCollider * aCollider, int aUserData /* = 0 */); -void Sfxr_set3dAttenuator(Sfxr * aSfxr, AudioAttenuator * aAttenuator); -void Sfxr_setInaudibleBehavior(Sfxr * aSfxr, int aMustTick, int aKill); -void Sfxr_setFilter(Sfxr * aSfxr, unsigned int aFilterId, Filter * aFilter); -void Sfxr_stop(Sfxr * aSfxr); - -/* - * FlangerFilter - */ -void FlangerFilter_destroy(FlangerFilter * aFlangerFilter); -FlangerFilter * FlangerFilter_create(); -int FlangerFilter_setParams(FlangerFilter * aFlangerFilter, float aDelay, float aFreq); - -/* - * DCRemovalFilter - */ -void DCRemovalFilter_destroy(DCRemovalFilter * aDCRemovalFilter); -DCRemovalFilter * DCRemovalFilter_create(); -int DCRemovalFilter_setParams(DCRemovalFilter * aDCRemovalFilter); -int DCRemovalFilter_setParamsEx(DCRemovalFilter * aDCRemovalFilter, float aLength /* = 0.1f */); - -/* - * Openmpt - */ -void Openmpt_destroy(Openmpt * aOpenmpt); -Openmpt * Openmpt_create(); -int Openmpt_load(Openmpt * aOpenmpt, const char * aFilename); -int Openmpt_loadMem(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength); -int Openmpt_loadMemEx(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); -int Openmpt_loadFile(Openmpt * aOpenmpt, File * aFile); -void Openmpt_setVolume(Openmpt * aOpenmpt, float aVolume); -void Openmpt_setLooping(Openmpt * aOpenmpt, int aLoop); -void Openmpt_set3dMinMaxDistance(Openmpt * aOpenmpt, float aMinDistance, float aMaxDistance); -void Openmpt_set3dAttenuation(Openmpt * aOpenmpt, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Openmpt_set3dDopplerFactor(Openmpt * aOpenmpt, float aDopplerFactor); -void Openmpt_set3dProcessing(Openmpt * aOpenmpt, int aDo3dProcessing); -void Openmpt_set3dListenerRelative(Openmpt * aOpenmpt, int aListenerRelative); -void Openmpt_set3dDistanceDelay(Openmpt * aOpenmpt, int aDistanceDelay); -void Openmpt_set3dCollider(Openmpt * aOpenmpt, AudioCollider * aCollider); -void Openmpt_set3dColliderEx(Openmpt * aOpenmpt, AudioCollider * aCollider, int aUserData /* = 0 */); -void Openmpt_set3dAttenuator(Openmpt * aOpenmpt, AudioAttenuator * aAttenuator); -void Openmpt_setInaudibleBehavior(Openmpt * aOpenmpt, int aMustTick, int aKill); -void Openmpt_setFilter(Openmpt * aOpenmpt, unsigned int aFilterId, Filter * aFilter); -void Openmpt_stop(Openmpt * aOpenmpt); - -/* - * Monotone - */ -void Monotone_destroy(Monotone * aMonotone); -Monotone * Monotone_create(); -int Monotone_setParams(Monotone * aMonotone, int aHardwareChannels); -int Monotone_setParamsEx(Monotone * aMonotone, int aHardwareChannels, int aWaveform /* = SQUARE */); -int Monotone_load(Monotone * aMonotone, const char * aFilename); -int Monotone_loadMem(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength); -int Monotone_loadMemEx(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); -int Monotone_loadFile(Monotone * aMonotone, File * aFile); -void Monotone_setVolume(Monotone * aMonotone, float aVolume); -void Monotone_setLooping(Monotone * aMonotone, int aLoop); -void Monotone_set3dMinMaxDistance(Monotone * aMonotone, float aMinDistance, float aMaxDistance); -void Monotone_set3dAttenuation(Monotone * aMonotone, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void Monotone_set3dDopplerFactor(Monotone * aMonotone, float aDopplerFactor); -void Monotone_set3dProcessing(Monotone * aMonotone, int aDo3dProcessing); -void Monotone_set3dListenerRelative(Monotone * aMonotone, int aListenerRelative); -void Monotone_set3dDistanceDelay(Monotone * aMonotone, int aDistanceDelay); -void Monotone_set3dCollider(Monotone * aMonotone, AudioCollider * aCollider); -void Monotone_set3dColliderEx(Monotone * aMonotone, AudioCollider * aCollider, int aUserData /* = 0 */); -void Monotone_set3dAttenuator(Monotone * aMonotone, AudioAttenuator * aAttenuator); -void Monotone_setInaudibleBehavior(Monotone * aMonotone, int aMustTick, int aKill); -void Monotone_setFilter(Monotone * aMonotone, unsigned int aFilterId, Filter * aFilter); -void Monotone_stop(Monotone * aMonotone); - -/* - * TedSid - */ -void TedSid_destroy(TedSid * aTedSid); -TedSid * TedSid_create(); -int TedSid_load(TedSid * aTedSid, const char * aFilename); -int TedSid_loadToMem(TedSid * aTedSid, const char * aFilename); -int TedSid_loadMem(TedSid * aTedSid, unsigned char * aMem, unsigned int aLength); -int TedSid_loadMemEx(TedSid * aTedSid, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); -int TedSid_loadFileToMem(TedSid * aTedSid, File * aFile); -int TedSid_loadFile(TedSid * aTedSid, File * aFile); -void TedSid_setVolume(TedSid * aTedSid, float aVolume); -void TedSid_setLooping(TedSid * aTedSid, int aLoop); -void TedSid_set3dMinMaxDistance(TedSid * aTedSid, float aMinDistance, float aMaxDistance); -void TedSid_set3dAttenuation(TedSid * aTedSid, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); -void TedSid_set3dDopplerFactor(TedSid * aTedSid, float aDopplerFactor); -void TedSid_set3dProcessing(TedSid * aTedSid, int aDo3dProcessing); -void TedSid_set3dListenerRelative(TedSid * aTedSid, int aListenerRelative); -void TedSid_set3dDistanceDelay(TedSid * aTedSid, int aDistanceDelay); -void TedSid_set3dCollider(TedSid * aTedSid, AudioCollider * aCollider); -void TedSid_set3dColliderEx(TedSid * aTedSid, AudioCollider * aCollider, int aUserData /* = 0 */); -void TedSid_set3dAttenuator(TedSid * aTedSid, AudioAttenuator * aAttenuator); -void TedSid_setInaudibleBehavior(TedSid * aTedSid, int aMustTick, int aKill); -void TedSid_setFilter(TedSid * aTedSid, unsigned int aFilterId, Filter * aFilter); -void TedSid_stop(TedSid * aTedSid); -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // SOLOUD_C_H_INCLUDED - +/* ************************************************** + * WARNING: this is a generated file. Do not edit. * + * Any edits will be overwritten by the generator. * + ************************************************** */ + +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +/* SoLoud C-Api Code Generator (c)2013-2020 Jari Komppa http://iki.fi/sol/ */ + +#ifndef SOLOUD_C_H_INCLUDED +#define SOLOUD_C_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif +// Collected enumerations +enum SOLOUD_ENUMS +{ + SOLOUD_AUTO = 0, + SOLOUD_SDL1 = 1, + SOLOUD_SDL2 = 2, + SOLOUD_PORTAUDIO = 3, + SOLOUD_WINMM = 4, + SOLOUD_XAUDIO2 = 5, + SOLOUD_WASAPI = 6, + SOLOUD_ALSA = 7, + SOLOUD_JACK = 8, + SOLOUD_OSS = 9, + SOLOUD_OPENAL = 10, + SOLOUD_COREAUDIO = 11, + SOLOUD_OPENSLES = 12, + SOLOUD_VITA_HOMEBREW = 13, + SOLOUD_MINIAUDIO = 14, + SOLOUD_NOSOUND = 15, + SOLOUD_NULLDRIVER = 16, + SOLOUD_BACKEND_MAX = 17, + SOLOUD_CLIP_ROUNDOFF = 1, + SOLOUD_ENABLE_VISUALIZATION = 2, + SOLOUD_LEFT_HANDED_3D = 4, + SOLOUD_NO_FPU_REGISTER_CHANGE = 8, + SOLOUD_WAVE_SQUARE = 0, + SOLOUD_WAVE_SAW = 1, + SOLOUD_WAVE_SIN = 2, + SOLOUD_WAVE_TRIANGLE = 3, + SOLOUD_WAVE_BOUNCE = 4, + SOLOUD_WAVE_JAWS = 5, + SOLOUD_WAVE_HUMPS = 6, + SOLOUD_WAVE_FSQUARE = 7, + SOLOUD_WAVE_FSAW = 8, + SOLOUD_RESAMPLER_POINT = 0, + SOLOUD_RESAMPLER_LINEAR = 1, + SOLOUD_RESAMPLER_CATMULLROM = 2, + BASSBOOSTFILTER_WET = 0, + BASSBOOSTFILTER_BOOST = 1, + BIQUADRESONANTFILTER_LOWPASS = 0, + BIQUADRESONANTFILTER_HIGHPASS = 1, + BIQUADRESONANTFILTER_BANDPASS = 2, + BIQUADRESONANTFILTER_WET = 0, + BIQUADRESONANTFILTER_TYPE = 1, + BIQUADRESONANTFILTER_FREQUENCY = 2, + BIQUADRESONANTFILTER_RESONANCE = 3, + ECHOFILTER_WET = 0, + ECHOFILTER_DELAY = 1, + ECHOFILTER_DECAY = 2, + ECHOFILTER_FILTER = 3, + FLANGERFILTER_WET = 0, + FLANGERFILTER_DELAY = 1, + FLANGERFILTER_FREQ = 2, + FREEVERBFILTER_WET = 0, + FREEVERBFILTER_FREEZE = 1, + FREEVERBFILTER_ROOMSIZE = 2, + FREEVERBFILTER_DAMP = 3, + FREEVERBFILTER_WIDTH = 4, + LOFIFILTER_WET = 0, + LOFIFILTER_SAMPLERATE = 1, + LOFIFILTER_BITDEPTH = 2, + NOISE_WHITE = 0, + NOISE_PINK = 1, + NOISE_BROWNISH = 2, + NOISE_BLUEISH = 3, + ROBOTIZEFILTER_WET = 0, + ROBOTIZEFILTER_FREQ = 1, + ROBOTIZEFILTER_WAVE = 2, + SFXR_COIN = 0, + SFXR_LASER = 1, + SFXR_EXPLOSION = 2, + SFXR_POWERUP = 3, + SFXR_HURT = 4, + SFXR_JUMP = 5, + SFXR_BLIP = 6, + SPEECH_KW_SAW = 0, + SPEECH_KW_TRIANGLE = 1, + SPEECH_KW_SIN = 2, + SPEECH_KW_SQUARE = 3, + SPEECH_KW_PULSE = 4, + SPEECH_KW_NOISE = 5, + SPEECH_KW_WARBLE = 6, + VIC_PAL = 0, + VIC_NTSC = 1, + VIC_BASS = 0, + VIC_ALTO = 1, + VIC_SOPRANO = 2, + VIC_NOISE = 3, + VIC_MAX_REGS = 4, + WAVESHAPERFILTER_WET = 0, + WAVESHAPERFILTER_AMOUNT = 1 +}; + +// Object handle typedefs +typedef void * AlignedFloatBuffer; +typedef void * TinyAlignedFloatBuffer; +typedef void * Soloud; +typedef void * Ay; +typedef void * AudioCollider; +typedef void * AudioAttenuator; +typedef void * AudioSource; +typedef void * BassboostFilter; +typedef void * BiquadResonantFilter; +typedef void * Bus; +typedef void * DCRemovalFilter; +typedef void * EchoFilter; +typedef void * Fader; +typedef void * FFTFilter; +typedef void * Filter; +typedef void * FlangerFilter; +typedef void * FreeverbFilter; +typedef void * LofiFilter; +typedef void * Monotone; +typedef void * Noise; +typedef void * Openmpt; +typedef void * Queue; +typedef void * RobotizeFilter; +typedef void * Sfxr; +typedef void * Speech; +typedef void * TedSid; +typedef void * Vic; +typedef void * Vizsn; +typedef void * Wav; +typedef void * WaveShaperFilter; +typedef void * WavStream; +typedef void * File; + +/* + * Soloud + */ +void Soloud_destroy(Soloud * aSoloud); +Soloud * Soloud_create(); +int Soloud_init(Soloud * aSoloud); +int Soloud_initEx(Soloud * aSoloud, unsigned int aFlags /* = Soloud::CLIP_ROUNDOFF */, unsigned int aBackend /* = Soloud::AUTO */, unsigned int aSamplerate /* = Soloud::AUTO */, unsigned int aBufferSize /* = Soloud::AUTO */, unsigned int aChannels /* = 2 */); +void Soloud_deinit(Soloud * aSoloud); +unsigned int Soloud_getVersion(Soloud * aSoloud); +const char * Soloud_getErrorString(Soloud * aSoloud, int aErrorCode); +unsigned int Soloud_getBackendId(Soloud * aSoloud); +const char * Soloud_getBackendString(Soloud * aSoloud); +unsigned int Soloud_getBackendChannels(Soloud * aSoloud); +unsigned int Soloud_getBackendSamplerate(Soloud * aSoloud); +unsigned int Soloud_getBackendBufferSize(Soloud * aSoloud); +int Soloud_setSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float aX, float aY, float aZ); +int Soloud_getSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float * aX, float * aY, float * aZ); +unsigned int Soloud_play(Soloud * aSoloud, AudioSource * aSound); +unsigned int Soloud_playEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); +unsigned int Soloud_playClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound); +unsigned int Soloud_playClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, unsigned int aBus /* = 0 */); +unsigned int Soloud_play3d(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); +unsigned int Soloud_play3dEx(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); +unsigned int Soloud_play3dClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); +unsigned int Soloud_play3dClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, unsigned int aBus /* = 0 */); +unsigned int Soloud_playBackground(Soloud * aSoloud, AudioSource * aSound); +unsigned int Soloud_playBackgroundEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); +int Soloud_seek(Soloud * aSoloud, unsigned int aVoiceHandle, double aSeconds); +void Soloud_stop(Soloud * aSoloud, unsigned int aVoiceHandle); +void Soloud_stopAll(Soloud * aSoloud); +void Soloud_stopAudioSource(Soloud * aSoloud, AudioSource * aSound); +int Soloud_countAudioSource(Soloud * aSoloud, AudioSource * aSound); +void Soloud_setFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); +float Soloud_getFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); +void Soloud_fadeFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, double aTime); +void Soloud_oscillateFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, double aTime); +double Soloud_getStreamTime(Soloud * aSoloud, unsigned int aVoiceHandle); +double Soloud_getStreamPosition(Soloud * aSoloud, unsigned int aVoiceHandle); +int Soloud_getPause(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getVolume(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getOverallVolume(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getPan(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle); +int Soloud_getProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle); +unsigned int Soloud_getActiveVoiceCount(Soloud * aSoloud); +unsigned int Soloud_getVoiceCount(Soloud * aSoloud); +int Soloud_isValidVoiceHandle(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getPostClipScaler(Soloud * aSoloud); +unsigned int Soloud_getMainResampler(Soloud * aSoloud); +float Soloud_getGlobalVolume(Soloud * aSoloud); +unsigned int Soloud_getMaxActiveVoiceCount(Soloud * aSoloud); +int Soloud_getLooping(Soloud * aSoloud, unsigned int aVoiceHandle); +int Soloud_getAutoStop(Soloud * aSoloud, unsigned int aVoiceHandle); +double Soloud_getLoopPoint(Soloud * aSoloud, unsigned int aVoiceHandle); +void Soloud_setLoopPoint(Soloud * aSoloud, unsigned int aVoiceHandle, double aLoopPoint); +void Soloud_setLooping(Soloud * aSoloud, unsigned int aVoiceHandle, int aLooping); +void Soloud_setAutoStop(Soloud * aSoloud, unsigned int aVoiceHandle, int aAutoStop); +int Soloud_setMaxActiveVoiceCount(Soloud * aSoloud, unsigned int aVoiceCount); +void Soloud_setInaudibleBehavior(Soloud * aSoloud, unsigned int aVoiceHandle, int aMustTick, int aKill); +void Soloud_setGlobalVolume(Soloud * aSoloud, float aVolume); +void Soloud_setPostClipScaler(Soloud * aSoloud, float aScaler); +void Soloud_setMainResampler(Soloud * aSoloud, unsigned int aResampler); +void Soloud_setPause(Soloud * aSoloud, unsigned int aVoiceHandle, int aPause); +void Soloud_setPauseAll(Soloud * aSoloud, int aPause); +int Soloud_setRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aSpeed); +void Soloud_setProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle, int aProtect); +void Soloud_setSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle, float aSamplerate); +void Soloud_setPan(Soloud * aSoloud, unsigned int aVoiceHandle, float aPan); +void Soloud_setPanAbsolute(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume); +void Soloud_setChannelVolume(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aChannel, float aVolume); +void Soloud_setVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aVolume); +void Soloud_setDelaySamples(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aSamples); +void Soloud_fadeVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); +void Soloud_fadePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); +void Soloud_fadeRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); +void Soloud_fadeGlobalVolume(Soloud * aSoloud, float aTo, double aTime); +void Soloud_schedulePause(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); +void Soloud_scheduleStop(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); +void Soloud_oscillateVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); +void Soloud_oscillatePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); +void Soloud_oscillateRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); +void Soloud_oscillateGlobalVolume(Soloud * aSoloud, float aFrom, float aTo, double aTime); +void Soloud_setGlobalFilter(Soloud * aSoloud, unsigned int aFilterId, Filter * aFilter); +void Soloud_setVisualizationEnable(Soloud * aSoloud, int aEnable); +float * Soloud_calcFFT(Soloud * aSoloud); +float * Soloud_getWave(Soloud * aSoloud); +float Soloud_getApproximateVolume(Soloud * aSoloud, unsigned int aChannel); +unsigned int Soloud_getLoopCount(Soloud * aSoloud, unsigned int aVoiceHandle); +float Soloud_getInfo(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aInfoKey); +unsigned int Soloud_createVoiceGroup(Soloud * aSoloud); +int Soloud_destroyVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); +int Soloud_addVoiceToGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle, unsigned int aVoiceHandle); +int Soloud_isVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); +int Soloud_isVoiceGroupEmpty(Soloud * aSoloud, unsigned int aVoiceGroupHandle); +void Soloud_update3dAudio(Soloud * aSoloud); +int Soloud_set3dSoundSpeed(Soloud * aSoloud, float aSpeed); +float Soloud_get3dSoundSpeed(Soloud * aSoloud); +void Soloud_set3dListenerParameters(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ); +void Soloud_set3dListenerParametersEx(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); +void Soloud_set3dListenerPosition(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ); +void Soloud_set3dListenerAt(Soloud * aSoloud, float aAtX, float aAtY, float aAtZ); +void Soloud_set3dListenerUp(Soloud * aSoloud, float aUpX, float aUpY, float aUpZ); +void Soloud_set3dListenerVelocity(Soloud * aSoloud, float aVelocityX, float aVelocityY, float aVelocityZ); +void Soloud_set3dSourceParameters(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); +void Soloud_set3dSourceParametersEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); +void Soloud_set3dSourcePosition(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); +void Soloud_set3dSourceVelocity(Soloud * aSoloud, unsigned int aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); +void Soloud_set3dSourceMinMaxDistance(Soloud * aSoloud, unsigned int aVoiceHandle, float aMinDistance, float aMaxDistance); +void Soloud_set3dSourceAttenuation(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Soloud_set3dSourceDopplerFactor(Soloud * aSoloud, unsigned int aVoiceHandle, float aDopplerFactor); +void Soloud_mix(Soloud * aSoloud, float * aBuffer, unsigned int aSamples); +void Soloud_mixSigned16(Soloud * aSoloud, short * aBuffer, unsigned int aSamples); + +/* + * Ay + */ +void Ay_destroy(Ay * aAy); +Ay * Ay_create(); +void Ay_setVolume(Ay * aAy, float aVolume); +void Ay_setLooping(Ay * aAy, int aLoop); +void Ay_setAutoStop(Ay * aAy, int aAutoStop); +void Ay_set3dMinMaxDistance(Ay * aAy, float aMinDistance, float aMaxDistance); +void Ay_set3dAttenuation(Ay * aAy, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Ay_set3dDopplerFactor(Ay * aAy, float aDopplerFactor); +void Ay_set3dListenerRelative(Ay * aAy, int aListenerRelative); +void Ay_set3dDistanceDelay(Ay * aAy, int aDistanceDelay); +void Ay_set3dCollider(Ay * aAy, AudioCollider * aCollider); +void Ay_set3dColliderEx(Ay * aAy, AudioCollider * aCollider, int aUserData /* = 0 */); +void Ay_set3dAttenuator(Ay * aAy, AudioAttenuator * aAttenuator); +void Ay_setInaudibleBehavior(Ay * aAy, int aMustTick, int aKill); +void Ay_setLoopPoint(Ay * aAy, double aLoopPoint); +double Ay_getLoopPoint(Ay * aAy); +void Ay_setFilter(Ay * aAy, unsigned int aFilterId, Filter * aFilter); +void Ay_stop(Ay * aAy); + +/* + * BassboostFilter + */ +void BassboostFilter_destroy(BassboostFilter * aBassboostFilter); +int BassboostFilter_getParamCount(BassboostFilter * aBassboostFilter); +const char * BassboostFilter_getParamName(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); +unsigned int BassboostFilter_getParamType(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); +float BassboostFilter_getParamMax(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); +float BassboostFilter_getParamMin(BassboostFilter * aBassboostFilter, unsigned int aParamIndex); +int BassboostFilter_setParams(BassboostFilter * aBassboostFilter, float aBoost); +BassboostFilter * BassboostFilter_create(); + +/* + * BiquadResonantFilter + */ +void BiquadResonantFilter_destroy(BiquadResonantFilter * aBiquadResonantFilter); +int BiquadResonantFilter_getParamCount(BiquadResonantFilter * aBiquadResonantFilter); +const char * BiquadResonantFilter_getParamName(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); +unsigned int BiquadResonantFilter_getParamType(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); +float BiquadResonantFilter_getParamMax(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); +float BiquadResonantFilter_getParamMin(BiquadResonantFilter * aBiquadResonantFilter, unsigned int aParamIndex); +BiquadResonantFilter * BiquadResonantFilter_create(); +int BiquadResonantFilter_setParams(BiquadResonantFilter * aBiquadResonantFilter, int aType, float aFrequency, float aResonance); + +/* + * Bus + */ +void Bus_destroy(Bus * aBus); +Bus * Bus_create(); +void Bus_setFilter(Bus * aBus, unsigned int aFilterId, Filter * aFilter); +unsigned int Bus_play(Bus * aBus, AudioSource * aSound); +unsigned int Bus_playEx(Bus * aBus, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */); +unsigned int Bus_playClocked(Bus * aBus, double aSoundTime, AudioSource * aSound); +unsigned int Bus_playClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */); +unsigned int Bus_play3d(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); +unsigned int Bus_play3dEx(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */); +unsigned int Bus_play3dClocked(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); +unsigned int Bus_play3dClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */); +int Bus_setChannels(Bus * aBus, unsigned int aChannels); +void Bus_setVisualizationEnable(Bus * aBus, int aEnable); +void Bus_annexSound(Bus * aBus, unsigned int aVoiceHandle); +float * Bus_calcFFT(Bus * aBus); +float * Bus_getWave(Bus * aBus); +float Bus_getApproximateVolume(Bus * aBus, unsigned int aChannel); +unsigned int Bus_getActiveVoiceCount(Bus * aBus); +unsigned int Bus_getResampler(Bus * aBus); +void Bus_setResampler(Bus * aBus, unsigned int aResampler); +void Bus_setVolume(Bus * aBus, float aVolume); +void Bus_setLooping(Bus * aBus, int aLoop); +void Bus_setAutoStop(Bus * aBus, int aAutoStop); +void Bus_set3dMinMaxDistance(Bus * aBus, float aMinDistance, float aMaxDistance); +void Bus_set3dAttenuation(Bus * aBus, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Bus_set3dDopplerFactor(Bus * aBus, float aDopplerFactor); +void Bus_set3dListenerRelative(Bus * aBus, int aListenerRelative); +void Bus_set3dDistanceDelay(Bus * aBus, int aDistanceDelay); +void Bus_set3dCollider(Bus * aBus, AudioCollider * aCollider); +void Bus_set3dColliderEx(Bus * aBus, AudioCollider * aCollider, int aUserData /* = 0 */); +void Bus_set3dAttenuator(Bus * aBus, AudioAttenuator * aAttenuator); +void Bus_setInaudibleBehavior(Bus * aBus, int aMustTick, int aKill); +void Bus_setLoopPoint(Bus * aBus, double aLoopPoint); +double Bus_getLoopPoint(Bus * aBus); +void Bus_stop(Bus * aBus); + +/* + * DCRemovalFilter + */ +void DCRemovalFilter_destroy(DCRemovalFilter * aDCRemovalFilter); +DCRemovalFilter * DCRemovalFilter_create(); +int DCRemovalFilter_setParams(DCRemovalFilter * aDCRemovalFilter); +int DCRemovalFilter_setParamsEx(DCRemovalFilter * aDCRemovalFilter, float aLength /* = 0.1f */); +int DCRemovalFilter_getParamCount(DCRemovalFilter * aDCRemovalFilter); +const char * DCRemovalFilter_getParamName(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); +unsigned int DCRemovalFilter_getParamType(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); +float DCRemovalFilter_getParamMax(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); +float DCRemovalFilter_getParamMin(DCRemovalFilter * aDCRemovalFilter, unsigned int aParamIndex); + +/* + * EchoFilter + */ +void EchoFilter_destroy(EchoFilter * aEchoFilter); +int EchoFilter_getParamCount(EchoFilter * aEchoFilter); +const char * EchoFilter_getParamName(EchoFilter * aEchoFilter, unsigned int aParamIndex); +unsigned int EchoFilter_getParamType(EchoFilter * aEchoFilter, unsigned int aParamIndex); +float EchoFilter_getParamMax(EchoFilter * aEchoFilter, unsigned int aParamIndex); +float EchoFilter_getParamMin(EchoFilter * aEchoFilter, unsigned int aParamIndex); +EchoFilter * EchoFilter_create(); +int EchoFilter_setParams(EchoFilter * aEchoFilter, float aDelay); +int EchoFilter_setParamsEx(EchoFilter * aEchoFilter, float aDelay, float aDecay /* = 0.7f */, float aFilter /* = 0.0f */); + +/* + * FFTFilter + */ +void FFTFilter_destroy(FFTFilter * aFFTFilter); +FFTFilter * FFTFilter_create(); +int FFTFilter_getParamCount(FFTFilter * aFFTFilter); +const char * FFTFilter_getParamName(FFTFilter * aFFTFilter, unsigned int aParamIndex); +unsigned int FFTFilter_getParamType(FFTFilter * aFFTFilter, unsigned int aParamIndex); +float FFTFilter_getParamMax(FFTFilter * aFFTFilter, unsigned int aParamIndex); +float FFTFilter_getParamMin(FFTFilter * aFFTFilter, unsigned int aParamIndex); + +/* + * FlangerFilter + */ +void FlangerFilter_destroy(FlangerFilter * aFlangerFilter); +int FlangerFilter_getParamCount(FlangerFilter * aFlangerFilter); +const char * FlangerFilter_getParamName(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); +unsigned int FlangerFilter_getParamType(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); +float FlangerFilter_getParamMax(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); +float FlangerFilter_getParamMin(FlangerFilter * aFlangerFilter, unsigned int aParamIndex); +FlangerFilter * FlangerFilter_create(); +int FlangerFilter_setParams(FlangerFilter * aFlangerFilter, float aDelay, float aFreq); + +/* + * FreeverbFilter + */ +void FreeverbFilter_destroy(FreeverbFilter * aFreeverbFilter); +int FreeverbFilter_getParamCount(FreeverbFilter * aFreeverbFilter); +const char * FreeverbFilter_getParamName(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); +unsigned int FreeverbFilter_getParamType(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); +float FreeverbFilter_getParamMax(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); +float FreeverbFilter_getParamMin(FreeverbFilter * aFreeverbFilter, unsigned int aParamIndex); +FreeverbFilter * FreeverbFilter_create(); +int FreeverbFilter_setParams(FreeverbFilter * aFreeverbFilter, float aMode, float aRoomSize, float aDamp, float aWidth); + +/* + * LofiFilter + */ +void LofiFilter_destroy(LofiFilter * aLofiFilter); +int LofiFilter_getParamCount(LofiFilter * aLofiFilter); +const char * LofiFilter_getParamName(LofiFilter * aLofiFilter, unsigned int aParamIndex); +unsigned int LofiFilter_getParamType(LofiFilter * aLofiFilter, unsigned int aParamIndex); +float LofiFilter_getParamMax(LofiFilter * aLofiFilter, unsigned int aParamIndex); +float LofiFilter_getParamMin(LofiFilter * aLofiFilter, unsigned int aParamIndex); +LofiFilter * LofiFilter_create(); +int LofiFilter_setParams(LofiFilter * aLofiFilter, float aSampleRate, float aBitdepth); + +/* + * Monotone + */ +void Monotone_destroy(Monotone * aMonotone); +Monotone * Monotone_create(); +int Monotone_setParams(Monotone * aMonotone, int aHardwareChannels); +int Monotone_setParamsEx(Monotone * aMonotone, int aHardwareChannels, int aWaveform /* = Soloud::WAVE_SQUARE */); +int Monotone_load(Monotone * aMonotone, const char * aFilename); +int Monotone_loadMem(Monotone * aMonotone, const unsigned char * aMem, unsigned int aLength); +int Monotone_loadMemEx(Monotone * aMonotone, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); +int Monotone_loadFile(Monotone * aMonotone, File * aFile); +void Monotone_setVolume(Monotone * aMonotone, float aVolume); +void Monotone_setLooping(Monotone * aMonotone, int aLoop); +void Monotone_setAutoStop(Monotone * aMonotone, int aAutoStop); +void Monotone_set3dMinMaxDistance(Monotone * aMonotone, float aMinDistance, float aMaxDistance); +void Monotone_set3dAttenuation(Monotone * aMonotone, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Monotone_set3dDopplerFactor(Monotone * aMonotone, float aDopplerFactor); +void Monotone_set3dListenerRelative(Monotone * aMonotone, int aListenerRelative); +void Monotone_set3dDistanceDelay(Monotone * aMonotone, int aDistanceDelay); +void Monotone_set3dCollider(Monotone * aMonotone, AudioCollider * aCollider); +void Monotone_set3dColliderEx(Monotone * aMonotone, AudioCollider * aCollider, int aUserData /* = 0 */); +void Monotone_set3dAttenuator(Monotone * aMonotone, AudioAttenuator * aAttenuator); +void Monotone_setInaudibleBehavior(Monotone * aMonotone, int aMustTick, int aKill); +void Monotone_setLoopPoint(Monotone * aMonotone, double aLoopPoint); +double Monotone_getLoopPoint(Monotone * aMonotone); +void Monotone_setFilter(Monotone * aMonotone, unsigned int aFilterId, Filter * aFilter); +void Monotone_stop(Monotone * aMonotone); + +/* + * Noise + */ +void Noise_destroy(Noise * aNoise); +Noise * Noise_create(); +void Noise_setOctaveScale(Noise * aNoise, float aOct0, float aOct1, float aOct2, float aOct3, float aOct4, float aOct5, float aOct6, float aOct7, float aOct8, float aOct9); +void Noise_setType(Noise * aNoise, int aType); +void Noise_setVolume(Noise * aNoise, float aVolume); +void Noise_setLooping(Noise * aNoise, int aLoop); +void Noise_setAutoStop(Noise * aNoise, int aAutoStop); +void Noise_set3dMinMaxDistance(Noise * aNoise, float aMinDistance, float aMaxDistance); +void Noise_set3dAttenuation(Noise * aNoise, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Noise_set3dDopplerFactor(Noise * aNoise, float aDopplerFactor); +void Noise_set3dListenerRelative(Noise * aNoise, int aListenerRelative); +void Noise_set3dDistanceDelay(Noise * aNoise, int aDistanceDelay); +void Noise_set3dCollider(Noise * aNoise, AudioCollider * aCollider); +void Noise_set3dColliderEx(Noise * aNoise, AudioCollider * aCollider, int aUserData /* = 0 */); +void Noise_set3dAttenuator(Noise * aNoise, AudioAttenuator * aAttenuator); +void Noise_setInaudibleBehavior(Noise * aNoise, int aMustTick, int aKill); +void Noise_setLoopPoint(Noise * aNoise, double aLoopPoint); +double Noise_getLoopPoint(Noise * aNoise); +void Noise_setFilter(Noise * aNoise, unsigned int aFilterId, Filter * aFilter); +void Noise_stop(Noise * aNoise); + +/* + * Openmpt + */ +void Openmpt_destroy(Openmpt * aOpenmpt); +Openmpt * Openmpt_create(); +int Openmpt_load(Openmpt * aOpenmpt, const char * aFilename); +int Openmpt_loadMem(Openmpt * aOpenmpt, const unsigned char * aMem, unsigned int aLength); +int Openmpt_loadMemEx(Openmpt * aOpenmpt, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); +int Openmpt_loadFile(Openmpt * aOpenmpt, File * aFile); +void Openmpt_setVolume(Openmpt * aOpenmpt, float aVolume); +void Openmpt_setLooping(Openmpt * aOpenmpt, int aLoop); +void Openmpt_setAutoStop(Openmpt * aOpenmpt, int aAutoStop); +void Openmpt_set3dMinMaxDistance(Openmpt * aOpenmpt, float aMinDistance, float aMaxDistance); +void Openmpt_set3dAttenuation(Openmpt * aOpenmpt, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Openmpt_set3dDopplerFactor(Openmpt * aOpenmpt, float aDopplerFactor); +void Openmpt_set3dListenerRelative(Openmpt * aOpenmpt, int aListenerRelative); +void Openmpt_set3dDistanceDelay(Openmpt * aOpenmpt, int aDistanceDelay); +void Openmpt_set3dCollider(Openmpt * aOpenmpt, AudioCollider * aCollider); +void Openmpt_set3dColliderEx(Openmpt * aOpenmpt, AudioCollider * aCollider, int aUserData /* = 0 */); +void Openmpt_set3dAttenuator(Openmpt * aOpenmpt, AudioAttenuator * aAttenuator); +void Openmpt_setInaudibleBehavior(Openmpt * aOpenmpt, int aMustTick, int aKill); +void Openmpt_setLoopPoint(Openmpt * aOpenmpt, double aLoopPoint); +double Openmpt_getLoopPoint(Openmpt * aOpenmpt); +void Openmpt_setFilter(Openmpt * aOpenmpt, unsigned int aFilterId, Filter * aFilter); +void Openmpt_stop(Openmpt * aOpenmpt); + +/* + * Queue + */ +void Queue_destroy(Queue * aQueue); +Queue * Queue_create(); +int Queue_play(Queue * aQueue, AudioSource * aSound); +unsigned int Queue_getQueueCount(Queue * aQueue); +int Queue_isCurrentlyPlaying(Queue * aQueue, AudioSource * aSound); +int Queue_setParamsFromAudioSource(Queue * aQueue, AudioSource * aSound); +int Queue_setParams(Queue * aQueue, float aSamplerate); +int Queue_setParamsEx(Queue * aQueue, float aSamplerate, unsigned int aChannels /* = 2 */); +void Queue_setVolume(Queue * aQueue, float aVolume); +void Queue_setLooping(Queue * aQueue, int aLoop); +void Queue_setAutoStop(Queue * aQueue, int aAutoStop); +void Queue_set3dMinMaxDistance(Queue * aQueue, float aMinDistance, float aMaxDistance); +void Queue_set3dAttenuation(Queue * aQueue, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Queue_set3dDopplerFactor(Queue * aQueue, float aDopplerFactor); +void Queue_set3dListenerRelative(Queue * aQueue, int aListenerRelative); +void Queue_set3dDistanceDelay(Queue * aQueue, int aDistanceDelay); +void Queue_set3dCollider(Queue * aQueue, AudioCollider * aCollider); +void Queue_set3dColliderEx(Queue * aQueue, AudioCollider * aCollider, int aUserData /* = 0 */); +void Queue_set3dAttenuator(Queue * aQueue, AudioAttenuator * aAttenuator); +void Queue_setInaudibleBehavior(Queue * aQueue, int aMustTick, int aKill); +void Queue_setLoopPoint(Queue * aQueue, double aLoopPoint); +double Queue_getLoopPoint(Queue * aQueue); +void Queue_setFilter(Queue * aQueue, unsigned int aFilterId, Filter * aFilter); +void Queue_stop(Queue * aQueue); + +/* + * RobotizeFilter + */ +void RobotizeFilter_destroy(RobotizeFilter * aRobotizeFilter); +int RobotizeFilter_getParamCount(RobotizeFilter * aRobotizeFilter); +const char * RobotizeFilter_getParamName(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); +unsigned int RobotizeFilter_getParamType(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); +float RobotizeFilter_getParamMax(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); +float RobotizeFilter_getParamMin(RobotizeFilter * aRobotizeFilter, unsigned int aParamIndex); +void RobotizeFilter_setParams(RobotizeFilter * aRobotizeFilter, float aFreq, int aWaveform); +RobotizeFilter * RobotizeFilter_create(); + +/* + * Sfxr + */ +void Sfxr_destroy(Sfxr * aSfxr); +Sfxr * Sfxr_create(); +void Sfxr_resetParams(Sfxr * aSfxr); +int Sfxr_loadParams(Sfxr * aSfxr, const char * aFilename); +int Sfxr_loadParamsMem(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength); +int Sfxr_loadParamsMemEx(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); +int Sfxr_loadParamsFile(Sfxr * aSfxr, File * aFile); +int Sfxr_loadPreset(Sfxr * aSfxr, int aPresetNo, int aRandSeed); +void Sfxr_setVolume(Sfxr * aSfxr, float aVolume); +void Sfxr_setLooping(Sfxr * aSfxr, int aLoop); +void Sfxr_setAutoStop(Sfxr * aSfxr, int aAutoStop); +void Sfxr_set3dMinMaxDistance(Sfxr * aSfxr, float aMinDistance, float aMaxDistance); +void Sfxr_set3dAttenuation(Sfxr * aSfxr, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Sfxr_set3dDopplerFactor(Sfxr * aSfxr, float aDopplerFactor); +void Sfxr_set3dListenerRelative(Sfxr * aSfxr, int aListenerRelative); +void Sfxr_set3dDistanceDelay(Sfxr * aSfxr, int aDistanceDelay); +void Sfxr_set3dCollider(Sfxr * aSfxr, AudioCollider * aCollider); +void Sfxr_set3dColliderEx(Sfxr * aSfxr, AudioCollider * aCollider, int aUserData /* = 0 */); +void Sfxr_set3dAttenuator(Sfxr * aSfxr, AudioAttenuator * aAttenuator); +void Sfxr_setInaudibleBehavior(Sfxr * aSfxr, int aMustTick, int aKill); +void Sfxr_setLoopPoint(Sfxr * aSfxr, double aLoopPoint); +double Sfxr_getLoopPoint(Sfxr * aSfxr); +void Sfxr_setFilter(Sfxr * aSfxr, unsigned int aFilterId, Filter * aFilter); +void Sfxr_stop(Sfxr * aSfxr); + +/* + * Speech + */ +void Speech_destroy(Speech * aSpeech); +Speech * Speech_create(); +int Speech_setText(Speech * aSpeech, const char * aText); +int Speech_setParams(Speech * aSpeech); +int Speech_setParamsEx(Speech * aSpeech, unsigned int aBaseFrequency /* = 1330 */, float aBaseSpeed /* = 10.0f */, float aBaseDeclination /* = 0.5f */, int aBaseWaveform /* = KW_TRIANGLE */); +void Speech_setVolume(Speech * aSpeech, float aVolume); +void Speech_setLooping(Speech * aSpeech, int aLoop); +void Speech_setAutoStop(Speech * aSpeech, int aAutoStop); +void Speech_set3dMinMaxDistance(Speech * aSpeech, float aMinDistance, float aMaxDistance); +void Speech_set3dAttenuation(Speech * aSpeech, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Speech_set3dDopplerFactor(Speech * aSpeech, float aDopplerFactor); +void Speech_set3dListenerRelative(Speech * aSpeech, int aListenerRelative); +void Speech_set3dDistanceDelay(Speech * aSpeech, int aDistanceDelay); +void Speech_set3dCollider(Speech * aSpeech, AudioCollider * aCollider); +void Speech_set3dColliderEx(Speech * aSpeech, AudioCollider * aCollider, int aUserData /* = 0 */); +void Speech_set3dAttenuator(Speech * aSpeech, AudioAttenuator * aAttenuator); +void Speech_setInaudibleBehavior(Speech * aSpeech, int aMustTick, int aKill); +void Speech_setLoopPoint(Speech * aSpeech, double aLoopPoint); +double Speech_getLoopPoint(Speech * aSpeech); +void Speech_setFilter(Speech * aSpeech, unsigned int aFilterId, Filter * aFilter); +void Speech_stop(Speech * aSpeech); + +/* + * TedSid + */ +void TedSid_destroy(TedSid * aTedSid); +TedSid * TedSid_create(); +int TedSid_load(TedSid * aTedSid, const char * aFilename); +int TedSid_loadMem(TedSid * aTedSid, const unsigned char * aMem, unsigned int aLength); +int TedSid_loadMemEx(TedSid * aTedSid, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); +int TedSid_loadFile(TedSid * aTedSid, File * aFile); +void TedSid_setVolume(TedSid * aTedSid, float aVolume); +void TedSid_setLooping(TedSid * aTedSid, int aLoop); +void TedSid_setAutoStop(TedSid * aTedSid, int aAutoStop); +void TedSid_set3dMinMaxDistance(TedSid * aTedSid, float aMinDistance, float aMaxDistance); +void TedSid_set3dAttenuation(TedSid * aTedSid, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void TedSid_set3dDopplerFactor(TedSid * aTedSid, float aDopplerFactor); +void TedSid_set3dListenerRelative(TedSid * aTedSid, int aListenerRelative); +void TedSid_set3dDistanceDelay(TedSid * aTedSid, int aDistanceDelay); +void TedSid_set3dCollider(TedSid * aTedSid, AudioCollider * aCollider); +void TedSid_set3dColliderEx(TedSid * aTedSid, AudioCollider * aCollider, int aUserData /* = 0 */); +void TedSid_set3dAttenuator(TedSid * aTedSid, AudioAttenuator * aAttenuator); +void TedSid_setInaudibleBehavior(TedSid * aTedSid, int aMustTick, int aKill); +void TedSid_setLoopPoint(TedSid * aTedSid, double aLoopPoint); +double TedSid_getLoopPoint(TedSid * aTedSid); +void TedSid_setFilter(TedSid * aTedSid, unsigned int aFilterId, Filter * aFilter); +void TedSid_stop(TedSid * aTedSid); + +/* + * Vic + */ +void Vic_destroy(Vic * aVic); +Vic * Vic_create(); +void Vic_setModel(Vic * aVic, int model); +int Vic_getModel(Vic * aVic); +void Vic_setRegister(Vic * aVic, int reg, unsigned char value); +unsigned char Vic_getRegister(Vic * aVic, int reg); +void Vic_setVolume(Vic * aVic, float aVolume); +void Vic_setLooping(Vic * aVic, int aLoop); +void Vic_setAutoStop(Vic * aVic, int aAutoStop); +void Vic_set3dMinMaxDistance(Vic * aVic, float aMinDistance, float aMaxDistance); +void Vic_set3dAttenuation(Vic * aVic, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Vic_set3dDopplerFactor(Vic * aVic, float aDopplerFactor); +void Vic_set3dListenerRelative(Vic * aVic, int aListenerRelative); +void Vic_set3dDistanceDelay(Vic * aVic, int aDistanceDelay); +void Vic_set3dCollider(Vic * aVic, AudioCollider * aCollider); +void Vic_set3dColliderEx(Vic * aVic, AudioCollider * aCollider, int aUserData /* = 0 */); +void Vic_set3dAttenuator(Vic * aVic, AudioAttenuator * aAttenuator); +void Vic_setInaudibleBehavior(Vic * aVic, int aMustTick, int aKill); +void Vic_setLoopPoint(Vic * aVic, double aLoopPoint); +double Vic_getLoopPoint(Vic * aVic); +void Vic_setFilter(Vic * aVic, unsigned int aFilterId, Filter * aFilter); +void Vic_stop(Vic * aVic); + +/* + * Vizsn + */ +void Vizsn_destroy(Vizsn * aVizsn); +Vizsn * Vizsn_create(); +void Vizsn_setText(Vizsn * aVizsn, char * aText); +void Vizsn_setVolume(Vizsn * aVizsn, float aVolume); +void Vizsn_setLooping(Vizsn * aVizsn, int aLoop); +void Vizsn_setAutoStop(Vizsn * aVizsn, int aAutoStop); +void Vizsn_set3dMinMaxDistance(Vizsn * aVizsn, float aMinDistance, float aMaxDistance); +void Vizsn_set3dAttenuation(Vizsn * aVizsn, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Vizsn_set3dDopplerFactor(Vizsn * aVizsn, float aDopplerFactor); +void Vizsn_set3dListenerRelative(Vizsn * aVizsn, int aListenerRelative); +void Vizsn_set3dDistanceDelay(Vizsn * aVizsn, int aDistanceDelay); +void Vizsn_set3dCollider(Vizsn * aVizsn, AudioCollider * aCollider); +void Vizsn_set3dColliderEx(Vizsn * aVizsn, AudioCollider * aCollider, int aUserData /* = 0 */); +void Vizsn_set3dAttenuator(Vizsn * aVizsn, AudioAttenuator * aAttenuator); +void Vizsn_setInaudibleBehavior(Vizsn * aVizsn, int aMustTick, int aKill); +void Vizsn_setLoopPoint(Vizsn * aVizsn, double aLoopPoint); +double Vizsn_getLoopPoint(Vizsn * aVizsn); +void Vizsn_setFilter(Vizsn * aVizsn, unsigned int aFilterId, Filter * aFilter); +void Vizsn_stop(Vizsn * aVizsn); + +/* + * Wav + */ +void Wav_destroy(Wav * aWav); +Wav * Wav_create(); +int Wav_load(Wav * aWav, const char * aFilename); +int Wav_loadMem(Wav * aWav, const unsigned char * aMem, unsigned int aLength); +int Wav_loadMemEx(Wav * aWav, const unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); +int Wav_loadFile(Wav * aWav, File * aFile); +int Wav_loadRawWave8(Wav * aWav, unsigned char * aMem, unsigned int aLength); +int Wav_loadRawWave8Ex(Wav * aWav, unsigned char * aMem, unsigned int aLength, float aSamplerate /* = 44100.0f */, unsigned int aChannels /* = 1 */); +int Wav_loadRawWave16(Wav * aWav, short * aMem, unsigned int aLength); +int Wav_loadRawWave16Ex(Wav * aWav, short * aMem, unsigned int aLength, float aSamplerate /* = 44100.0f */, unsigned int aChannels /* = 1 */); +int Wav_loadRawWave(Wav * aWav, float * aMem, unsigned int aLength); +int Wav_loadRawWaveEx(Wav * aWav, float * aMem, unsigned int aLength, float aSamplerate /* = 44100.0f */, unsigned int aChannels /* = 1 */, int aCopy /* = false */, int aTakeOwnership /* = true */); +double Wav_getLength(Wav * aWav); +void Wav_setVolume(Wav * aWav, float aVolume); +void Wav_setLooping(Wav * aWav, int aLoop); +void Wav_setAutoStop(Wav * aWav, int aAutoStop); +void Wav_set3dMinMaxDistance(Wav * aWav, float aMinDistance, float aMaxDistance); +void Wav_set3dAttenuation(Wav * aWav, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void Wav_set3dDopplerFactor(Wav * aWav, float aDopplerFactor); +void Wav_set3dListenerRelative(Wav * aWav, int aListenerRelative); +void Wav_set3dDistanceDelay(Wav * aWav, int aDistanceDelay); +void Wav_set3dCollider(Wav * aWav, AudioCollider * aCollider); +void Wav_set3dColliderEx(Wav * aWav, AudioCollider * aCollider, int aUserData /* = 0 */); +void Wav_set3dAttenuator(Wav * aWav, AudioAttenuator * aAttenuator); +void Wav_setInaudibleBehavior(Wav * aWav, int aMustTick, int aKill); +void Wav_setLoopPoint(Wav * aWav, double aLoopPoint); +double Wav_getLoopPoint(Wav * aWav); +void Wav_setFilter(Wav * aWav, unsigned int aFilterId, Filter * aFilter); +void Wav_stop(Wav * aWav); + +/* + * WaveShaperFilter + */ +void WaveShaperFilter_destroy(WaveShaperFilter * aWaveShaperFilter); +int WaveShaperFilter_setParams(WaveShaperFilter * aWaveShaperFilter, float aAmount); +WaveShaperFilter * WaveShaperFilter_create(); +int WaveShaperFilter_getParamCount(WaveShaperFilter * aWaveShaperFilter); +const char * WaveShaperFilter_getParamName(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); +unsigned int WaveShaperFilter_getParamType(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); +float WaveShaperFilter_getParamMax(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); +float WaveShaperFilter_getParamMin(WaveShaperFilter * aWaveShaperFilter, unsigned int aParamIndex); + +/* + * WavStream + */ +void WavStream_destroy(WavStream * aWavStream); +WavStream * WavStream_create(); +int WavStream_load(WavStream * aWavStream, const char * aFilename); +int WavStream_loadMem(WavStream * aWavStream, const unsigned char * aData, unsigned int aDataLen); +int WavStream_loadMemEx(WavStream * aWavStream, const unsigned char * aData, unsigned int aDataLen, int aCopy /* = false */, int aTakeOwnership /* = true */); +int WavStream_loadToMem(WavStream * aWavStream, const char * aFilename); +int WavStream_loadFile(WavStream * aWavStream, File * aFile); +int WavStream_loadFileToMem(WavStream * aWavStream, File * aFile); +double WavStream_getLength(WavStream * aWavStream); +void WavStream_setVolume(WavStream * aWavStream, float aVolume); +void WavStream_setLooping(WavStream * aWavStream, int aLoop); +void WavStream_setAutoStop(WavStream * aWavStream, int aAutoStop); +void WavStream_set3dMinMaxDistance(WavStream * aWavStream, float aMinDistance, float aMaxDistance); +void WavStream_set3dAttenuation(WavStream * aWavStream, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); +void WavStream_set3dDopplerFactor(WavStream * aWavStream, float aDopplerFactor); +void WavStream_set3dListenerRelative(WavStream * aWavStream, int aListenerRelative); +void WavStream_set3dDistanceDelay(WavStream * aWavStream, int aDistanceDelay); +void WavStream_set3dCollider(WavStream * aWavStream, AudioCollider * aCollider); +void WavStream_set3dColliderEx(WavStream * aWavStream, AudioCollider * aCollider, int aUserData /* = 0 */); +void WavStream_set3dAttenuator(WavStream * aWavStream, AudioAttenuator * aAttenuator); +void WavStream_setInaudibleBehavior(WavStream * aWavStream, int aMustTick, int aKill); +void WavStream_setLoopPoint(WavStream * aWavStream, double aLoopPoint); +double WavStream_getLoopPoint(WavStream * aWavStream); +void WavStream_setFilter(WavStream * aWavStream, unsigned int aFilterId, Filter * aFilter); +void WavStream_stop(WavStream * aWavStream); +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // SOLOUD_C_H_INCLUDED + diff --git a/include/common/soloud/soloud_dcremovalfilter.h b/include/common/soloud/soloud_dcremovalfilter.h index c9ecef1..77e044c 100755 --- a/include/common/soloud/soloud_dcremovalfilter.h +++ b/include/common/soloud/soloud_dcremovalfilter.h @@ -1,58 +1,58 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_DCREMOVAL_H -#define SOLOUD_DCREMOVAL_H - -#include "soloud.h" - -namespace SoLoud -{ - class DCRemovalFilter; - - class DCRemovalFilterInstance : public FilterInstance - { - float *mBuffer; - float *mTotals; - int mBufferLength; - DCRemovalFilter *mParent; - int mOffset; - - public: - virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); - virtual ~DCRemovalFilterInstance(); - DCRemovalFilterInstance(DCRemovalFilter *aParent); - }; - - class DCRemovalFilter : public Filter - { - public: - float mLength; - virtual FilterInstance *createInstance(); - DCRemovalFilter(); - result setParams(float aLength = 0.1f); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_DCREMOVAL_H +#define SOLOUD_DCREMOVAL_H + +#include "soloud.h" + +namespace SoLoud +{ + class DCRemovalFilter; + + class DCRemovalFilterInstance : public FilterInstance + { + float *mBuffer; + float *mTotals; + int mBufferLength; + DCRemovalFilter *mParent; + int mOffset; + + public: + virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); + virtual ~DCRemovalFilterInstance(); + DCRemovalFilterInstance(DCRemovalFilter *aParent); + }; + + class DCRemovalFilter : public Filter + { + public: + float mLength; + virtual FilterInstance *createInstance(); + DCRemovalFilter(); + result setParams(float aLength = 0.1f); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_echofilter.h b/include/common/soloud/soloud_echofilter.h index a73dc50..e9fae3b 100755 --- a/include/common/soloud/soloud_echofilter.h +++ b/include/common/soloud/soloud_echofilter.h @@ -1,59 +1,71 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_ECHOFILTER_H -#define SOLOUD_ECHOFILTER_H - -#include "soloud.h" - -namespace SoLoud -{ - class EchoFilter; - - class EchoFilterInstance : public FilterInstance - { - float *mBuffer; - int mBufferLength; - EchoFilter *mParent; - int mOffset; - - public: - virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); - virtual ~EchoFilterInstance(); - EchoFilterInstance(EchoFilter *aParent); - }; - - class EchoFilter : public Filter - { - public: - float mDelay; - float mDecay; - float mFilter; - virtual FilterInstance *createInstance(); - EchoFilter(); - result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_ECHOFILTER_H +#define SOLOUD_ECHOFILTER_H + +#include "soloud.h" + +namespace SoLoud +{ + class EchoFilter; + + class EchoFilterInstance : public FilterInstance + { + float *mBuffer; + int mBufferLength; + int mBufferMaxLength; + int mOffset; + + public: + virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); + virtual ~EchoFilterInstance(); + EchoFilterInstance(EchoFilter *aParent); + }; + + class EchoFilter : public Filter + { + public: + enum FILTERATTRIBUTE + { + WET = 0, + DELAY, + DECAY, + FILTER + }; + float mDelay; + float mDecay; + float mFilter; + virtual int getParamCount(); + virtual const char* getParamName(unsigned int aParamIndex); + virtual unsigned int getParamType(unsigned int aParamIndex); + virtual float getParamMax(unsigned int aParamIndex); + virtual float getParamMin(unsigned int aParamIndex); + virtual FilterInstance *createInstance(); + EchoFilter(); + result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_eqfilter.h b/include/common/soloud/soloud_eqfilter.h new file mode 100644 index 0000000..b858a95 --- /dev/null +++ b/include/common/soloud/soloud_eqfilter.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_error.h b/include/common/soloud/soloud_error.h index a0be65d..1379f8e 100755 --- a/include/common/soloud/soloud_error.h +++ b/include/common/soloud/soloud_error.h @@ -1,41 +1,41 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ -#ifndef SOLOUD_ERROR_H -#define SOLOUD_ERROR_H - -namespace SoLoud -{ - enum SOLOUD_ERRORS - { - SO_NO_ERROR = 0, // No error - INVALID_PARAMETER = 1, // Some parameter is invalid - FILE_NOT_FOUND = 2, // File not found - FILE_LOAD_FAILED = 3, // File found, but could not be loaded - DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL - OUT_OF_MEMORY = 5, // Out of memory - NOT_IMPLEMENTED = 6, // Feature not implemented - UNKNOWN_ERROR = 7 // Other error - }; -}; +/* +SoLoud audio engine +Copyright (c) 2013-2014 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#ifndef SOLOUD_ERROR_H +#define SOLOUD_ERROR_H + +namespace SoLoud +{ + enum SOLOUD_ERRORS + { + SO_NO_ERROR = 0, // No error + INVALID_PARAMETER = 1, // Some parameter is invalid + FILE_NOT_FOUND = 2, // File not found + FILE_LOAD_FAILED = 3, // File found, but could not be loaded + DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL + OUT_OF_MEMORY = 5, // Out of memory + NOT_IMPLEMENTED = 6, // Feature not implemented + UNKNOWN_ERROR = 7 // Other error + }; +}; #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_fader.h b/include/common/soloud/soloud_fader.h index a4de6a6..bd1c93e 100755 --- a/include/common/soloud/soloud_fader.h +++ b/include/common/soloud/soloud_fader.h @@ -1,63 +1,63 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_FADER_H -#define SOLOUD_FADER_H - -#include "soloud.h" - -namespace SoLoud -{ - // Helper class to process faders - class Fader - { - public: - // Value to fade from - float mFrom; - // Value to fade to - float mTo; - // Delta between from and to - float mDelta; - // Total time to fade - time mTime; - // Time fading started - time mStartTime; - // Time fading will end - time mEndTime; - // Current value. Used in case time rolls over. - float mCurrent; - // Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped - int mActive; - // Ctor - Fader(); - // Set up LFO - void setLFO(float aFrom, float aTo, time aTime, time aStartTime); - // Set up fader - void set(float aFrom, float aTo, time aTime, time aStartTime); - // Get the current fading value - float get(time aCurrentTime); - }; -}; - +/* +SoLoud audio engine +Copyright (c) 2013-2014 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_FADER_H +#define SOLOUD_FADER_H + +#include "soloud.h" + +namespace SoLoud +{ + // Helper class to process faders + class Fader + { + public: + // Value to fade from + float mFrom; + // Value to fade to + float mTo; + // Delta between from and to + float mDelta; + // Total time to fade + time mTime; + // Time fading started + time mStartTime; + // Time fading will end + time mEndTime; + // Current value. Used in case time rolls over. + float mCurrent; + // Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped + int mActive; + // Ctor + Fader(); + // Set up LFO + void setLFO(float aFrom, float aTo, time aTime, time aStartTime); + // Set up fader + void set(float aFrom, float aTo, time aTime, time aStartTime); + // Get the current fading value + float get(time aCurrentTime); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_fft.h b/include/common/soloud/soloud_fft.h index fcdc8f9..dd54488 100755 --- a/include/common/soloud/soloud_fft.h +++ b/include/common/soloud/soloud_fft.h @@ -1,45 +1,51 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_FFT_H -#define SOLOUD_FFT_H - -#include "soloud.h" - -namespace SoLoud -{ - namespace FFT - { - // Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten - void fft1024(float *aBuffer); - - // Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten - void fft256(float *aBuffer); - - // Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten - void ifft256(float *aBuffer); - }; -}; - +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_FFT_H +#define SOLOUD_FFT_H + +#include "soloud.h" + +namespace SoLoud +{ + namespace FFT + { + // Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten + void fft1024(float *aBuffer); + + // Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten + void fft256(float *aBuffer); + + // Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten + void ifft256(float *aBuffer); + + // Generic (slower) power of two FFT. Buffer is overwritten. + void fft(float *aBuffer, unsigned int aBufferLength); + + // Generic (slower) power of two IFFT. Buffer is overwritten. + void ifft(float *aBuffer, unsigned int aBufferLength); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_fftfilter.h b/include/common/soloud/soloud_fftfilter.h index 543ab3c..01378b8 100755 --- a/include/common/soloud/soloud_fftfilter.h +++ b/include/common/soloud/soloud_fftfilter.h @@ -1,57 +1,66 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_FFTFILTER_H -#define SOLOUD_FFTFILTER_H - -#include "soloud.h" - -namespace SoLoud -{ - class FFTFilter; - - class FFTFilterInstance : public FilterInstance - { - float *mTemp; - float *mInputBuffer; - float *mMixBuffer; - unsigned int mOffset[MAX_CHANNELS]; - FFTFilter *mParent; - public: - virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); - virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); - virtual ~FFTFilterInstance(); - FFTFilterInstance(FFTFilter *aParent); - FFTFilterInstance(); - }; - - class FFTFilter : public Filter - { - public: - virtual FilterInstance *createInstance(); - FFTFilter(); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_FFTFILTER_H +#define SOLOUD_FFTFILTER_H + +#include "soloud.h" + +namespace SoLoud +{ + class FFTFilter; + + class FFTFilterInstance : public FilterInstance + { + float *mTemp; + float *mInputBuffer; + float *mMixBuffer; + float *mLastPhase; + float *mSumPhase; + unsigned int mInputOffset[MAX_CHANNELS]; + unsigned int mMixOffset[MAX_CHANNELS]; + unsigned int mReadOffset[MAX_CHANNELS]; + FFTFilter *mParent; + public: + virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); + virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); + virtual ~FFTFilterInstance(); + FFTFilterInstance(FFTFilter *aParent); + FFTFilterInstance(); + void comp2MagPhase(float* aFFTBuffer, unsigned int aSamples); + void magPhase2MagFreq(float* aFFTBuffer, unsigned int aSamples, float aSamplerate, unsigned int aChannel); + void magFreq2MagPhase(float* aFFTBuffer, unsigned int aSamples, float aSamplerate, unsigned int aChannel); + void magPhase2Comp(float* aFFTBuffer, unsigned int aSamples); + void init(); + }; + + class FFTFilter : public Filter + { + public: + virtual FilterInstance *createInstance(); + FFTFilter(); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_file.h b/include/common/soloud/soloud_file.h index 6b5cd6c..e01f83a 100755 --- a/include/common/soloud/soloud_file.h +++ b/include/common/soloud/soloud_file.h @@ -45,7 +45,7 @@ namespace SoLoud virtual void seek(int aOffset) = 0; virtual unsigned int pos() = 0; virtual FILE * getFilePtr() { return 0; } - virtual unsigned char * getMemPtr() { return 0; } + virtual const unsigned char * getMemPtr() { return 0; } }; class DiskFile : public File @@ -68,7 +68,7 @@ namespace SoLoud class MemoryFile : public File { public: - unsigned char *mDataPtr; + const unsigned char *mDataPtr; unsigned int mDataLength; unsigned int mOffset; bool mDataOwned; @@ -78,10 +78,10 @@ namespace SoLoud virtual unsigned int length(); virtual void seek(int aOffset); virtual unsigned int pos(); - virtual unsigned char * getMemPtr(); + virtual const unsigned char * getMemPtr(); virtual ~MemoryFile(); MemoryFile(); - result openMem(unsigned char *aData, unsigned int aDataLength, bool aCopy=false, bool aTakeOwnership=true); + result openMem(const unsigned char *aData, unsigned int aDataLength, bool aCopy=false, bool aTakeOwnership=true); result openToMem(const char *aFilename); result openFileToMem(File *aFile); }; diff --git a/include/common/soloud/soloud_file_hack_off.h b/include/common/soloud/soloud_file_hack_off.h index 6c75180..4433ffc 100755 --- a/include/common/soloud/soloud_file_hack_off.h +++ b/include/common/soloud/soloud_file_hack_off.h @@ -1,35 +1,36 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -/* -See soloud_file_hack_on.h -*/ - -#undef FILE -#undef fgetc -#undef fread -#undef fseek -#undef ftell -#undef fclose -#undef fopen +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +/* +See soloud_file_hack_on.h +*/ + +#undef FILE +#undef fgetc +#undef fread +#undef fseek +#undef ftell +#undef fclose +#undef fopen +#undef fopen_s diff --git a/include/common/soloud/soloud_file_hack_on.h b/include/common/soloud/soloud_file_hack_on.h index a7efe99..50a6b59 100755 --- a/include/common/soloud/soloud_file_hack_on.h +++ b/include/common/soloud/soloud_file_hack_on.h @@ -1,58 +1,60 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -/* -This is a "hack" header to fool third party code to use our File stuff instead -of stdio FILE* stuff. -You can use soloud_file_hack_off.h to undef the stuff defined here. -*/ - -#ifndef SEEK_SET -#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio. -#endif - -typedef void* Soloud_Filehack; - -#ifdef __cplusplus -extern "C" { -#endif - -extern int Soloud_Filehack_fgetc(Soloud_Filehack *f); -extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f); -extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base); -extern int Soloud_Filehack_ftell(Soloud_Filehack *f); -extern int Soloud_Filehack_fclose(Soloud_Filehack *f); -extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode); - -#ifdef __cplusplus -} -#endif - -#define FILE Soloud_Filehack -#define fgetc Soloud_Filehack_fgetc -#define fread Soloud_Filehack_fread -#define fseek Soloud_Filehack_fseek -#define ftell Soloud_Filehack_ftell -#define fclose Soloud_Filehack_fclose -#define fopen Soloud_Filehack_fopen +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +/* +This is a "hack" header to fool third party code to use our File stuff instead +of stdio FILE* stuff. +You can use soloud_file_hack_off.h to undef the stuff defined here. +*/ + +#ifndef SEEK_SET +#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio. +#endif + +typedef void* Soloud_Filehack; + +#ifdef __cplusplus +extern "C" { +#endif + +extern int Soloud_Filehack_fgetc(Soloud_Filehack *f); +extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f); +extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base); +extern int Soloud_Filehack_ftell(Soloud_Filehack *f); +extern int Soloud_Filehack_fclose(Soloud_Filehack *f); +extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode); +extern int Soloud_Filehack_fopen_s(Soloud_Filehack **f, const char* aFilename, char* aMode); + +#ifdef __cplusplus +} +#endif + +#define FILE Soloud_Filehack +#define fgetc Soloud_Filehack_fgetc +#define fread Soloud_Filehack_fread +#define fseek Soloud_Filehack_fseek +#define ftell Soloud_Filehack_ftell +#define fclose Soloud_Filehack_fclose +#define fopen Soloud_Filehack_fopen +#define fopen_s Soloud_Filehack_fopen_s diff --git a/include/common/soloud/soloud_filter.h b/include/common/soloud/soloud_filter.h index 887d3fa..a21c290 100755 --- a/include/common/soloud/soloud_filter.h +++ b/include/common/soloud/soloud_filter.h @@ -1,64 +1,76 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_FILTER_H -#define SOLOUD_FILTER_H - -#include "soloud.h" - -namespace SoLoud -{ - class Fader; - - class FilterInstance - { - public: - unsigned int mNumParams; - unsigned int mParamChanged; - float *mParam; - Fader *mParamFader; - - - FilterInstance(); - virtual result initParams(int aNumParams); - virtual void updateParams(time aTime); - virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); - virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); - virtual float getFilterParameter(unsigned int aAttributeId); - virtual void setFilterParameter(unsigned int aAttributeId, float aValue); - virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime); - virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime); - virtual ~FilterInstance(); - }; - - class Filter - { - public: - Filter(); - virtual FilterInstance *createInstance() = 0; - virtual ~Filter(); - }; -}; - -#endif +/* +SoLoud audio engine +Copyright (c) 2013-2014 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_FILTER_H +#define SOLOUD_FILTER_H + +#include "soloud.h" + +namespace SoLoud +{ + class Fader; + + class FilterInstance + { + public: + unsigned int mNumParams; + unsigned int mParamChanged; + float *mParam; + Fader *mParamFader; + + + FilterInstance(); + virtual result initParams(int aNumParams); + virtual void updateParams(time aTime); + virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); + virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); + virtual float getFilterParameter(unsigned int aAttributeId); + virtual void setFilterParameter(unsigned int aAttributeId, float aValue); + virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime); + virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime); + virtual ~FilterInstance(); + }; + + class Filter + { + public: + enum PARAMTYPE + { + FLOAT_PARAM = 0, + INT_PARAM, + BOOL_PARAM + }; + Filter(); + virtual int getParamCount(); + virtual const char* getParamName(unsigned int aParamIndex); + virtual unsigned int getParamType(unsigned int aParamIndex); + virtual float getParamMax(unsigned int aParamIndex); + virtual float getParamMin(unsigned int aParamIndex); + + virtual FilterInstance *createInstance() = 0; + virtual ~Filter(); + }; +}; + +#endif diff --git a/include/common/soloud/soloud_flangerfilter.h b/include/common/soloud/soloud_flangerfilter.h index 7eb4adb..d28dd96 100755 --- a/include/common/soloud/soloud_flangerfilter.h +++ b/include/common/soloud/soloud_flangerfilter.h @@ -1,65 +1,70 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_FLANGERFILTER_H -#define SOLOUD_FLANGERFILTER_H - -#include "soloud.h" - -namespace SoLoud -{ - class FlangerFilter; - - class FlangerFilterInstance : public FilterInstance - { - float *mBuffer; - int mBufferLength; - FlangerFilter *mParent; - int mOffset; - double mIndex; - - public: - virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); - virtual ~FlangerFilterInstance(); - FlangerFilterInstance(FlangerFilter *aParent); - }; - - class FlangerFilter : public Filter - { - public: - enum FILTERPARAMS - { - WET, - DELAY, - FREQ - }; - float mDelay; - float mFreq; - virtual FilterInstance *createInstance(); - FlangerFilter(); - result setParams(float aDelay, float aFreq); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_FLANGERFILTER_H +#define SOLOUD_FLANGERFILTER_H + +#include "soloud.h" + +namespace SoLoud +{ + class FlangerFilter; + + class FlangerFilterInstance : public FilterInstance + { + float *mBuffer; + unsigned int mBufferLength; + FlangerFilter *mParent; + unsigned int mOffset; + double mIndex; + + public: + virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime); + virtual ~FlangerFilterInstance(); + FlangerFilterInstance(FlangerFilter *aParent); + }; + + class FlangerFilter : public Filter + { + public: + enum FILTERPARAMS + { + WET, + DELAY, + FREQ + }; + float mDelay; + float mFreq; + virtual int getParamCount(); + virtual const char* getParamName(unsigned int aParamIndex); + virtual unsigned int getParamType(unsigned int aParamIndex); + virtual float getParamMax(unsigned int aParamIndex); + virtual float getParamMin(unsigned int aParamIndex); + virtual FilterInstance *createInstance(); + FlangerFilter(); + result setParams(float aDelay, float aFreq); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_freeverbfilter.h b/include/common/soloud/soloud_freeverbfilter.h new file mode 100644 index 0000000..b5e0146 --- /dev/null +++ b/include/common/soloud/soloud_freeverbfilter.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_internal.h b/include/common/soloud/soloud_internal.h index d510693..c0589ab 100755 --- a/include/common/soloud/soloud_internal.h +++ b/include/common/soloud/soloud_internal.h @@ -1,118 +1,161 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_INTERNAL_H -#define SOLOUD_INTERNAL_H - -#include "soloud.h" - -namespace SoLoud -{ - // SDL back-end initialization call - result sdl_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // SDL "non-dynamic" back-end initialization call - result sdlstatic_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // SDL2 "non-dynamic" back-end initialization call - result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // OpenAL back-end initialization call - result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // Core Audio driver back-end initialization call - result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // OpenSL ES back-end initialization call - result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // PortAudio back-end initialization call - result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // WinMM back-end initialization call - result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); - - // XAudio2 back-end initialization call - result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // WASAPI back-end initialization call - result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); - - // OSS back-end initialization call - result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // PS Vita homebrew back-end initialization call - result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // ALSA back-end initialization call - result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // null driver back-end initialization call - result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); - - // Deinterlace samples in a buffer. From 12121212 to 11112222 - void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); - - // Interlace samples in a buffer. From 11112222 to 12121212 - void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); - - // Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212 - void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels); -}; - -#define FOR_ALL_VOICES_PRE \ - handle *h_ = NULL; \ - handle th_[2] = { aVoiceHandle, 0 }; \ - lockAudioMutex(); \ - h_ = voiceGroupHandleToArray(aVoiceHandle); \ - if (h_ == NULL) h_ = th_; \ - while (*h_) \ - { \ - int ch = getVoiceFromHandle(*h_); \ - if (ch != -1) \ - { - -#define FOR_ALL_VOICES_POST \ - } \ - h_++; \ - } \ - unlockAudioMutex(); - -#define FOR_ALL_VOICES_PRE_3D \ - handle *h_ = NULL; \ - handle th_[2] = { aVoiceHandle, 0 }; \ - h_ = voiceGroupHandleToArray(aVoiceHandle); \ - if (h_ == NULL) h_ = th_; \ - while (*h_) \ - { \ - int ch = (*h_ & 0xfff) - 1; \ - if (ch != -1 && m3dData[ch].mHandle == *h_) \ - { - -#define FOR_ALL_VOICES_POST_3D \ - } \ - h_++; \ - } - -#endif \ No newline at end of file +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_INTERNAL_H +#define SOLOUD_INTERNAL_H + +#include "soloud.h" + +namespace SoLoud +{ + // SDL1 back-end initialization call + result sdl1_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // SDL2 back-end initialization call + result sdl2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // SDL1 "non-dynamic" back-end initialization call + result sdl1static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // SDL2 "non-dynamic" back-end initialization call + result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // OpenAL back-end initialization call + result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // Core Audio driver back-end initialization call + result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // OpenSL ES back-end initialization call + result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // PortAudio back-end initialization call + result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // WinMM back-end initialization call + result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); + + // XAudio2 back-end initialization call + result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // WASAPI back-end initialization call + result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); + + // OSS back-end initialization call + result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // PS Vita homebrew back-end initialization call + result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // ALSA back-end initialization call + result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // JACK back-end initialization call + result jack_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // MiniAudio back-end initialization call + result miniaudio_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // nosound back-end initialization call + result nosound_init(SoLoud::Soloud* aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // null driver back-end initialization call + result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); + + // Interlace samples in a buffer. From 11112222 to 12121212 + void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels, unsigned int aStride); + + // Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212 + void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels, unsigned int aStride); +}; + +#define FOR_ALL_VOICES_PRE \ + handle *h_ = NULL; \ + handle th_[2] = { aVoiceHandle, 0 }; \ + lockAudioMutex_internal(); \ + h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \ + if (h_ == NULL) h_ = th_; \ + while (*h_) \ + { \ + int ch = getVoiceFromHandle_internal(*h_); \ + if (ch != -1) \ + { + +#define FOR_ALL_VOICES_POST \ + } \ + h_++; \ + } \ + unlockAudioMutex_internal(); + +#define FOR_ALL_VOICES_PRE_3D \ + handle *h_ = NULL; \ + handle th_[2] = { aVoiceHandle, 0 }; \ + h_ = voiceGroupHandleToArray_internal(aVoiceHandle); \ + if (h_ == NULL) h_ = th_; \ + while (*h_) \ + { \ + int ch = (*h_ & 0xfff) - 1; \ + if (ch != -1 && m3dData[ch].mHandle == *h_) \ + { + +#define FOR_ALL_VOICES_POST_3D \ + } \ + h_++; \ + } + +#define FOR_ALL_VOICES_PRE_EXT \ + handle *h_ = NULL; \ + handle th_[2] = { aVoiceHandle, 0 }; \ + mSoloud->lockAudioMutex_internal(); \ + h_ = mSoloud->voiceGroupHandleToArray_internal(aVoiceHandle); \ + if (h_ == NULL) h_ = th_; \ + while (*h_) \ + { \ + int ch = mSoloud->getVoiceFromHandle_internal(*h_); \ + if (ch != -1) \ + { + +#define FOR_ALL_VOICES_POST_EXT \ + } \ + h_++; \ + } \ + mSoloud->unlockAudioMutex_internal(); + +#define FOR_ALL_VOICES_PRE_3D_EXT \ + handle *h_ = NULL; \ + handle th_[2] = { aVoiceHandle, 0 }; \ + h_ = mSoloud->voiceGroupHandleToArray(aVoiceHandle); \ + if (h_ == NULL) h_ = th_; \ + while (*h_) \ + { \ + int ch = (*h_ & 0xfff) - 1; \ + if (ch != -1 && mSoloud->m3dData[ch].mHandle == *h_) \ + { + +#define FOR_ALL_VOICES_POST_3D_EXT \ + } \ + h_++; \ + } + +#endif diff --git a/include/common/soloud/soloud_lofifilter.h b/include/common/soloud/soloud_lofifilter.h index 627ab6c..be3d594 100755 --- a/include/common/soloud/soloud_lofifilter.h +++ b/include/common/soloud/soloud_lofifilter.h @@ -1,75 +1,80 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_LOFIFILTER_H -#define SOLOUD_LOFIFILTER_H - -#include "soloud.h" - -namespace SoLoud -{ - class LofiFilter; - - struct LofiChannelData - { - float mSample; - float mSamplesToSkip; - }; - - class LofiFilterInstance : public FilterInstance - { - enum FILTERPARAMS - { - WET, - SAMPLERATE, - BITDEPTH - }; - LofiChannelData mChannelData[2]; - - LofiFilter *mParent; - public: - virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); - virtual ~LofiFilterInstance(); - LofiFilterInstance(LofiFilter *aParent); - }; - - class LofiFilter : public Filter - { - public: - enum FILTERPARAMS - { - WET, - SAMPLERATE, - BITDEPTH - }; - float mSampleRate; - float mBitdepth; - virtual LofiFilterInstance *createInstance(); - LofiFilter(); - result setParams(float aSampleRate, float aBitdepth); - virtual ~LofiFilter(); - }; -} - +/* +SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_LOFIFILTER_H +#define SOLOUD_LOFIFILTER_H + +#include "soloud.h" + +namespace SoLoud +{ + class LofiFilter; + + struct LofiChannelData + { + float mSample; + float mSamplesToSkip; + }; + + class LofiFilterInstance : public FilterInstance + { + enum FILTERPARAMS + { + WET, + SAMPLERATE, + BITDEPTH + }; + LofiChannelData mChannelData[2]; + + LofiFilter *mParent; + public: + virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); + virtual ~LofiFilterInstance(); + LofiFilterInstance(LofiFilter *aParent); + }; + + class LofiFilter : public Filter + { + public: + enum FILTERPARAMS + { + WET, + SAMPLERATE, + BITDEPTH + }; + float mSampleRate; + float mBitdepth; + virtual LofiFilterInstance *createInstance(); + virtual int getParamCount(); + virtual const char* getParamName(unsigned int aParamIndex); + virtual unsigned int getParamType(unsigned int aParamIndex); + virtual float getParamMax(unsigned int aParamIndex); + virtual float getParamMin(unsigned int aParamIndex); + LofiFilter(); + result setParams(float aSampleRate, float aBitdepth); + virtual ~LofiFilter(); + }; +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_misc.h b/include/common/soloud/soloud_misc.h new file mode 100644 index 0000000..a50630f --- /dev/null +++ b/include/common/soloud/soloud_misc.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_monotone.h b/include/common/soloud/soloud_monotone.h index d86ca92..dd0440a 100755 --- a/include/common/soloud/soloud_monotone.h +++ b/include/common/soloud/soloud_monotone.h @@ -1,116 +1,110 @@ -/* -MONOTONE module for SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef MONOTONE_H -#define MONOTONE_H - -#include "soloud.h" - -namespace SoLoud -{ - class Monotone; - class File; - - struct MonotoneSong - { - char *mTitle; - char *mComment; - unsigned char mVersion; // must be 1 - unsigned char mTotalPatterns; - unsigned char mTotalTracks; - unsigned char mCellSize; // must be 2 for version 1 - unsigned char mOrder[256]; - unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks - }; - - struct MonotoneChannel - { - int mEnabled; - int mActive; - int mFreq[3]; - int mPortamento; - int mArpCounter; - int mArp; - int mLastNote; - int mPortamentoToNote; - int mVibrato; - int mVibratoIndex; - int mVibratoDepth; - int mVibratoSpeed; - }; - - struct MonotoneHardwareChannel - { - int mEnabled; - float mSamplePos; - float mSamplePosInc; - }; - - class MonotoneInstance : public AudioSourceInstance - { - Monotone *mParent; - public: - MonotoneChannel mChannel[12]; - MonotoneHardwareChannel mOutput[12]; - int mNextChannel; - int mTempo; // ticks / row. Tick = 60hz. Default 4. - int mOrder; - int mRow; - int mSampleCount; - int mRowTick; - - MonotoneInstance(Monotone *aParent); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual bool hasEnded(); - }; - - class Monotone : public AudioSource - { - public: - enum MONOTONE_WAVEFORMS - { - SQUARE = 0, - SAW = 1, - SIN = 2, - SAWSIN = 3 - }; - - int mNotesHz[800]; - int mVibTable[32]; - int mHardwareChannels; - int mWaveform; - MonotoneSong mSong; - Monotone(); - ~Monotone(); - result setParams(int aHardwareChannels, int aWaveform = SQUARE); - result load(const char *aFilename); - result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); - result loadFile(File *aFile); - virtual AudioSourceInstance *createInstance(); - public: - void clear(); - }; -}; - +/* +MONOTONE module for SoLoud audio engine +Copyright (c) 2013-2020 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef MONOTONE_H +#define MONOTONE_H + +#include "soloud.h" +#include "soloud_misc.h" + +namespace SoLoud +{ + class Monotone; + class File; + + struct MonotoneSong + { + char *mTitle; + char *mComment; + unsigned char mVersion; // must be 1 + unsigned char mTotalPatterns; + unsigned char mTotalTracks; + unsigned char mCellSize; // must be 2 for version 1 + unsigned char mOrder[256]; + unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks + }; + + struct MonotoneChannel + { + int mEnabled; + int mActive; + int mFreq[3]; + int mPortamento; + int mArpCounter; + int mArp; + int mLastNote; + int mPortamentoToNote; + int mVibrato; + int mVibratoIndex; + int mVibratoDepth; + int mVibratoSpeed; + }; + + struct MonotoneHardwareChannel + { + int mEnabled; + float mSamplePos; + float mSamplePosInc; + }; + + class MonotoneInstance : public AudioSourceInstance + { + Monotone *mParent; + public: + MonotoneChannel mChannel[12]; + MonotoneHardwareChannel mOutput[12]; + int mNextChannel; + int mTempo; // ticks / row. Tick = 60hz. Default 4. + int mOrder; + int mRow; + int mSampleCount; + int mRowTick; + + MonotoneInstance(Monotone *aParent); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize); + virtual bool hasEnded(); + }; + + class Monotone : public AudioSource + { + public: + + int mNotesHz[800]; + int mVibTable[32]; + int mHardwareChannels; + int mWaveform; + MonotoneSong mSong; + Monotone(); + ~Monotone(); + result setParams(int aHardwareChannels, int aWaveform = Soloud::WAVE_SQUARE); + result load(const char *aFilename); + result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); + result loadFile(File *aFile); + virtual AudioSourceInstance *createInstance(); + public: + void clear(); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_noise.h b/include/common/soloud/soloud_noise.h new file mode 100644 index 0000000..48f5088 --- /dev/null +++ b/include/common/soloud/soloud_noise.h @@ -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 diff --git a/include/common/soloud/soloud_openmpt.h b/include/common/soloud/soloud_openmpt.h index aa0fdbc..5c7a2b4 100755 --- a/include/common/soloud/soloud_openmpt.h +++ b/include/common/soloud/soloud_openmpt.h @@ -1,62 +1,62 @@ -/* -Openmpt module for SoLoud audio engine -Copyright (c) 2016 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef OPENMPT_H -#define OPENMPT_H - -#include "soloud.h" - -namespace SoLoud -{ - class Openmpt; - class File; - - class OpenmptInstance : public AudioSourceInstance - { - Openmpt *mParent; - void *mModfile; - int mPlaying; - - public: - OpenmptInstance(Openmpt *aParent); - virtual ~OpenmptInstance(); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual bool hasEnded(); - }; - - class Openmpt : public AudioSource - { - public: - char *mData; - unsigned int mDataLen; - Openmpt(); - virtual ~Openmpt(); - result load(const char* aFilename); - result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); - result loadFile(File *aFile); - virtual AudioSourceInstance *createInstance(); - }; -}; - +/* +Openmpt module for SoLoud audio engine +Copyright (c) 2016 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef OPENMPT_H +#define OPENMPT_H + +#include "soloud.h" + +namespace SoLoud +{ + class Openmpt; + class File; + + class OpenmptInstance : public AudioSourceInstance + { + Openmpt *mParent; + void *mModfile; + int mPlaying; + + public: + OpenmptInstance(Openmpt *aParent); + virtual ~OpenmptInstance(); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual bool hasEnded(); + }; + + class Openmpt : public AudioSource + { + public: + char *mData; + unsigned int mDataLen; + Openmpt(); + virtual ~Openmpt(); + result load(const char* aFilename); + result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); + result loadFile(File *aFile); + virtual AudioSourceInstance *createInstance(); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_queue.h b/include/common/soloud/soloud_queue.h new file mode 100644 index 0000000..0491f56 --- /dev/null +++ b/include/common/soloud/soloud_queue.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_robotizefilter.h b/include/common/soloud/soloud_robotizefilter.h new file mode 100644 index 0000000..735e332 --- /dev/null +++ b/include/common/soloud/soloud_robotizefilter.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_sfxr.h b/include/common/soloud/soloud_sfxr.h index dd3a5ce..b8ae442 100755 --- a/include/common/soloud/soloud_sfxr.h +++ b/include/common/soloud/soloud_sfxr.h @@ -1,169 +1,159 @@ -/* -SFXR module for SoLoud audio engine -Copyright (c) 2014 Jari Komppa -Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SFXR_H -#define SFXR_H - -#include "soloud.h" - -namespace SoLoud -{ - class File; - - class Prg - { - public: - // random generator - Prg(); - unsigned int state[16]; - unsigned int index; - unsigned int rand(); - void srand(int aSeed); - }; - - struct SfxrParams - { - int wave_type; - - float p_base_freq; - float p_freq_limit; - float p_freq_ramp; - float p_freq_dramp; - float p_duty; - float p_duty_ramp; - - float p_vib_strength; - float p_vib_speed; - float p_vib_delay; - - float p_env_attack; - float p_env_sustain; - float p_env_decay; - float p_env_punch; - - bool filter_on; - float p_lpf_resonance; - float p_lpf_freq; - float p_lpf_ramp; - float p_hpf_freq; - float p_hpf_ramp; - - float p_pha_offset; - float p_pha_ramp; - - float p_repeat_speed; - - float p_arp_speed; - float p_arp_mod; - - float master_vol; - - float sound_vol; - }; - - class Sfxr; - - class SfxrInstance : public AudioSourceInstance - { - Sfxr *mParent; - - Prg mRand; - SfxrParams mParams; - - bool playing_sample; - int phase; - double fperiod; - double fmaxperiod; - double fslide; - double fdslide; - int period; - float square_duty; - float square_slide; - int env_stage; - int env_time; - int env_length[3]; - float env_vol; - float fphase; - float fdphase; - int iphase; - float phaser_buffer[1024]; - int ipp; - float noise_buffer[32]; - float fltp; - float fltdp; - float fltw; - float fltw_d; - float fltdmp; - float fltphp; - float flthp; - float flthp_d; - float vib_phase; - float vib_speed; - float vib_amp; - int rep_time; - int rep_limit; - int arp_time; - int arp_limit; - double arp_mod; - - void resetSample(bool aRestart); - - public: - SfxrInstance(Sfxr *aParent); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual bool hasEnded(); - }; - - class Sfxr : public AudioSource - { - public: - SfxrParams mParams; - - enum SFXR_PRESETS - { - COIN, - LASER, - EXPLOSION, - POWERUP, - HURT, - JUMP, - BLIP - }; - - Prg mRand; - - Sfxr(); - virtual ~Sfxr(); - void resetParams(); - result loadParams(const char* aFilename); - result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); - result loadParamsFile(File *aFile); - - result loadPreset(int aPresetNo, int aRandSeed); - virtual AudioSourceInstance *createInstance(); - }; -}; - +/* +SFXR module for SoLoud audio engine +Copyright (c) 2014 Jari Komppa +Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SFXR_H +#define SFXR_H + +#include "soloud.h" +#include "soloud_misc.h" + +namespace SoLoud +{ + class File; + + struct SfxrParams + { + int wave_type; + + float p_base_freq; + float p_freq_limit; + float p_freq_ramp; + float p_freq_dramp; + float p_duty; + float p_duty_ramp; + + float p_vib_strength; + float p_vib_speed; + float p_vib_delay; + + float p_env_attack; + float p_env_sustain; + float p_env_decay; + float p_env_punch; + + bool filter_on; + float p_lpf_resonance; + float p_lpf_freq; + float p_lpf_ramp; + float p_hpf_freq; + float p_hpf_ramp; + + float p_pha_offset; + float p_pha_ramp; + + float p_repeat_speed; + + float p_arp_speed; + float p_arp_mod; + + float master_vol; + + float sound_vol; + }; + + class Sfxr; + + class SfxrInstance : public AudioSourceInstance + { + Sfxr *mParent; + + Misc::Prg mRand; + SfxrParams mParams; + + bool playing_sample; + int phase; + double fperiod; + double fmaxperiod; + double fslide; + double fdslide; + int period; + float square_duty; + float square_slide; + int env_stage; + int env_time; + int env_length[3]; + float env_vol; + float fphase; + float fdphase; + int iphase; + float phaser_buffer[1024]; + int ipp; + float noise_buffer[32]; + float fltp; + float fltdp; + float fltw; + float fltw_d; + float fltdmp; + float fltphp; + float flthp; + float flthp_d; + float vib_phase; + float vib_speed; + float vib_amp; + int rep_time; + int rep_limit; + int arp_time; + int arp_limit; + double arp_mod; + + void resetSample(bool aRestart); + + public: + SfxrInstance(Sfxr *aParent); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual bool hasEnded(); + }; + + class Sfxr : public AudioSource + { + public: + SfxrParams mParams; + + enum SFXR_PRESETS + { + COIN, + LASER, + EXPLOSION, + POWERUP, + HURT, + JUMP, + BLIP + }; + + Misc::Prg mRand; + + Sfxr(); + virtual ~Sfxr(); + void resetParams(); + result loadParams(const char* aFilename); + result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); + result loadParamsFile(File *aFile); + + result loadPreset(int aPresetNo, int aRandSeed); + virtual AudioSourceInstance *createInstance(); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_speech.h b/include/common/soloud/soloud_speech.h index 680d1e0..fa7436c 100755 --- a/include/common/soloud/soloud_speech.h +++ b/include/common/soloud/soloud_speech.h @@ -1,63 +1,79 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ -#ifndef SOLOUD_SPEECH_H -#define SOLOUD_SPEECH_H - -#include "soloud.h" -#include "../src/audiosource/speech/darray.h" -#include "../src/audiosource/speech/klatt.h" -#include "../src/audiosource/speech/tts.h" - -namespace SoLoud -{ - class Speech; - - class Speech : public AudioSource - { - public: - int mFrames; - darray mElement; - Speech(); - result setText(const char *aText); - virtual ~Speech(); - virtual AudioSourceInstance *createInstance(); - }; - - class SpeechInstance : public AudioSourceInstance - { - klatt mSynth; - Speech *mParent; - short *mSample; - int mSampleCount; - int mOffset; - public: - SpeechInstance(Speech *aParent); - virtual ~SpeechInstance(); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual result rewind(); - virtual bool hasEnded(); - }; -}; - -#endif +/* +SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ +#ifndef SOLOUD_SPEECH_H +#define SOLOUD_SPEECH_H + +#include "soloud.h" +#include "../src/audiosource/speech/darray.h" +#include "../src/audiosource/speech/klatt.h" +#include "../src/audiosource/speech/tts.h" + +namespace SoLoud +{ + class Speech; + + class Speech : public AudioSource + { + // copy of the enum in klatt.h for codegen purposes + enum KLATT_WAVEFORM + { + KW_SAW, + KW_TRIANGLE, + KW_SIN, + KW_SQUARE, + KW_PULSE, + KW_NOISE, + KW_WARBLE + }; + public: + int mBaseFrequency; + float mBaseSpeed; + float mBaseDeclination; + int mBaseWaveform; + int mFrames; + darray mElement; + Speech(); + result setText(const char *aText); + result setParams(unsigned int aBaseFrequency = 1330, float aBaseSpeed = 10.0f, float aBaseDeclination = 0.5f, int aBaseWaveform = KW_TRIANGLE); + virtual ~Speech(); + virtual AudioSourceInstance *createInstance(); + }; + + class SpeechInstance : public AudioSourceInstance + { + klatt mSynth; + Speech *mParent; + short *mSample; + int mSampleCount; + int mOffset; + public: + SpeechInstance(Speech *aParent); + virtual ~SpeechInstance(); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual result rewind(); + virtual bool hasEnded(); + }; +}; + +#endif diff --git a/include/common/soloud/soloud_tedsid.h b/include/common/soloud/soloud_tedsid.h index 72d8748..1b28e30 100755 --- a/include/common/soloud/soloud_tedsid.h +++ b/include/common/soloud/soloud_tedsid.h @@ -1,74 +1,72 @@ -/* -TED/SID module for SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef TEDSID_H -#define TEDSID_H - -#include "soloud.h" - -class SIDsound; -class TED; - -namespace SoLoud -{ - class TedSid; - class File; - - class TedSidInstance : public AudioSourceInstance - { - TedSid *mParent; - SIDsound *mSID; - TED *mTED; - unsigned int mSampleCount; - int mNextReg; - int mNextVal; - int mRegValues[128]; - public: - - TedSidInstance(TedSid *aParent); - ~TedSidInstance(); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual void tick(); - virtual bool hasEnded(); - virtual float getInfo(unsigned int aInfoKey); - }; - - class TedSid : public AudioSource - { - public: - File *mFile; - int mModel; - bool mFileOwned; - TedSid(); - ~TedSid(); - result load(const char *aFilename); - result loadToMem(const char *aFilename); - result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); - result loadFileToMem(File *aFile); - result loadFile(File *aFile); - virtual AudioSourceInstance *createInstance(); - }; -}; - +/* +TED/SID module for SoLoud audio engine +Copyright (c) 2013-2015 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef TEDSID_H +#define TEDSID_H + +#include "soloud.h" + +class SIDsound; +class TED; + +namespace SoLoud +{ + class TedSid; + class File; + + class TedSidInstance : public AudioSourceInstance + { + TedSid *mParent; + SIDsound *mSID; + TED *mTED; + int mPos; + unsigned int mSampleCount; + int mRegValues[128]; + public: + + TedSidInstance(TedSid *aParent); + ~TedSidInstance(); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual void tick(); + virtual bool hasEnded(); + virtual float getInfo(unsigned int aInfoKey); + }; + + class TedSid : public AudioSource + { + public: + int mLooppos; + int mLength; + unsigned short* mOps; + int mModel; + TedSid(); + ~TedSid(); + result load(const char *aFilename); + result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); + result loadFile(File *aFile); + virtual AudioSourceInstance *createInstance(); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_thread.h b/include/common/soloud/soloud_thread.h index b89eb62..5664689 100755 --- a/include/common/soloud/soloud_thread.h +++ b/include/common/soloud/soloud_thread.h @@ -1,83 +1,84 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2014 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_THREAD_H -#define SOLOUD_THREAD_H - -#include "soloud.h" - -namespace SoLoud -{ - namespace Thread - { - typedef void (*threadFunction)(void *aParam); - - struct ThreadHandleData; - typedef ThreadHandleData* ThreadHandle; - - void * createMutex(); - void destroyMutex(void *aHandle); - void lockMutex(void *aHandle); - void unlockMutex(void *aHandle); - - ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter); - - void sleep(int aMSec); - void wait(ThreadHandle aThreadHandle); - void release(ThreadHandle aThreadHandle); - -#define MAX_THREADPOOL_TASKS 1024 - - class PoolTask - { - public: - virtual void work() = 0; - }; - - class Pool - { - public: - // Initialize and run thread pool. For thread count 0, work is done at addWork call. - void init(int aThreadCount); - // Ctor, sets known state - Pool(); - // Dtor. Waits for the threads to finish. Work may be unfinished. - ~Pool(); - // Add work to work list. Object is not automatically deleted when work is done. - void addWork(PoolTask *aTask); - // Called from worker thread to get a new task. Returns null if no work available. - PoolTask *getWork(); - public: - int mThreadCount; // number of threads - ThreadHandle *mThread; // array of thread handles - void *mWorkMutex; // mutex to protect task array/maxtask - PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks - int mMaxTask; // how many tasks are pending - int mRobin; // cyclic counter, used to pick jobs for threads - volatile int mRunning; // running flag, used to flag threads to stop - }; - } -} - +/* +SoLoud audio engine +Copyright (c) 2013-2014 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_THREAD_H +#define SOLOUD_THREAD_H + +#include "soloud.h" + +namespace SoLoud +{ + namespace Thread + { + typedef void (*threadFunction)(void *aParam); + + struct ThreadHandleData; + typedef ThreadHandleData* ThreadHandle; + + void * createMutex(); + void destroyMutex(void *aHandle); + void lockMutex(void *aHandle); + void unlockMutex(void *aHandle); + + ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter); + + void sleep(int aMSec); + void wait(ThreadHandle aThreadHandle); + void release(ThreadHandle aThreadHandle); + int getTimeMillis(); + +#define MAX_THREADPOOL_TASKS 1024 + + class PoolTask + { + public: + virtual void work() = 0; + }; + + class Pool + { + public: + // Initialize and run thread pool. For thread count 0, work is done at addWork call. + void init(int aThreadCount); + // Ctor, sets known state + Pool(); + // Dtor. Waits for the threads to finish. Work may be unfinished. + ~Pool(); + // Add work to work list. Object is not automatically deleted when work is done. + void addWork(PoolTask *aTask); + // Called from worker thread to get a new task. Returns null if no work available. + PoolTask *getWork(); + public: + int mThreadCount; // number of threads + ThreadHandle *mThread; // array of thread handles + void *mWorkMutex; // mutex to protect task array/maxtask + PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks + int mMaxTask; // how many tasks are pending + int mRobin; // cyclic counter, used to pick jobs for threads + volatile int mRunning; // running flag, used to flag threads to stop + }; + } +} + #endif \ No newline at end of file diff --git a/include/common/soloud/soloud_vic.h b/include/common/soloud/soloud_vic.h index dd8845c..ef6b486 100755 --- a/include/common/soloud/soloud_vic.h +++ b/include/common/soloud/soloud_vic.h @@ -1,108 +1,108 @@ -/* -SoLoud audio engine -Copyright (c) 2015 Jari Komppa - -VIC 6560/6561 sound chip emulator -Copyright (c) 2015 Petri Hakkinen - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_VIC_H -#define SOLOUD_VIC_H - -#include "soloud.h" - -/* -A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models. -Bass, alto and soprano should be quite close to original vic, noise probably not so. - -The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency. -The highest bit of each oscillator register switches the oscillator on/off. -The fourth oscillator generates a noise waveform. - -VIC-20 does not have per channel volume control, only global volume, -which you can change by setting audio source's volume. - -To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter -with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0. -*/ - -namespace SoLoud -{ - class Vic; - - class VicInstance : public AudioSourceInstance - { - public: - VicInstance(Vic *aParent); - ~VicInstance(); - - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual bool hasEnded(); - - private: - Vic* m_parent; - unsigned int m_phase[4]; - unsigned int m_noisePos; - }; - - class Vic : public AudioSource - { - public: - // VIC model - enum - { - PAL = 0, - NTSC, - }; - - // VIC sound registers - enum - { - BASS = 0, - ALTO, - SOPRANO, - NOISE, - MAX_REGS - }; - - Vic(); - virtual ~Vic(); - - void setModel(int model); - int getModel() const; - - void setRegister(int reg, unsigned char value) { m_regs[reg] = value; } - unsigned char getRegister(int reg) const { return m_regs[reg]; } - - virtual AudioSourceInstance *createInstance(); - - private: - friend class VicInstance; - - int m_model; - float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model - unsigned char m_regs[MAX_REGS]; - unsigned char m_noise[8192]; - }; -}; - -#endif +/* +SoLoud audio engine +Copyright (c) 2015 Jari Komppa + +VIC 6560/6561 sound chip emulator +Copyright (c) 2015 Petri Hakkinen + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_VIC_H +#define SOLOUD_VIC_H + +#include "soloud.h" + +/* +A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models. +Bass, alto and soprano should be quite close to original vic, noise probably not so. + +The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency. +The highest bit of each oscillator register switches the oscillator on/off. +The fourth oscillator generates a noise waveform. + +VIC-20 does not have per channel volume control, only global volume, +which you can change by setting audio source's volume. + +To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter +with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0. +*/ + +namespace SoLoud +{ + class Vic; + + class VicInstance : public AudioSourceInstance + { + public: + VicInstance(Vic *aParent); + ~VicInstance(); + + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual bool hasEnded(); + + public: + Vic* m_parent; + unsigned int m_phase[4]; + unsigned int m_noisePos; + }; + + class Vic : public AudioSource + { + public: + // VIC model + enum + { + PAL = 0, + NTSC + }; + + // VIC sound registers + enum + { + BASS = 0, + ALTO, + SOPRANO, + NOISE, + MAX_REGS + }; + + Vic(); + + virtual ~Vic(); + + void setModel(int model); + + int getModel() const; + + void setRegister(int reg, unsigned char value); + + unsigned char getRegister(int reg); + + public: + virtual AudioSourceInstance *createInstance(); + int m_model; + float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model + unsigned char m_regs[MAX_REGS]; + unsigned char m_noise[8192]; + }; +}; + +#endif diff --git a/include/common/soloud/soloud_vizsn.h b/include/common/soloud/soloud_vizsn.h new file mode 100644 index 0000000..96e9b08 --- /dev/null +++ b/include/common/soloud/soloud_vizsn.h @@ -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 diff --git a/include/common/soloud/soloud_wav.h b/include/common/soloud/soloud_wav.h index a76cf2f..ab3be0b 100755 --- a/include/common/soloud/soloud_wav.h +++ b/include/common/soloud/soloud_wav.h @@ -1,68 +1,74 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_WAV_H -#define SOLOUD_WAV_H - -#include "soloud.h" - -struct stb_vorbis; - -namespace SoLoud -{ - class Wav; - class File; - - class WavInstance : public AudioSourceInstance - { - Wav *mParent; - unsigned int mOffset; - public: - WavInstance(Wav *aParent); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual result rewind(); - virtual bool hasEnded(); - }; - - class Wav : public AudioSource - { - result loadwav(File *aReader); - result loadogg(File *aReader); - result testAndLoadFile(File *aReader); - public: - float *mData; - unsigned int mSampleCount; - - Wav(); - virtual ~Wav(); - result load(const char *aFilename); - result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); - result loadFile(File *aFile); - - virtual AudioSourceInstance *createInstance(); - time getLength(); - }; -}; - -#endif +/* +SoLoud audio engine +Copyright (c) 2013-2018 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_WAV_H +#define SOLOUD_WAV_H + +#include "soloud.h" + +struct stb_vorbis; + +namespace SoLoud +{ + class Wav; + class File; + class MemoryFile; + + class WavInstance : public AudioSourceInstance + { + Wav *mParent; + unsigned int mOffset; + public: + WavInstance(Wav *aParent); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual result rewind(); + virtual bool hasEnded(); + }; + + class Wav : public AudioSource + { + result loadwav(MemoryFile *aReader); + result loadogg(MemoryFile *aReader); + result loadmp3(MemoryFile *aReader); + result loadflac(MemoryFile *aReader); + result testAndLoadFile(MemoryFile *aReader); + public: + float *mData; + unsigned int mSampleCount; + + Wav(); + virtual ~Wav(); + result load(const char *aFilename); + result loadMem(const unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); + result loadFile(File *aFile); + result loadRawWave8(unsigned char *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1); + result loadRawWave16(short *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1); + result loadRawWave(float *aMem, unsigned int aLength, float aSamplerate = 44100.0f, unsigned int aChannels = 1, bool aCopy = false, bool aTakeOwnership = true); + + virtual AudioSourceInstance *createInstance(); + time getLength(); + }; +}; + +#endif diff --git a/include/common/soloud/soloud_waveshaperfilter.h b/include/common/soloud/soloud_waveshaperfilter.h new file mode 100644 index 0000000..6b6791c --- /dev/null +++ b/include/common/soloud/soloud_waveshaperfilter.h @@ -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 \ No newline at end of file diff --git a/include/common/soloud/soloud_wavstream.h b/include/common/soloud/soloud_wavstream.h index 81ee17e..0f46e14 100755 --- a/include/common/soloud/soloud_wavstream.h +++ b/include/common/soloud/soloud_wavstream.h @@ -1,83 +1,106 @@ -/* -SoLoud audio engine -Copyright (c) 2013-2015 Jari Komppa - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#ifndef SOLOUD_WAVSTREAM_H -#define SOLOUD_WAVSTREAM_H - -#include -#include "soloud.h" - - -struct stb_vorbis; - -namespace SoLoud -{ - class WavStream; - class File; - - class WavStreamInstance : public AudioSourceInstance - { - WavStream *mParent; - unsigned int mOffset; - File *mFile; - stb_vorbis *mOgg; - unsigned int mOggFrameSize; - unsigned int mOggFrameOffset; - float **mOggOutputs; - public: - WavStreamInstance(WavStream *aParent); - virtual void getAudio(float *aBuffer, unsigned int aSamples); - virtual result rewind(); - virtual bool hasEnded(); - virtual ~WavStreamInstance(); - }; - - class WavStream : public AudioSource - { - result loadwav(File * fp); - result loadogg(File * fp); - public: - int mOgg; - char *mFilename; - File *mMemFile; - File *mStreamFile; - unsigned int mDataOffset; - unsigned int mBits; - unsigned int mSampleCount; - - WavStream(); - virtual ~WavStream(); - result load(const char *aFilename); - result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true); - result loadToMem(const char *aFilename); - result loadFile(File *aFile); - result loadFileToMem(File *aFile); - virtual AudioSourceInstance *createInstance(); - time getLength(); - public: - result parse(File *aFile); - }; -}; - +/* +SoLoud audio engine +Copyright (c) 2013-2018 Jari Komppa + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifndef SOLOUD_WAVSTREAM_H +#define SOLOUD_WAVSTREAM_H + +#include +#include "soloud.h" + +struct stb_vorbis; +#ifndef dr_flac_h +struct drflac; +#endif +#ifndef dr_mp3_h +struct drmp3; +#endif +#ifndef dr_wav_h +struct drwav; +#endif + +namespace SoLoud +{ + class WavStream; + class File; + + class WavStreamInstance : public AudioSourceInstance + { + WavStream *mParent; + unsigned int mOffset; + File *mFile; + union codec + { + stb_vorbis *mOgg; + drflac *mFlac; + drmp3 *mMp3; + drwav *mWav; + } mCodec; + unsigned int mOggFrameSize; + unsigned int mOggFrameOffset; + float **mOggOutputs; + public: + WavStreamInstance(WavStream *aParent); + virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize); + virtual result rewind(); + virtual bool hasEnded(); + virtual ~WavStreamInstance(); + }; + + enum WAVSTREAM_FILETYPE + { + WAVSTREAM_WAV = 0, + WAVSTREAM_OGG = 1, + WAVSTREAM_FLAC = 2, + WAVSTREAM_MP3 = 3 + }; + + class WavStream : public AudioSource + { + result loadwav(File *fp); + result loadogg(File *fp); + result loadflac(File *fp); + result loadmp3(File *fp); + public: + int mFiletype; + char *mFilename; + File *mMemFile; + File *mStreamFile; + unsigned int mSampleCount; + + WavStream(); + virtual ~WavStream(); + result load(const char *aFilename); + result loadMem(const unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true); + result loadToMem(const char *aFilename); + result loadFile(File *aFile); + result loadFileToMem(File *aFile); + virtual AudioSourceInstance *createInstance(); + time getLength(); + + public: + result parse(File *aFile); + }; +}; + #endif \ No newline at end of file diff --git a/include/common/soloud/zx7decompress.h b/include/common/soloud/zx7decompress.h new file mode 100644 index 0000000..3c388aa --- /dev/null +++ b/include/common/soloud/zx7decompress.h @@ -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 \ No newline at end of file diff --git a/lib/windows/soloud/soloud_x64.dll b/lib/windows/soloud/soloud_x64.dll index d4bbaba..8fb8556 100755 Binary files a/lib/windows/soloud/soloud_x64.dll and b/lib/windows/soloud/soloud_x64.dll differ diff --git a/lib/windows/soloud/soloud_x64.exp b/lib/windows/soloud/soloud_x64.exp index 45e116f..2a7abb6 100755 Binary files a/lib/windows/soloud/soloud_x64.exp and b/lib/windows/soloud/soloud_x64.exp differ diff --git a/lib/windows/soloud/soloud_x64.lib b/lib/windows/soloud/soloud_x64.lib index 4cbf402..be15016 100755 Binary files a/lib/windows/soloud/soloud_x64.lib and b/lib/windows/soloud/soloud_x64.lib differ diff --git a/lib/windows/soloud/soloud_x64_d.dll b/lib/windows/soloud/soloud_x64_d.dll index d0ca26f..51431b1 100755 Binary files a/lib/windows/soloud/soloud_x64_d.dll and b/lib/windows/soloud/soloud_x64_d.dll differ diff --git a/lib/windows/soloud/soloud_x64_d.exp b/lib/windows/soloud/soloud_x64_d.exp index e1c66a7..a8f9d6b 100755 Binary files a/lib/windows/soloud/soloud_x64_d.exp and b/lib/windows/soloud/soloud_x64_d.exp differ diff --git a/lib/windows/soloud/soloud_x64_d.ilk b/lib/windows/soloud/soloud_x64_d.ilk index fc7ec20..dce85d7 100755 Binary files a/lib/windows/soloud/soloud_x64_d.ilk and b/lib/windows/soloud/soloud_x64_d.ilk differ diff --git a/lib/windows/soloud/soloud_x64_d.lib b/lib/windows/soloud/soloud_x64_d.lib index b49fefc..83b9cd9 100755 Binary files a/lib/windows/soloud/soloud_x64_d.lib and b/lib/windows/soloud/soloud_x64_d.lib differ diff --git a/lib/windows/soloud/soloud_x64_d.pdb b/lib/windows/soloud/soloud_x64_d.pdb index 4e8c461..faf76f0 100755 Binary files a/lib/windows/soloud/soloud_x64_d.pdb and b/lib/windows/soloud/soloud_x64_d.pdb differ diff --git a/src/common/hashmap.c b/src/common/hashmap.c index 6a4fdb1..51f0c7f 100755 --- a/src/common/hashmap.c +++ b/src/common/hashmap.c @@ -10,7 +10,7 @@ struct Hashmap_Entry { - char* key; + char key[MAX_HASH_KEY_LEN]; struct Variant value; }; @@ -32,12 +32,14 @@ static struct Hashmap_Entry* hashmap_entry_new(struct Hashmap* hashmap, const ch if(strncmp(key, hashmap->buckets[index][i].key, MAX_HASH_KEY_LEN) == 0) { new_entry = &hashmap->buckets[index][i]; - if(new_entry->key) memory_free(new_entry->key); + //if(new_entry->key) memory_free(new_entry->key); + memset(new_entry->key, '\0', MAX_HASH_KEY_LEN); break; } } if(!new_entry) new_entry = array_grow(hashmap->buckets[index], struct Hashmap_Entry); - new_entry->key = str_new(key); + //new_entry->key = str_new(key); + strncpy(new_entry->key, key, MAX_HASH_KEY_LEN); new_entry->value.type = VT_NONE; variant_free(&new_entry->value); return new_entry; @@ -57,8 +59,9 @@ struct Hashmap* hashmap_create(void) struct Hashmap* hashmap = memory_allocate(sizeof(*hashmap)); if(!hashmap) return NULL; + for(int i = 0; i < HASH_MAP_NUM_BUCKETS; i++) - hashmap->buckets[i] = array_new(struct Hashmap_Entry); + hashmap->buckets[i] = array_new(struct Hashmap_Entry); hashmap->iter_bucket = 0; hashmap->iter_index = -1; return hashmap; @@ -72,11 +75,12 @@ void hashmap_free(struct Hashmap* hashmap) for(int j = 0; j < array_len(hashmap->buckets[i]); j++) { struct Hashmap_Entry* entry = &hashmap->buckets[i][j]; - if(entry->key) - { - memory_free(entry->key); - entry->key = NULL; - } + //if(entry->key) + //{ + // memory_free(entry->key); + // entry->key = NULL; + //} + memset(entry->key, '\0', MAX_HASH_KEY_LEN); variant_free(&entry->value); } array_free(hashmap->buckets[i]); diff --git a/src/common/limits.h b/src/common/limits.h index ed6871a..e2c688b 100644 --- a/src/common/limits.h +++ b/src/common/limits.h @@ -39,7 +39,7 @@ #define MAX_DEBUG_VARS_PER_FRAME_TEXTURES 8 #define HASH_MAP_NUM_BUCKETS 10 -#define MAX_HASH_KEY_LEN 128 +#define MAX_HASH_KEY_LEN 64 #define MAX_PLAYER_HEALTH 100 diff --git a/src/common/memory_utils.c b/src/common/memory_utils.c index 8621319..1f2f95e 100644 --- a/src/common/memory_utils.c +++ b/src/common/memory_utils.c @@ -23,7 +23,7 @@ void* memory_allocate(size_t size) //memory->allocated += size; memory.allocated += size + sizeof(*allocation); } - return allocation->allocation; + return allocation ? allocation->allocation : NULL; } void* memory_reallocate_(void** ptr, size_t size) @@ -34,6 +34,7 @@ void* memory_reallocate_(void** ptr, size_t size) } struct Memory_Allocation* current_allocation = memory_get_allocation_ptr(*ptr); + int current_allocation_size = current_allocation->size; void* reallocated_memory = realloc(current_allocation, sizeof(*current_allocation) + size); if(!reallocated_memory) { @@ -41,13 +42,13 @@ void* memory_reallocate_(void** ptr, size_t size) } else { - memory.allocated += (size - current_allocation->size); - current_allocation->size = size; + memory.allocated += (size - current_allocation_size); + struct Memory_Allocation* new_allocation = (struct Memory_Allocation*)reallocated_memory; + new_allocation->size = size; current_allocation = reallocated_memory; } return current_allocation->allocation; - } void* memory_allocate_and_clear(size_t count, size_t size) @@ -63,7 +64,7 @@ void* memory_allocate_and_clear(size_t count, size_t size) //memory->allocated += size; memory.allocated += size + sizeof(*allocation); } - return allocation->allocation; + return allocation ? allocation->allocation : NULL; } void memory_free(void* ptr) diff --git a/src/common/version.h b/src/common/version.h index e1f745d..6eb10b0 100755 --- a/src/common/version.h +++ b/src/common/version.h @@ -4,9 +4,7 @@ /* Auto generated version file. DO NOT MODIFY */ #define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MINOR 2 -#define SYMMETRY_VERSION_REVISION 368 +#define SYMMETRY_VERSION_REVISION 371 #define SYMMETRY_VERSION_BRANCH "dev" -#endif - -#endif +#endif \ No newline at end of file