/* 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 __WaveSampler_layered_H__ #define __WaveSampler_layered_H__ #ifdef __cplusplus extern "C" { #endif typedef struct WaveSampler_layered WaveSampler_layered; #define WaveSampler_layered_superclass WaveSampler #include "audiosynth/WaveSampler.h" typedef enum WaveSampler_layered_blendMode { WaveSampler_layered_add, WaveSampler_layered_multiply, WaveSampler_layered_average } WaveSampler_layered_blendMode; struct WaveSampler_layered_layer { WaveSampler * sampler; float blend; bool mute; bool solo; float frequencyOffset; float phaseOffset; }; #define WaveSampler_layered_ivars \ WaveSampler_ivars \ \ enum WaveSampler_layered_blendMode blendMode; \ unsigned int layerCount; \ struct WaveSampler_layered_layer * layers; #define WaveSampler_layered_vtable(self_type) \ WaveSampler_vtable(self_type) stemobject_declare(WaveSampler_layered) // Takes ownership of all contents of layers WaveSampler_layered * WaveSampler_layered_create(WaveSampler_layered_blendMode blendMode, unsigned int layerCount, struct WaveSampler_layered_layer * layers); bool WaveSampler_layered_init(WaveSampler_layered * self, WaveSampler_layered_blendMode blendMode, unsigned int layerCount, struct WaveSampler_layered_layer * layers); void WaveSampler_layered_dispose(WaveSampler_layered * self); WaveSampler_layered * WaveSampler_layered_copy(WaveSampler_layered * self); bool WaveSampler_layered_isEqual(WaveSampler_layered * self, compat_type(WaveSampler_layered *) compare); uint32_t WaveSampler_layered_hash(WaveSampler_layered * self, uint32_t initval); void WaveSampler_layered_initCopy(WaveSampler_layered * self, WaveSampler_layered * original); // Layer list must not be mutated between initializing and disposing state SamplerObject_state * WaveSampler_layered_initState(WaveSampler_layered * self); void WaveSampler_layered_disposeState(WaveSampler_layered * self, SamplerObject_state * state); unsigned int WaveSampler_layered_getPropertyCount(WaveSampler_layered * self); SynthProperty WaveSampler_layered_getPropertyAtIndex(WaveSampler_layered * self, unsigned int index); float WaveSampler_layered_getPropertyValueStateless(WaveSampler_layered * self, SynthPropertyIdentifier propertyIdentifier); void WaveSampler_layered_setPropertyValue(WaveSampler_layered * self, SamplerObject_state * state, SynthPropertyIdentifier propertyIdentifier, float value); float WaveSampler_layered_sample(WaveSampler_layered * self, SamplerObject_state * state, float phase, float phaseDelta, float time, float timeDelta); // Takes ownership of layer void WaveSampler_layered_addLayer(WaveSampler_layered * self, struct WaveSampler_layered_layer layer); void WaveSampler_layered_removeLayer(WaveSampler_layered * self, unsigned int layerIndex); #ifdef __cplusplus } #endif #endif