/* 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); }
/* create a new sample selector record */ public static SampleSelectorRec NewSampleSelectorList(double LowestBound) { SampleSelectorRec SampList = new SampleSelectorRec(); SampList.List = new OneSampRec[0]; /* set the starting threshhold */ SampList.CurrentLowerBound = LowestBound; return(SampList); }
/* create a new multisampling object based on a list of wave tables */ public static MultiWaveTableRec NewMultiWaveTable( SampleSelectorRec Selector, WaveSampDictRec Dictionary) { MultiWaveTableRec MultiWaveTable = new MultiWaveTableRec(); int Count = GetSampleSelectorListLength(Selector); MultiWaveTable.WaveTableInfoArray = new OneWaveTableRec[Count]; int Index = 0; for (int i = 0; i < Count; i += 1) { OneWaveTableRec Entry = MultiWaveTable.WaveTableInfoArray[Index] = new OneWaveTableRec(); /* get interval for which this one is valid */ Entry.MinFrequency = GetSampleListEntryLowFreqBound(Selector, i); Entry.MaxFrequency = GetSampleListEntryHighFreqBound(Selector, i); /* get name of wave table for this interval */ string WaveTableName = GetSampleListEntryName(Selector, i); /* see if we can get info about this one */ if (!WaveSampDictGetWaveTableInfo( Dictionary, WaveTableName, out Entry.WaveTableMatrix, out Entry.FramesPerTable, out Entry.NumberOfTables)) { /* couldn't find that wave table, so just skip it */ continue; } /* this entry is valid */ Index += 1; } if (Index < Count) { Array.Resize(ref MultiWaveTable.WaveTableInfoArray, Index); } return(MultiWaveTable); }
/* check wave table selector */ public static SynthErrorCodes CheckWaveTableSelectorForUnreferencedSamples( SampleSelectorRec WaveTableSelector, CheckUnrefParamRec Param) { int Limit = GetSampleSelectorListLength(WaveTableSelector); for (int Scan = 0; Scan < Limit; Scan += 1) { string Name = GetSampleListEntryName(WaveTableSelector, Scan); if (!WaveSampDictDoesWaveTableExist( Param.Dictionary, Name)) { Param.ErrorInfo.ErrorEx = SynthErrorSubCodes.eSynthErrorExUndefinedWaveTable; Param.ErrorInfo.WaveTableName = Name; return(SynthErrorCodes.eSynthErrorEx); } } return(SynthErrorCodes.eSynthDone); }
/* add a new sample thing, with it's upper bound. the Name heap block is deleted */ public static void AppendSampleSelector( SampleSelectorRec SampList, double UpperBound, string Name) { /* constrain interval */ if (UpperBound < SampList.CurrentLowerBound) { UpperBound = SampList.CurrentLowerBound; } OneSampRec NewRec = new OneSampRec(); NewRec.LowerBound = SampList.CurrentLowerBound; NewRec.UpperBound = UpperBound; NewRec.Name = Name; /* update our idea of lower bound */ SampList.CurrentLowerBound = UpperBound; Array.Resize(ref SampList.List, SampList.List.Length + 1); SampList.List[SampList.List.Length - 1] = NewRec; }
/* return the low bound frequency of a particular list entry */ public static double GetSampleListEntryLowFreqBound( SampleSelectorRec SampList, int Index) { return(SampList.List[Index].LowerBound); }
/* get the number of sample ranges specified in the list */ public static int GetSampleSelectorListLength(SampleSelectorRec SampList) { return(SampList.List.Length); }
/* get the actual ptr to the heap block containing non-null-terminated sample name */ public static string GetSampleListEntryName( SampleSelectorRec SampList, int Index) { return(SampList.List[Index].Name); }