161 lines
9.9 KiB
C++
161 lines
9.9 KiB
C++
#include "SynthFactory.h"
|
|
#include "Component.h"
|
|
#include "Connection.h"
|
|
#include "Synth.h"
|
|
#include "EngineImpl.h"
|
|
#include "Components/Components.h"
|
|
#include "Connections/Connections.h"
|
|
|
|
|
|
Soundwich::SynthFactory::SynthFactory( Engine::Impl* engine )
|
|
{
|
|
// region Create Components
|
|
|
|
AddComponentCreateMethod( PlayMenuMusic::GetType( ), PlayMenuMusic::Create );
|
|
AddComponentCreateMethod( StopMenuMusic::GetType( ), StopMenuMusic::Create );
|
|
AddComponentCreateMethod( JDSound::GetType( ), JDSound::Create );
|
|
AddComponentCreateMethod( JDSoundSyncOnTransition::GetType( ), JDSoundSyncOnTransition::Create );
|
|
AddComponentCreateMethod( JDRemoteSound::GetType( ), JDRemoteSound::Create );
|
|
AddComponentCreateMethod( PlayEventBusMusic::GetType( ), PlayEventBusMusic::Create );
|
|
AddComponentCreateMethod( StopEventBusMusic::GetType( ), StopEventBusMusic::Create );
|
|
AddComponentCreateMethod( StopAllEventBusMixes::GetType(), StopAllEventBusMixes::Create );
|
|
AddComponentCreateMethod( PlayMusicMultiTrack::GetType( ), PlayMusicMultiTrack::Create );
|
|
AddComponentCreateMethod( EventIn::GetType( ), EventIn::Create );
|
|
AddComponentCreateMethod( EventInWithId::GetType( ), EventInWithId::Create );
|
|
AddComponentCreateMethod( EventOut::GetType( ), EventOut::Create );
|
|
AddComponentCreateMethod( ControlIn::GetType( ), ControlIn::Create );
|
|
AddComponentCreateMethod( ControlOut::GetType( ), ControlOut::Create );
|
|
AddComponentCreateMethod( SwitchIn::GetType( ), SwitchIn::Create );
|
|
AddComponentCreateMethod( SwitchOut::GetType( ), SwitchOut::Create );
|
|
AddComponentCreateMethod( EventPinIn::GetType( ), EventPinIn::Create );
|
|
AddComponentCreateMethod( EventPinOut::GetType( ), EventPinOut::Create );
|
|
AddComponentCreateMethod( ControlPinIn::GetType( ), ControlPinIn::Create );
|
|
AddComponentCreateMethod( ControlPinOut::GetType( ), ControlPinOut::Create );
|
|
AddComponentCreateMethod( SwitchPinIn::GetType( ), SwitchPinIn::Create );
|
|
AddComponentCreateMethod( SwitchPinOut::GetType( ), SwitchPinOut::Create );
|
|
AddComponentCreateMethod( ControlTriggerEvent::GetType( ), ControlTriggerEvent::Create );
|
|
AddComponentCreateMethod( ControlBandEvent::GetType( ), ControlBandEvent::Create );
|
|
AddComponentCreateMethod( SwitchTriggerEvent::GetType( ), SwitchTriggerEvent::Create );
|
|
AddComponentCreateMethod( SwitchBandEvent::GetType( ), SwitchBandEvent::Create );
|
|
AddComponentCreateMethod( EventToggleSwitch::GetType( ), EventToggleSwitch::Create );
|
|
AddComponentCreateMethod( EventPushSwitch::GetType( ), EventPushSwitch::Create );
|
|
AddComponentCreateMethod( EventMultiSwitch::GetType( ), EventMultiSwitch::Create );
|
|
AddComponentCreateMethod( ControlTriggerSwitch::GetType( ), ControlTriggerSwitch::Create );
|
|
AddComponentCreateMethod( ControlBandSwitch::GetType( ), ControlBandSwitch::Create );
|
|
AddComponentCreateMethod( ControlValueSwitch::GetType( ), ControlValueSwitch::Create );
|
|
AddComponentCreateMethod( AREnvelope::GetType( ), AREnvelope::Create );
|
|
AddComponentCreateMethod( AHREnvelope::GetType( ), AHREnvelope::Create );
|
|
AddComponentCreateMethod( ADSREnvelope::GetType( ), ADSREnvelope::Create );
|
|
AddComponentCreateMethod( LowFrequencyOscillator::GetType( ), LowFrequencyOscillator::Create );
|
|
AddComponentCreateMethod( Timer::GetType( ), Timer::Create );
|
|
AddComponentCreateMethod( EventImpulseControl::GetType( ), EventImpulseControl::Create );
|
|
AddComponentCreateMethod( SwitchTriggerControl::GetType( ), SwitchTriggerControl::Create );
|
|
AddComponentCreateMethod( SwitchBandControl::GetType( ), SwitchBandControl::Create );
|
|
AddComponentCreateMethod( SwitchValueControl::GetType( ), SwitchValueControl::Create );
|
|
AddComponentCreateMethod( CrossFader::GetType( ), CrossFader::Create );
|
|
AddComponentCreateMethod( CrossFaderMulti::GetType( ), CrossFaderMulti::Create );
|
|
AddComponentCreateMethod( EventRangeFilter::GetType( ), EventRangeFilter::Create );
|
|
AddComponentCreateMethod( EventMultiDispatcher::GetType( ), EventMultiDispatcher::Create );
|
|
AddComponentCreateMethod( State::GetType( ), State::Create );
|
|
AddComponentCreateMethod( PiecewiseLinearFunction::GetType( ), PiecewiseLinearFunction::Create );
|
|
AddComponentCreateMethod( PiecewiseCubicFunction::GetType( ), PiecewiseCubicFunction::Create );
|
|
AddComponentCreateMethod( AbsoluteControl::GetType( ), AbsoluteControl::Create );
|
|
AddComponentCreateMethod( AddControl::GetType( ), AddControl::Create );
|
|
AddComponentCreateMethod( AddMultiControl::GetType( ), AddMultiControl::Create );
|
|
AddComponentCreateMethod( ConstantControl::GetType( ), ConstantControl::Create );
|
|
AddComponentCreateMethod( DivideControl::GetType( ), DivideControl::Create );
|
|
AddComponentCreateMethod( MaxControl::GetType( ), MaxControl::Create );
|
|
AddComponentCreateMethod( MaxMultiControl::GetType( ), MaxMultiControl::Create );
|
|
AddComponentCreateMethod( MinControl::GetType( ), MinControl::Create );
|
|
AddComponentCreateMethod( MinMultiControl::GetType( ), MinMultiControl::Create );
|
|
AddComponentCreateMethod( MultiplyControl::GetType( ), MultiplyControl::Create );
|
|
AddComponentCreateMethod( MultiplyMultiControl::GetType( ), MultiplyMultiControl::Create );
|
|
AddComponentCreateMethod( PowerControl::GetType( ), PowerControl::Create );
|
|
AddComponentCreateMethod( ReciprocalControl::GetType( ), ReciprocalControl::Create );
|
|
AddComponentCreateMethod( SubtractControl::GetType( ), SubtractControl::Create );
|
|
AddComponentCreateMethod( SlewLimiter::GetType( ), SlewLimiter::Create );
|
|
AddComponentCreateMethod( HoldingSlewLimiter::GetType( ), HoldingSlewLimiter::Create );
|
|
AddComponentCreateMethod( LowPassSmoothing::GetType( ), LowPassSmoothing::Create );
|
|
AddComponentCreateMethod( Spring::GetType( ), Spring::Create );
|
|
AddComponentCreateMethod( AbsoluteSwitch::GetType( ), AbsoluteSwitch::Create );
|
|
AddComponentCreateMethod( AddSwitch::GetType( ), AddSwitch::Create );
|
|
AddComponentCreateMethod( ConstantSwitch::GetType( ), ConstantSwitch::Create );
|
|
AddComponentCreateMethod( MaxSwitch::GetType( ), MaxSwitch::Create );
|
|
AddComponentCreateMethod( MaxMultiSwitch::GetType( ), MaxMultiSwitch::Create );
|
|
AddComponentCreateMethod( MinSwitch::GetType( ), MinSwitch::Create );
|
|
AddComponentCreateMethod( MinMultiSwitch::GetType( ), MinMultiSwitch::Create );
|
|
AddComponentCreateMethod( EventRouter::GetType( ), EventRouter::Create );
|
|
AddComponentCreateMethod( EventMultiRouter::GetType( ), EventMultiRouter::Create );
|
|
AddComponentCreateMethod( ControlRouter::GetType( ), ControlRouter::Create );
|
|
AddComponentCreateMethod( ControlMultiRouter::GetType( ), ControlMultiRouter::Create );
|
|
AddComponentCreateMethod( SwitchRouter::GetType( ), SwitchRouter::Create );
|
|
AddComponentCreateMethod( SwitchMultiRouter::GetType( ), SwitchMultiRouter::Create );
|
|
AddComponentCreateMethod( EventSelector::GetType( ), EventSelector::Create );
|
|
AddComponentCreateMethod( EventMultiSelector::GetType( ), EventMultiSelector::Create );
|
|
AddComponentCreateMethod( ControlSelector::GetType( ), ControlSelector::Create );
|
|
AddComponentCreateMethod( ControlMultiSelector::GetType( ), ControlMultiSelector::Create );
|
|
AddComponentCreateMethod( SwitchSelector::GetType( ), SwitchSelector::Create );
|
|
AddComponentCreateMethod( SwitchMultiSelector::GetType( ), SwitchMultiSelector::Create );
|
|
AddComponentCreateMethod( DecibelToLinear::GetType( ), DecibelToLinear::Create );
|
|
AddComponentCreateMethod( LinearToDecibel::GetType( ), LinearToDecibel::Create );
|
|
AddComponentCreateMethod( RandomControl::GetType( ), RandomControl::Create );
|
|
AddComponentCreateMethod( RandomEvent::GetType( ), RandomEvent::Create );
|
|
AddComponentCreateMethod( RandomSwitch::GetType( ), RandomSwitch::Create );
|
|
AddComponentCreateMethod( WeightedRandomControl::GetType( ), WeightedRandomControl::Create );
|
|
|
|
// endregion
|
|
|
|
// region Connect Components
|
|
|
|
AddConnectionCreateMethod( ControlConnection::GetType( ), ControlConnection::Create );
|
|
AddConnectionCreateMethod( EventConnection::GetType( ), EventConnection::Create );
|
|
AddConnectionCreateMethod( SwitchConnection::GetType( ), SwitchConnection::Create );
|
|
|
|
// AddConnectionCreateMethod( Vector2Connection::GetType( ), Vector2Connection::Create );
|
|
// AddConnectionCreateMethod( Vector3Connection::GetType( ), Vector3Connection::Create );
|
|
// AddConnectionCreateMethod( MonoConnection::GetType( ), MonoConnection::Create );
|
|
// AddConnectionCreateMethod( StereoConnection::GetType( ), StereoConnection::Create );
|
|
// AddConnectionCreateMethod( QuadConnection::GetType( ), QuadConnection::Create );
|
|
// AddConnectionCreateMethod( FivePointZeroConnection::GetType( ), FivePointZeroConnection::Create );
|
|
// AddConnectionCreateMethod( FivePointOneConnection::GetType( ), FivePointOneConnection::Create );
|
|
|
|
// endregion
|
|
}
|
|
|
|
void Soundwich::SynthFactory::AddComponentCreateMethod( const Util::String& type, ComponentCreateMethod createMethod )
|
|
{
|
|
_createComponentMethods.Add( type, createMethod );
|
|
}
|
|
|
|
SoundResult Soundwich::SynthFactory::CreateComponent( Synth* synth, const Util::String& type, const Util::String& name, Component** component )
|
|
{
|
|
ComponentCreateMethod create;
|
|
|
|
SoundResult result = _createComponentMethods.TryGetValue( type, create ) ? Ok : UnknownComponentType;
|
|
|
|
if( result == Ok )
|
|
{
|
|
create( synth, name, component );
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
void Soundwich::SynthFactory::AddConnectionCreateMethod( const Util::String& type, ConnectionCreateMethod connectMethod )
|
|
{
|
|
_createConnectionMethods.Add( type, connectMethod );
|
|
}
|
|
|
|
SoundResult Soundwich::SynthFactory::CreateConnection( Synth* synth, const Util::String& type, Connection** connection )
|
|
{
|
|
ConnectionCreateMethod connect;
|
|
|
|
SoundResult result = _createConnectionMethods.TryGetValue( type, connect ) ? Ok : UnknownComponentConnectionType;
|
|
|
|
if( result == Ok )
|
|
{
|
|
connect( synth, connection );
|
|
}
|
|
|
|
return result;
|
|
}
|