/* add a vocoder to the spec list */ public static void AddVocoderToEffectSpecList( EffectSpecListRec EffectSpecList, VocoderSpecRec VocSpec, bool EnabledFlag) { AddGenericToEffectSpecList(EffectSpecList, EffectTypes.eVocoderEffect, VocSpec, EnabledFlag); }
public static void PutVocoderSpecOutputGainAccent( VocoderSpecRec VocSpec, double Value, int AccentNum) { SetAccentMemberValue(ref VocSpec.OutputGainAccent, AccentNum, Value); }
public static void PutVocoderSpecIndexAccent( VocoderSpecRec VocSpec, double Value, int AccentNum) { SetAccentMemberValue(ref VocSpec.WaveTableIndexAccent, AccentNum, Value); }
public static void GetVocoderSpecOutputGainAgg( VocoderSpecRec VocSpec, out ScalarParamEvalRec ParamsOut) { InitScalarParamEval( VocSpec.OutputGain, ref VocSpec.OutputGainAccent, VocSpec.OutputGainFormula, out ParamsOut); }
public static void GetVocoderSpecWaveTableIndexAgg( VocoderSpecRec VocSpec, out ScalarParamEvalRec ParamsOut) { InitScalarParamEval( VocSpec.WaveTableIndex, ref VocSpec.WaveTableIndexAccent, VocSpec.WaveTableIndexFormula, out ParamsOut); }
/* build common stuff */ private static VocoderRec VocoderBuildCommonStructure( VocoderSpecRec Template, SynthParamRec SynthParams) { int BandCount; int OrderCount; float[][] WaveTableMatrix; int FramesPerTable; int NumberOfTables; if (!WaveSampDictGetWaveTableInfo( SynthParams.Dictionary, GetVocoderSpecWaveTableName(Template), out WaveTableMatrix, out FramesPerTable, out NumberOfTables)) { Debug.Assert(false); throw new InvalidOperationException(); } BandCount = GetVocoderMaxNumBands(Template); OrderCount = GetVocoderFilterOrder(Template) / 2; if (BandCount > FramesPerTable / VOC_FIELDCOUNT) { BandCount = FramesPerTable / VOC_FIELDCOUNT; } VocoderRec Vocoder = new VocoderRec(); Vocoder.CombinedGainFactorVector = new float[2 * BandCount]; Vocoder.FilterVector = new ButterworthBandpassRec[2 * BandCount * OrderCount]; Vocoder.BandCount = BandCount; Vocoder.OrderCount = OrderCount; Vocoder.ForceFilterUpdate = true; Vocoder.PreviousOutputScaling = 0; Vocoder.PreviousWaveTableIndex = -1; Vocoder.WaveTableMatrix = WaveTableMatrix; Vocoder.FramesPerTable = FramesPerTable; Vocoder.NumberOfTablesMinus1 = NumberOfTables - 1; Vocoder.EnableCrossWaveTableInterpolation = VocoderGetEnableCrossWaveTableInterpolation(Template); /* initialize band matrix */ for (int i = 0; i < 2 * BandCount * OrderCount; i++) { Vocoder.FilterVector[i] = new ButterworthBandpassRec(); } return(Vocoder); }
/* specify the maximum number of bands for the vocoder */ public static void PutVocoderMaxNumBands( VocoderSpecRec VocSpec, int MaxCount) { #if DEBUG if (MaxCount < 1) { Debug.Assert(false); throw new ArgumentException(); } #endif VocSpec.MaxBandCount = MaxCount; }
/* check vocoder effect */ public static SynthErrorCodes CheckVocoderEffectForUnreferencedSamples( VocoderSpecRec VocoderEffect, CheckUnrefParamRec Param) { SynthErrorCodes Error; string Name = GetVocoderSpecWaveTableName(VocoderEffect); if (!WaveSampDictDoesWaveTableExist( Param.Dictionary, Name)) { Param.ErrorInfo.ErrorEx = SynthErrorSubCodes.eSynthErrorExUndefinedWaveTable; Param.ErrorInfo.WaveTableName = Name; return(SynthErrorCodes.eSynthErrorEx); } Error = CheckEnvelopeForUnreferencedSamples( GetVocoderSpecIndexEnvelope(VocoderEffect), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } Error = CheckEnvelopeForUnreferencedSamples( GetVocoderSpecOutputGainEnvelope(VocoderEffect), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } Error = CheckLFOListForUnreferencedSamples( GetVocoderSpecIndexLFO(VocoderEffect), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } Error = CheckLFOListForUnreferencedSamples( GetVocoderSpecOutputGainLFO(VocoderEffect), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } return(SynthErrorCodes.eSynthDone); }
/* put the filter order (positive even number) */ public static void PutVocoderFilterOrder( VocoderSpecRec VocSpec, int Order) { #if DEBUG if ((Order < 2) || (Order % 2 != 0)) { // order must be positive even number Debug.Assert(false); throw new ArgumentException(); } #endif VocSpec.FilterOrder = Order; }
public static void PutVocoderSpecWaveTableIndex( VocoderSpecRec VocSpec, double WaveTableIndex, PcodeRec Formula) { #if DEBUG if (VocSpec.WaveTableIndexFormula != null) { Debug.Assert(false); throw new ArgumentException(); } #endif VocSpec.WaveTableIndexFormula = Formula; VocSpec.WaveTableIndex = WaveTableIndex; }
public static void PutVocoderSpecOutputGain( VocoderSpecRec VocSpec, double OutputGain, PcodeRec Formula) { #if DEBUG if (VocSpec.OutputGainFormula != null) { Debug.Assert(false); throw new ArgumentException(); } #endif VocSpec.OutputGainFormula = Formula; VocSpec.OutputGain = OutputGain; }
/* create a new track vocoder */ public static VocoderRec NewTrackVocoder( VocoderSpecRec Template, SynthParamRec SynthParams) { /* initialize common portion of structure */ VocoderRec Vocoder = VocoderBuildCommonStructure( Template, SynthParams); Vocoder.Track = new VocTrackRec(); /* initialize variant portion */ GetVocoderSpecOutputGainAgg( Template, out Vocoder.Track.OutputScaling); GetVocoderSpecWaveTableIndexAgg( Template, out Vocoder.Track.WaveTableIndex); return(Vocoder); }
public static VocoderSpecRec NewVocoderSpec( string WaveTableName) { VocoderSpecRec VocSpec = new VocoderSpecRec(); VocSpec.WaveTableName = WaveTableName; VocSpec.IndexEnvelope = NewEnvelope(); VocSpec.OutputGainEnvelope = NewEnvelope(); VocSpec.IndexLFO = NewLFOListSpecifier(); VocSpec.OutputGainLFO = NewLFOListSpecifier(); //InitializeAccentZero(out VocSpec.WaveTableIndexAccent); //InitializeAccentZero(out VocSpec.OutputGainAccent); VocSpec.WaveTableIndex = 0; VocSpec.OutputGain = 1; //VocSpec.MaxBandCount = 0; VocSpec.FilterOrder = 2; //VocSpec.WaveTableIndexFormula = null; //VocSpec.OutputGainFormula = null; VocSpec.EnableCrossWaveTableInterpolation = true; return(VocSpec); }
public static string GetVocoderSpecWaveTableName(VocoderSpecRec VocSpec) { return(VocSpec.WaveTableName); }
public static EnvelopeRec GetVocoderSpecIndexEnvelope(VocoderSpecRec VocSpec) { return(VocSpec.IndexEnvelope); }
public static void VocoderSetEnableCrossWaveTableInterpolation(VocoderSpecRec VocSpec, bool enable) { VocSpec.EnableCrossWaveTableInterpolation = enable; }
public static bool VocoderGetEnableCrossWaveTableInterpolation(VocoderSpecRec VocSpec) { return(VocSpec.EnableCrossWaveTableInterpolation); }
/* get the filter order */ public static int GetVocoderFilterOrder(VocoderSpecRec VocSpec) { return(VocSpec.FilterOrder); }
public static LFOListSpecRec GetVocoderSpecOutputGainLFO(VocoderSpecRec VocSpec) { return(VocSpec.OutputGainLFO); }
public static LFOListSpecRec GetVocoderSpecIndexLFO(VocoderSpecRec VocSpec) { return(VocSpec.IndexLFO); }
public static EnvelopeRec GetVocoderSpecOutputGainEnvelope(VocoderSpecRec VocSpec) { return(VocSpec.OutputGainEnvelope); }
/* create a new oscillator vocoder */ public static VocoderRec NewOscVocoder( VocoderSpecRec Template, ref AccentRec Accents, double HurryUp, double InitialFrequency, double FreqForMultisampling, out int PreOriginTimeOut, PlayTrackInfoRec TrackInfo, SynthParamRec SynthParams) { int OnePreOrigin; /* initialize common portion of structure */ VocoderRec Vocoder = VocoderBuildCommonStructure( Template, SynthParams); Vocoder.Oscillator = new VocOscRec(); /* initialize variant portion */ int MaxPreOrigin = 0; Vocoder.Oscillator.OutputScalingEnvelope = NewEnvelopeStateRecord( GetVocoderSpecOutputGainEnvelope(Template), ref Accents, InitialFrequency, 1, HurryUp, out OnePreOrigin, _PlayTrackParamGetter, TrackInfo, SynthParams); if (OnePreOrigin > MaxPreOrigin) { MaxPreOrigin = OnePreOrigin; } Vocoder.Oscillator.OutputScalingLFO = NewLFOGenerator( GetVocoderSpecOutputGainLFO(Template), out OnePreOrigin, ref Accents, InitialFrequency, HurryUp, 1, 1, FreqForMultisampling, _PlayTrackParamGetter, TrackInfo, SynthParams); if (OnePreOrigin > MaxPreOrigin) { MaxPreOrigin = OnePreOrigin; } Vocoder.Oscillator.WaveTableIndexEnvelope = NewEnvelopeStateRecord( GetVocoderSpecIndexEnvelope(Template), ref Accents, InitialFrequency, 1, HurryUp, out OnePreOrigin, _PlayTrackParamGetter, TrackInfo, SynthParams); if (OnePreOrigin > MaxPreOrigin) { MaxPreOrigin = OnePreOrigin; } Vocoder.Oscillator.WaveTableIndexLFO = NewLFOGenerator( GetVocoderSpecIndexLFO(Template), out OnePreOrigin, ref Accents, InitialFrequency, HurryUp, 1, 1, FreqForMultisampling, _PlayTrackParamGetter, TrackInfo, SynthParams); if (OnePreOrigin > MaxPreOrigin) { MaxPreOrigin = OnePreOrigin; } PreOriginTimeOut = MaxPreOrigin; return(Vocoder); }
/* get the maximum number of bands for the vocoder */ public static int GetVocoderMaxNumBands(VocoderSpecRec VocSpec) { return(VocSpec.MaxBandCount); }