コード例 #1
0
 /* add a vocoder to the spec list */
 public static void AddVocoderToEffectSpecList(
     EffectSpecListRec EffectSpecList,
     VocoderSpecRec VocSpec,
     bool EnabledFlag)
 {
     AddGenericToEffectSpecList(EffectSpecList, EffectTypes.eVocoderEffect, VocSpec, EnabledFlag);
 }
コード例 #2
0
 public static void PutVocoderSpecOutputGainAccent(
     VocoderSpecRec VocSpec,
     double Value,
     int AccentNum)
 {
     SetAccentMemberValue(ref VocSpec.OutputGainAccent, AccentNum, Value);
 }
コード例 #3
0
 public static void PutVocoderSpecIndexAccent(
     VocoderSpecRec VocSpec,
     double Value,
     int AccentNum)
 {
     SetAccentMemberValue(ref VocSpec.WaveTableIndexAccent, AccentNum, Value);
 }
コード例 #4
0
 public static void GetVocoderSpecOutputGainAgg(
     VocoderSpecRec VocSpec,
     out ScalarParamEvalRec ParamsOut)
 {
     InitScalarParamEval(
         VocSpec.OutputGain,
         ref VocSpec.OutputGainAccent,
         VocSpec.OutputGainFormula,
         out ParamsOut);
 }
コード例 #5
0
 public static void GetVocoderSpecWaveTableIndexAgg(
     VocoderSpecRec VocSpec,
     out ScalarParamEvalRec ParamsOut)
 {
     InitScalarParamEval(
         VocSpec.WaveTableIndex,
         ref VocSpec.WaveTableIndexAccent,
         VocSpec.WaveTableIndexFormula,
         out ParamsOut);
 }
コード例 #6
0
ファイル: Vocoder.cs プロジェクト: programmatom/OutOfPhase
            /* 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);
            }
コード例 #7
0
        /* 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;
        }
コード例 #8
0
        /* 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);
        }
コード例 #9
0
        /* 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;
        }
コード例 #10
0
        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;
        }
コード例 #11
0
        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;
        }
コード例 #12
0
ファイル: Vocoder.cs プロジェクト: programmatom/OutOfPhase
            /* 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);
            }
コード例 #13
0
        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);
        }
コード例 #14
0
 public static string GetVocoderSpecWaveTableName(VocoderSpecRec VocSpec)
 {
     return(VocSpec.WaveTableName);
 }
コード例 #15
0
 public static EnvelopeRec GetVocoderSpecIndexEnvelope(VocoderSpecRec VocSpec)
 {
     return(VocSpec.IndexEnvelope);
 }
コード例 #16
0
 public static void VocoderSetEnableCrossWaveTableInterpolation(VocoderSpecRec VocSpec, bool enable)
 {
     VocSpec.EnableCrossWaveTableInterpolation = enable;
 }
コード例 #17
0
 public static bool VocoderGetEnableCrossWaveTableInterpolation(VocoderSpecRec VocSpec)
 {
     return(VocSpec.EnableCrossWaveTableInterpolation);
 }
コード例 #18
0
 /* get the filter order */
 public static int GetVocoderFilterOrder(VocoderSpecRec VocSpec)
 {
     return(VocSpec.FilterOrder);
 }
コード例 #19
0
 public static LFOListSpecRec GetVocoderSpecOutputGainLFO(VocoderSpecRec VocSpec)
 {
     return(VocSpec.OutputGainLFO);
 }
コード例 #20
0
 public static LFOListSpecRec GetVocoderSpecIndexLFO(VocoderSpecRec VocSpec)
 {
     return(VocSpec.IndexLFO);
 }
コード例 #21
0
 public static EnvelopeRec GetVocoderSpecOutputGainEnvelope(VocoderSpecRec VocSpec)
 {
     return(VocSpec.OutputGainEnvelope);
 }
コード例 #22
0
ファイル: Vocoder.cs プロジェクト: programmatom/OutOfPhase
            /* 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);
            }
コード例 #23
0
 /* get the maximum number of bands for the vocoder */
 public static int GetVocoderMaxNumBands(VocoderSpecRec VocSpec)
 {
     return(VocSpec.MaxBandCount);
 }