/* Copyright (c) 2021 Alex Diener 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. Alex Diener alex@ludobloom.com */ #ifndef __AudioSamplerParameters_generalSynth_H__ #define __AudioSamplerParameters_generalSynth_H__ #ifdef __cplusplus extern "C" { #endif typedef struct AudioSamplerParameters_generalSynth AudioSamplerParameters_generalSynth; #define AudioSamplerParameters_generalSynth_superclass AudioSamplerParameters #include "audiosynth/AmplitudeEnvelope.h" #include "audiosynth/AudioSamplerParameters.h" #include "audiosynth/FrequencyCurve.h" #include "audiosynth/SignalFilter.h" #include "audiosynth/SynthPropertyController.h" #include "audiosynth/WaveSampler.h" typedef struct FilterChain { unsigned int signalFilterCount; SignalFilter ** signalFilters; } FilterChain; typedef struct SynthPropertyControllerList { unsigned int controllerCount; SynthPropertyController ** controllers; } SynthPropertyControllerList; #define FilterChain_empty ((FilterChain) {0, NULL}) #define SynthPropertyControllerList_empty ((SynthPropertyControllerList) {0, NULL}) typedef enum SamplerTimingMode { SAMPLER_TIMING_SPECIFY_LENGTH, // Sound length specified by length field SAMPLER_TIMING_AMPLITUDE_LENGTH, // Sound length specified by amplitude envelope's getLength() return value SAMPLER_TIMING_FREQUENCY_LENGTH, // Sound length specified by frequency curve's getLength() return value SAMPLER_TIMING_WAVE_LENGTH // Sound length specified by wave sampler's getLength() return value } SamplerTimingMode; #define AudioSamplerParameters_generalSynth_ivars \ AudioSamplerParameters_ivars \ \ WaveSampler * waveSampler; \ FrequencyCurve * frequencyCurve; \ AmplitudeEnvelope * amplitudeEnvelope; \ FilterChain filterChain; \ SynthPropertyControllerList controllerList; \ SamplerTimingMode timingMode; \ float length; \ bool amplitudeTimeAbsolute; \ bool frequencyTimeAbsolute; #define AudioSamplerParameters_generalSynth_vtable(self_type) \ AudioSamplerParameters_vtable(self_type) stemobject_declare(AudioSamplerParameters_generalSynth) // Takes ownership of all parameters // amplitudeTimeAbsolute and frequencyTimeAbsolute specify whether amplitudeEnvelope and frequencyCurve phase parameters are in seconds, or between 0 and 1 for the entire length of sound AudioSamplerParameters_generalSynth * AudioSamplerParameters_generalSynth_create(compat_type(WaveSampler *) waveSampler, compat_type(FrequencyCurve *) frequencyCurve, compat_type(AmplitudeEnvelope *) amplitudeEnvelope, FilterChain filterChain, SynthPropertyControllerList controllerList, SamplerTimingMode timingMode, float length, bool amplitudeTimeAbsolute, bool frequencyTimeAbsolute); bool AudioSamplerParameters_generalSynth_init(AudioSamplerParameters_generalSynth * self, compat_type(WaveSampler *) waveSampler, compat_type(FrequencyCurve *) frequencyCurve, compat_type(AmplitudeEnvelope *) amplitudeEnvelope, FilterChain filterChain, SynthPropertyControllerList controllerList, SamplerTimingMode timingMode, float length, bool amplitudeTimeAbsolute, bool frequencyTimeAbsolute); void AudioSamplerParameters_generalSynth_dispose(AudioSamplerParameters_generalSynth * self); AudioSamplerParameters_generalSynth * AudioSamplerParameters_generalSynth_copy(AudioSamplerParameters_generalSynth * self); void AudioSamplerParameters_generalSynth_initCopy(AudioSamplerParameters_generalSynth * self, AudioSamplerParameters_generalSynth * original); bool AudioSamplerParameters_generalSynth_isEqual(AudioSamplerParameters_generalSynth * self, compat_type(AudioSamplerParameters_generalSynth *) compare); uint32_t AudioSamplerParameters_generalSynth_hash(AudioSamplerParameters_generalSynth * self, uint32_t initval); SamplerObject * AudioSamplerParameters_generalSynth_getSamplerObject(AudioSamplerParameters_generalSynth * self, SynthPropertyRootType rootType, unsigned int index); #ifdef __cplusplus } #endif #endif