/* 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 __GeneralSynthConfiguration_H__ #define __GeneralSynthConfiguration_H__ #ifdef __cplusplus extern "C" { #endif typedef struct GeneralSynthConfiguration GeneralSynthConfiguration; #define GeneralSynthConfiguration_superclass StemObject #include "audiosynth/AudioSamplerParameters_multitrack.h" #include "audiosynth/FrequencyCurve_ramp.h" #include "audiosynth/FrequencyCurve_stairstep.h" #include "audiosynth/SplineInfo.h" #include "audiosynth/WaveModifier_chord.h" #include "pcmaudio/PCMAudio.h" #include "serialization/DeserializationContext.h" #include "serialization/SerializationContext.h" #include "stemobject/StemObject.h" #define GeneralSynthConfiguration_formatVersion 1 #define GeneralSynthConfiguration_formatType "synth" #define GeneralSynthConfiguration_amplitude_formatVersion 1 #define GeneralSynthConfiguration_amplitude_formatType "amp" #define GeneralSynthConfiguration_frequency_formatVersion 0 #define GeneralSynthConfiguration_frequency_formatType "freq" #define GeneralSynthConfiguration_wave_formatVersion 0 #define GeneralSynthConfiguration_wave_formatType "wave" #define GeneralSynthConfiguration_signalFilter_formatVersion 0 #define GeneralSynthConfiguration_signalFilter_formatType "sflt" #define GeneralSynthConfiguration_waveModifier_formatVersion 0 #define GeneralSynthConfiguration_waveModifier_formatType "wmod" #define GeneralSynthConfiguration_synthPropertyController_formatVersion 0 #define GeneralSynthConfiguration_synthPropertyController_formatType "cont" typedef enum GeneralSynthConfiguration_amplitudeType { AMPLITUDE_TYPE_LAYERED, AMPLITUDE_TYPE_FLAT, AMPLITUDE_TYPE_ADSR, AMPLITUDE_TYPE_PULSE, AMPLITUDE_TYPE_SPLINE, AMPLITUDE_TYPE_TREMOLO } GeneralSynthConfiguration_amplitudeType; typedef enum GeneralSynthConfiguration_frequencyType { FREQUENCY_TYPE_LAYERED, FREQUENCY_TYPE_FLAT, FREQUENCY_TYPE_STAIRSTEP, FREQUENCY_TYPE_RAMP, FREQUENCY_TYPE_SPLINE, FREQUENCY_TYPE_VIBRATO } GeneralSynthConfiguration_frequencyType; typedef enum GeneralSynthConfiguration_waveType { WAVE_TYPE_LAYERED, WAVE_TYPE_SINE, WAVE_TYPE_PULSE, WAVE_TYPE_SAWTOOTH, WAVE_TYPE_TRIANGLE, WAVE_TYPE_WHITE_NOISE, WAVE_TYPE_PINK_NOISE, WAVE_TYPE_BITNOISE, WAVE_TYPE_SPIKE, WAVE_TYPE_SPLINE, WAVE_TYPE_MODIFIED, WAVE_TYPE_PCM_DATA } GeneralSynthConfiguration_waveType; typedef enum GeneralSynthConfiguration_signalFilterType { SIGNAL_FILTER_TYPE_BITCRUSH, SIGNAL_FILTER_TYPE_COMPRESSION, SIGNAL_FILTER_TYPE_DISTORTION, SIGNAL_FILTER_TYPE_DELAY } GeneralSynthConfiguration_signalFilterType; typedef enum GeneralSynthConfiguration_waveModifierType { WAVE_MODIFIER_TYPE_DISTORTION, WAVE_MODIFIER_TYPE_HARMONICS, WAVE_MODIFIER_TYPE_RESET, WAVE_MODIFIER_TYPE_SUPERSAMPLE, WAVE_MODIFIER_TYPE_CHORD, WAVE_MODIFIER_TYPE_PHASER, WAVE_MODIFIER_TYPE_SFXRHIGHLOWPASS, WAVE_MODIFIER_TYPE_HIGHLOWPASS, WAVE_MODIFIER_TYPE_TIME_VALUE_TRANSFORM, WAVE_MODIFIER_TYPE_THINNING, WAVE_MODIFIER_TYPE_TIME_CURVE, WAVE_MODIFIER_TYPE_RING_MODULATION } GeneralSynthConfiguration_waveModifierType; typedef enum GeneralSynthConfiguration_synthPropertyControllerType { SYNTH_PROPERTY_CONTROLLER_TYPE_RAMP, SYNTH_PROPERTY_CONTROLLER_TYPE_SINE } GeneralSynthConfiguration_synthPropertyControllerType; struct GeneralSynthConfiguration_amplitudeParameters { GeneralSynthConfiguration_amplitudeType type; union { struct { float baseAmplitude; float length; } flat; struct { float baseAmplitude; int blendMode; unsigned int layerCount; struct GeneralSynthConfiguration_amplitudeLayer * layers; } layered; struct { float peakAmplitude; float sustainAmplitude; float punchAmplitude; float attackTime; float decayTime; float sustainTime; float releaseTime; } linearADSR; struct { float cycleCount; float maxAmplitude; float minAmplitude; float startPhase; float attackTime; float sustainTime; float releaseTime; float restTime; } pulse; struct { SplineInfo spline; float length; } spline; struct { float baseAmplitude; float strength; float speed; float phase; float length; } tremolo; } info; }; struct GeneralSynthConfiguration_amplitudeLayer { struct GeneralSynthConfiguration_amplitudeParameters parameters; float blend; bool mute; bool solo; }; struct GeneralSynthConfiguration_frequencyParameters { GeneralSynthConfiguration_frequencyType type; union { struct { float baseValue; } flat; struct { float baseValue; int blendMode; unsigned int layerCount; struct GeneralSynthConfiguration_frequencyLayer * layers; } layered; struct { float baseValue; float linearRamp; float curvedRamp; float onset; float endpoint; float resetPoint; FrequencyCurve_ramp_boundType boundType; } ramp; struct { float baseValue; uint16_t stepCount; struct FrequencyCurve_stairstep_step * steps; uint16_t repeatStartIndex; uint16_t repeatCount; } stairstep; struct { float baseValue; SplineInfo spline; } spline; struct { float baseValue; float strength; float speed; float phase; } vibrato; } info; }; struct GeneralSynthConfiguration_frequencyLayer { struct GeneralSynthConfiguration_frequencyParameters parameters; float blend; bool mute; bool solo; }; struct GeneralSynthConfiguration_waveModifierParameters { enum GeneralSynthConfiguration_waveModifierType type; float blend; bool mute; bool solo; union { struct { float amplification; float clipRange; } distortion; struct { float toneCount; float frequencySpacing; float falloff; bool averageAmplitude; } harmonics; struct { float resetPoint; } reset; struct { unsigned int sampleCount; } supersample; struct { unsigned int noteCount; struct WaveModifier_chord_note * notes; } chord; struct { float timeOffset; bool smooth; unsigned int bufferSize; } phaser; struct { float lpCutoff; float lpRamp; float lpResonance; float hpCutoff; float hpRamp; } sfxrHighLowpass; struct { float lpStrength; float hpStrength; } highLowpass; struct { float timeOffset; float timeScale; float valueOffset; float valueScale; } timeValueTransform; struct { float amount; float center; } thinning; struct { float strength; float center; } timeCurve; struct { float carrierFrequency; float carrierPhaseOffset; struct GeneralSynthConfiguration_waveParameters * carrierParameters; } ringModulation; } info; }; struct GeneralSynthConfiguration_waveParameters { GeneralSynthConfiguration_waveType type; union { struct { int blendMode; unsigned int layerCount; struct GeneralSynthConfiguration_waveLayer * layers; } layered; struct { struct GeneralSynthConfiguration_waveParameters * samplerParameters; unsigned int modifierCount; struct GeneralSynthConfiguration_waveModifierParameters * modifiers; } modified; struct { float duty; float amplitude; } pulse; struct { float incline; float amplitude; } sawtooth; struct { uint32_t seed; bool smooth; } noise; struct { SplineInfo spline; } spline; struct { PCMAudio * audioData; bool loop; uint32_t startFrameIndex; uint32_t frameCount; } pcmData; } info; }; struct GeneralSynthConfiguration_waveLayer { struct GeneralSynthConfiguration_waveParameters parameters; float blend; bool mute; bool solo; float frequencyOffset; float phaseOffset; }; struct GeneralSynthConfiguration_signalFilterParameters { GeneralSynthConfiguration_signalFilterType type; char * name; float blend; bool mute; bool solo; union { struct { float numericResolution; float temporalResolution; } bitcrush; struct { float strength; } compression; struct { float amplification; float clipRange; } distortion; struct { float interval; float falloff; unsigned int repeatCount; } delay; } info; }; struct GeneralSynthConfiguration_synthPropertyControllerParameters { GeneralSynthConfiguration_synthPropertyControllerType type; SynthPropertyIdentifier identifier; bool mute; bool solo; union { struct { float startValue; float endValue; float curvePower; float onset; float endpoint; float resetPoint; } ramp; struct { float centerValue; float amplitude; float cycleCount; float startPhase; } sine; } info; }; struct GeneralSynthConfiguration_track { char * name; float offset; float blend; bool mute; bool solo; struct GeneralSynthConfiguration_amplitudeParameters amplitudeParameters; struct GeneralSynthConfiguration_frequencyParameters frequencyParameters; struct GeneralSynthConfiguration_waveParameters waveParameters; unsigned int signalFilterCount; struct GeneralSynthConfiguration_signalFilterParameters * signalFilterParameters; unsigned int controllerCount; struct GeneralSynthConfiguration_synthPropertyControllerParameters * controllerParameters; SamplerTimingMode timingMode; float length; bool amplitudeTimeAbsolute; bool frequencyTimeAbsolute; }; #define GeneralSynthConfiguration_ivars \ StemObject_ivars \ \ unsigned int trackCount; \ struct GeneralSynthConfiguration_track * tracks; #define GeneralSynthConfiguration_vtable(self_type) \ StemObject_vtable(self_type) stemobject_declare(GeneralSynthConfiguration) GeneralSynthConfiguration * GeneralSynthConfiguration_create(void); bool GeneralSynthConfiguration_init(GeneralSynthConfiguration * self); void GeneralSynthConfiguration_dispose(GeneralSynthConfiguration * self); AudioSamplerParameters_multitrack * GeneralSynthConfiguration_createAudioSamplerParameters(GeneralSynthConfiguration * self); GeneralSynthConfiguration * GeneralSynthConfiguration_createFromAudioSamplerParameters(AudioSamplerParameters_multitrack * samplerParameters); GeneralSynthConfiguration * GeneralSynthConfiguration_deserialize(compat_type(DeserializationContext *) deserializationContext); GeneralSynthConfiguration * GeneralSynthConfiguration_deserializeMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion); bool GeneralSynthConfiguration_initFromSerializedData(GeneralSynthConfiguration * self, compat_type(DeserializationContext *) deserializationContext); bool GeneralSynthConfiguration_initFromSerializedDataMinimal(GeneralSynthConfiguration * self, compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion); void GeneralSynthConfiguration_serialize(GeneralSynthConfiguration * self, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeMinimal(GeneralSynthConfiguration * self, compat_type(SerializationContext *) serializationContext); struct GeneralSynthConfiguration_amplitudeParameters GeneralSynthConfiguration_createAmplitudeParametersFromEnvelope(compat_type(AmplitudeEnvelope *) amplitudeEnvelope); AmplitudeEnvelope * GeneralSynthConfiguration_createAmplitudeEnvelopeFromParameters(struct GeneralSynthConfiguration_amplitudeParameters parameters); void GeneralSynthConfiguration_serializeAmplitudeParameters(struct GeneralSynthConfiguration_amplitudeParameters parameters, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeAmplitudeParametersMinimal(struct GeneralSynthConfiguration_amplitudeParameters parameters, compat_type(SerializationContext *) serializationContext); bool GeneralSynthConfiguration_deserializeAmplitudeParameters(compat_type(DeserializationContext *) deserializationContext, struct GeneralSynthConfiguration_amplitudeParameters * outParameters); bool GeneralSynthConfiguration_deserializeAmplitudeParametersMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion, struct GeneralSynthConfiguration_amplitudeParameters * outParameters); void GeneralSynthConfiguration_disposeAmplitudeParameters(struct GeneralSynthConfiguration_amplitudeParameters parameters); GeneralSynthConfiguration_amplitudeType getAmplitudeType(AmplitudeEnvelope * amplitudeEnvelope); const char * getAmplitudeEnvelopeHumanReadableName(GeneralSynthConfiguration_amplitudeType type); struct GeneralSynthConfiguration_frequencyParameters GeneralSynthConfiguration_createFrequencyParametersFromCurve(compat_type(FrequencyCurve *) frequencyCurve); FrequencyCurve * GeneralSynthConfiguration_createFrequencyCurveFromParameters(struct GeneralSynthConfiguration_frequencyParameters parameters); void GeneralSynthConfiguration_serializeFrequencyParameters(struct GeneralSynthConfiguration_frequencyParameters parameters, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeFrequencyParametersMinimal(struct GeneralSynthConfiguration_frequencyParameters parameters, compat_type(SerializationContext *) serializationContext); bool GeneralSynthConfiguration_deserializeFrequencyParameters(compat_type(DeserializationContext *) deserializationContext, struct GeneralSynthConfiguration_frequencyParameters * outParameters); bool GeneralSynthConfiguration_deserializeFrequencyParametersMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion, struct GeneralSynthConfiguration_frequencyParameters * outParameters); void GeneralSynthConfiguration_disposeFrequencyParameters(struct GeneralSynthConfiguration_frequencyParameters parameters); GeneralSynthConfiguration_frequencyType getFrequencyType(FrequencyCurve * frequencyCurve); const char * getFrequencyCurveHumanReadableName(GeneralSynthConfiguration_frequencyType type); struct GeneralSynthConfiguration_waveParameters GeneralSynthConfiguration_createWaveParametersFromSampler(compat_type(WaveSampler *) waveSampler); WaveSampler * GeneralSynthConfiguration_createWaveSamplerFromParameters(struct GeneralSynthConfiguration_waveParameters parameters); void GeneralSynthConfiguration_serializeWaveParameters(struct GeneralSynthConfiguration_waveParameters parameters, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeWaveParametersMinimal(struct GeneralSynthConfiguration_waveParameters parameters, compat_type(SerializationContext *) serializationContext); bool GeneralSynthConfiguration_deserializeWaveParameters(compat_type(DeserializationContext *) deserializationContext, struct GeneralSynthConfiguration_waveParameters * outParameters); bool GeneralSynthConfiguration_deserializeWaveParametersMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion, struct GeneralSynthConfiguration_waveParameters * outParameters); void GeneralSynthConfiguration_disposeWaveParameters(struct GeneralSynthConfiguration_waveParameters parameters); GeneralSynthConfiguration_waveType getWaveType(WaveSampler * waveSampler); const char * getWaveSamplerHumanReadableName(GeneralSynthConfiguration_waveType type); struct GeneralSynthConfiguration_signalFilterParameters GeneralSynthConfiguration_createSignalFilterParametersFromFilter(compat_type(SignalFilter *) signalFilter); SignalFilter * GeneralSynthConfiguration_createSignalFilterFromParameters(struct GeneralSynthConfiguration_signalFilterParameters parameters); void GeneralSynthConfiguration_serializeSignalFilterParameters(struct GeneralSynthConfiguration_signalFilterParameters parameters, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeSignalFilterParametersMinimal(struct GeneralSynthConfiguration_signalFilterParameters parameters, compat_type(SerializationContext *) serializationContext); bool GeneralSynthConfiguration_deserializeSignalFilterParameters(compat_type(DeserializationContext *) deserializationContext, struct GeneralSynthConfiguration_signalFilterParameters * outParameters); bool GeneralSynthConfiguration_deserializeSignalFilterParametersMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion, struct GeneralSynthConfiguration_signalFilterParameters * outParameters); void GeneralSynthConfiguration_disposeSignalFilterParameters(struct GeneralSynthConfiguration_signalFilterParameters parameters); GeneralSynthConfiguration_signalFilterType getSignalFilterType(SignalFilter * signalFilter); const char * getSignalFilterHumanReadableName(GeneralSynthConfiguration_signalFilterType type); struct GeneralSynthConfiguration_waveModifierParameters GeneralSynthConfiguration_createWaveModifierParametersFromModifier(compat_type(WaveModifier *) waveModifier); WaveModifier * GeneralSynthConfiguration_createWaveModifierFromParameters(struct GeneralSynthConfiguration_waveModifierParameters parameters); void GeneralSynthConfiguration_serializeWaveModifierParameters(struct GeneralSynthConfiguration_waveModifierParameters parameters, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeWaveModifierParametersMinimal(struct GeneralSynthConfiguration_waveModifierParameters parameters, compat_type(SerializationContext *) serializationContext); bool GeneralSynthConfiguration_deserializeWaveModifierParameters(compat_type(DeserializationContext *) deserializationContext, struct GeneralSynthConfiguration_waveModifierParameters * outParameters); bool GeneralSynthConfiguration_deserializeWaveModifierParametersMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion, struct GeneralSynthConfiguration_waveModifierParameters * outParameters); void GeneralSynthConfiguration_disposeWaveModifierParameters(struct GeneralSynthConfiguration_waveModifierParameters parameters); GeneralSynthConfiguration_waveModifierType getWaveModifierType(WaveModifier * waveModifier); const char * getWaveModifierHumanReadableName(GeneralSynthConfiguration_waveModifierType type); struct GeneralSynthConfiguration_synthPropertyControllerParameters GeneralSynthConfiguration_createSynthPropertyControllerParametersFromController(compat_type(SynthPropertyController *) controller); SynthPropertyController * GeneralSynthConfiguration_createSynthPropertyControllerFromParameters(struct GeneralSynthConfiguration_synthPropertyControllerParameters parameters); void GeneralSynthConfiguration_serializeSynthPropertyControllerParameters(struct GeneralSynthConfiguration_synthPropertyControllerParameters parameters, compat_type(SerializationContext *) serializationContext); void GeneralSynthConfiguration_serializeSynthPropertyControllerParametersMinimal(struct GeneralSynthConfiguration_synthPropertyControllerParameters parameters, compat_type(SerializationContext *) serializationContext); bool GeneralSynthConfiguration_deserializeSynthPropertyControllerParameters(compat_type(DeserializationContext *) deserializationContext, struct GeneralSynthConfiguration_synthPropertyControllerParameters * outParameters); bool GeneralSynthConfiguration_deserializeSynthPropertyControllerParametersMinimal(compat_type(DeserializationContext *) deserializationContext, uint16_t formatVersion, struct GeneralSynthConfiguration_synthPropertyControllerParameters * outParameters); void GeneralSynthConfiguration_disposeSynthPropertyControllerParameters(struct GeneralSynthConfiguration_synthPropertyControllerParameters parameters); GeneralSynthConfiguration_synthPropertyControllerType getSynthPropertyControllerType(SynthPropertyController * controller); const char * getSynthPropertyControllerHumanReadableName(GeneralSynthConfiguration_synthPropertyControllerType type); #ifdef __cplusplus } #endif #endif