コード例 #1
0
        /* create a new multisampling object based on a list of samples */
        public static MultiSampleRec NewMultiSample(
            SampleSelectorRec Selector,
            WaveSampDictRec Dictionary)
        {
            MultiSampleRec MultiSample = new MultiSampleRec();

            int Count = GetSampleSelectorListLength(Selector);

            MultiSample.SampleInfoArray = new OneSampleRec[Count];

            /* fill in the entries */
            int Index = 0;

            for (int i = 0; i < Count; i += 1)
            {
                OneSampleRec Entry = MultiSample.SampleInfoArray[Index] = new OneSampleRec();

                /* fill in interval for which this sample is valid */
                Entry.MinFrequency = GetSampleListEntryLowFreqBound(Selector, i);
                Entry.MaxFrequency = GetSampleListEntryHighFreqBound(Selector, i);

                /* get name of sample for this interval */
                string SampleName = GetSampleListEntryName(Selector, i);
                /* see if we can get info about this one */
                if (!WaveSampDictGetSampleInfo(
                        Dictionary,
                        SampleName,
                        out Entry.SampleDataReference,
                        out Entry.NumFrames,
                        out Entry.NumChannels,
                        out Entry.Loop1Start,
                        out Entry.Loop1End,
                        out Entry.Loop2Start,
                        out Entry.Loop2End,
                        out Entry.Loop3Start,
                        out Entry.Loop3End,
                        out Entry.Origin,
                        out Entry.NaturalFreq,
                        out Entry.SamplingRate,
                        out Entry.Loop1Bidirectional,
                        out Entry.Loop2Bidirectional,
                        out Entry.Loop3Bidirectional))
                {
                    /* couldn't find that wave table, so just skip it */
                    continue;
                }

                /* this entry is valid */
                Index += 1;
            }

            if (Index < Count)
            {
                Array.Resize(ref MultiSample.SampleInfoArray, Index);
            }

            return(MultiSample);
        }
コード例 #2
0
        /* obtain a data reference & info for a sample.  returns False if there is no */
        /* sample corresponding to the supplied frequency. */
        public static bool GetMultiSampleReference(
            MultiSampleRec MultiSample,
            double FrequencyHertz,
            out float[] DataOut,
            out int NumFramesOut,
            out NumChannelsType NumChannelsOut,
            out int Loop1StartOut,
            out int Loop1EndOut,
            out int Loop2StartOut,
            out int Loop2EndOut,
            out int Loop3StartOut,
            out int Loop3EndOut,
            out int OriginOut,
            out double NaturalFreqOut,
            out int SamplingRateOut,
            out bool Loop1Bidirectional,
            out bool Loop2Bidirectional,
            out bool Loop3Bidirectional)
        {
            for (int i = 0; i < MultiSample.SampleInfoArray.Length; i += 1)
            {
                OneSampleRec Entry = MultiSample.SampleInfoArray[i];

                if ((FrequencyHertz >= Entry.MinFrequency) && (FrequencyHertz < Entry.MaxFrequency))
                {
                    DataOut            = Entry.SampleDataReference;
                    NumFramesOut       = Entry.NumFrames;
                    NumChannelsOut     = Entry.NumChannels;
                    Loop1StartOut      = Entry.Loop1Start;
                    Loop1EndOut        = Entry.Loop1End;
                    Loop2StartOut      = Entry.Loop2Start;
                    Loop2EndOut        = Entry.Loop2End;
                    Loop3StartOut      = Entry.Loop3Start;
                    Loop3EndOut        = Entry.Loop3End;
                    Loop1Bidirectional = Entry.Loop1Bidirectional;
                    Loop2Bidirectional = Entry.Loop2Bidirectional;
                    Loop3Bidirectional = Entry.Loop3Bidirectional;
                    OriginOut          = Entry.Origin;
                    NaturalFreqOut     = Entry.NaturalFreq;
                    SamplingRateOut    = Entry.SamplingRate;
                    return(true);
                }
            }

            DataOut            = null;
            NumFramesOut       = 0;
            NumChannelsOut     = (NumChannelsType)0;
            Loop1StartOut      = 0;
            Loop1EndOut        = 0;
            Loop2StartOut      = 0;
            Loop2EndOut        = 0;
            Loop3StartOut      = 0;
            Loop3EndOut        = 0;
            Loop1Bidirectional = false;
            Loop2Bidirectional = false;
            Loop3Bidirectional = false;
            OriginOut          = 0;
            NaturalFreqOut     = 0;
            SamplingRateOut    = 0;
            return(false);
        }