/* create a new instrument specification record */ public static InstrumentRec NewInstrumentSpecifier() { InstrumentRec Instr = new InstrumentRec(); Instr.OverallLoudness = 1; Instr.FrequencyLFOList = NewLFOListSpecifier(); Instr.OscillatorList = NewOscillatorListSpecifier(); Instr.TrackEffectSpecList = NewEffectSpecList(); Instr.CombinedOscEffectSpecList = NewEffectSpecList(); return(Instr); }
/* make sure all instruments in list refer to existing samples and wave tables */ /* all instruments should be up to date when this is called. */ public static SynthErrorCodes CheckInstrListForUnreferencedSamples( IList <InstrObjectRec> InstrList, CheckUnrefParamRec Param) { for (int Scan = 0; Scan < InstrList.Count; Scan += 1) { InstrObjectRec InstrObject = InstrList[Scan]; InstrumentRec InstrumentDefinition = InstrObject.BuiltInstrument; SynthErrorCodes Error = CheckInstrumentForUnreferencedSamples( InstrumentDefinition, Param); if (Error != SynthErrorCodes.eSynthDone) { Param.ErrorInfo.InstrumentName = InstrObject.Name; return(Error); } } return(SynthErrorCodes.eSynthDone); }
/* make sure all referenced samples and wave tables really exist. */ public static SynthErrorCodes CheckInstrumentForUnreferencedSamples( InstrumentRec Instrument, CheckUnrefParamRec Param) { SynthErrorCodes Error; Error = CheckOscillatorListForUnreferencedSamples( GetInstrumentOscillatorList(Instrument), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } Error = CheckLFOListForUnreferencedSamples( GetInstrumentFrequencyLFOList(Instrument), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } Error = CheckEffectListForUnreferencedSamples( GetInstrumentEffectSpecList(Instrument), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } Error = CheckEffectListForUnreferencedSamples( GetInstrumentCombinedOscEffectSpecList(Instrument), Param); if (Error != SynthErrorCodes.eSynthDone) { return(Error); } return(SynthErrorCodes.eSynthDone); }
/* get the combined oscillator effect specifier list */ public static EffectSpecListRec GetInstrumentCombinedOscEffectSpecList(InstrumentRec Instr) { return(Instr.CombinedOscEffectSpecList); }
/* get the track effect specifier list */ public static EffectSpecListRec GetInstrumentEffectSpecList(InstrumentRec Instr) { return(Instr.TrackEffectSpecList); }
/* get the instrument's oscillator list */ public static OscillatorListRec GetInstrumentOscillatorList(InstrumentRec Instr) { return(Instr.OscillatorList); }
/* get the instrument's frequency LFO list */ public static LFOListSpecRec GetInstrumentFrequencyLFOList(InstrumentRec Instr) { return(Instr.FrequencyLFOList); }
/* put a new value for overall loudness */ public static void InstrumentSetOverallLoudness(InstrumentRec Instr, double NewLoudness) { Instr.OverallLoudness = NewLoudness; }
/* get the overall loudness of the instrument */ public static double GetInstrumentOverallLoudness(InstrumentRec Instr) { return(Instr.OverallLoudness); }
/* construct an oscillator bank template record. various parameters are passed in */ /* which are needed for synthesis. ParameterUpdator is the parameter information */ /* record for the whole track of which this is a part. */ public static OscBankTemplateRec NewOscBankTemplate( InstrumentRec InstrumentDefinition, IncrParamUpdateRec ParameterUpdator, SynthParamRec SynthParams) { OscillatorListRec OscillatorListObject; OscBankTemplateRec Template = new OscBankTemplateRec(); /* the oscillator bank template contains all of the information needed for */ /* constructing oscillators as notes are to be executed. */ /* number of oscillators in a bank. */ OscillatorListObject = GetInstrumentOscillatorList(InstrumentDefinition); /* get LFO information */ Template.PitchLFOTemplate = GetInstrumentFrequencyLFOList(InstrumentDefinition); Template.ParamUpdator = ParameterUpdator; Template.InstrOverallLoudness = GetInstrumentOverallLoudness(InstrumentDefinition); Template.CombinedOscillatorEffects = GetInstrumentCombinedOscEffectSpecList(InstrumentDefinition); if (0 == GetEffectSpecListLength(Template.CombinedOscillatorEffects)) { /* if no effects, then set to null, so we don't do any processing */ Template.CombinedOscillatorEffects = null; } /* vector containing templates for all of the oscillators */ Template.NumOscillatorsInBank = GetOscillatorListLength(OscillatorListObject); Template.TemplateArray = new OscBankVectorRec[Template.NumOscillatorsInBank]; /* build entry for each oscillator */ for (int i = 0; i < Template.NumOscillatorsInBank; i++) { OscillatorRec Osc = GetOscillatorFromList(OscillatorListObject, i); OscBankVectorRec Osc1 = Template.TemplateArray[i] = new OscBankVectorRec(); switch (OscillatorGetWhatKindItIs(Osc)) { default: Debug.Assert(false); throw new ArgumentException(); case OscillatorTypes.eOscillatorSampled: Osc1.TemplateReference = SampleTemplateRec.NewSampleTemplate(Osc, SynthParams); break; case OscillatorTypes.eOscillatorWaveTable: Osc1.TemplateReference = WaveTableTemplateRec.NewWaveTableTemplate(Osc, SynthParams); break; case OscillatorTypes.eOscillatorFOF: Osc1.TemplateReference = FOFTemplateRec.NewFOFTemplate(Osc, SynthParams); break; case OscillatorTypes.eOscillatorAlgorithm: Osc1.TemplateReference = AlgorithmicTemplateRec.NewAlgorithmicTemplate(Osc, SynthParams); break; case OscillatorTypes.eOscillatorFMSynth: Osc1.TemplateReference = FMSynthTemplateRec.NewFMSynthTemplate(Osc, SynthParams); break; case OscillatorTypes.eOscillatorPluggable: Osc1.TemplateReference = new PluggableOscillatorTemplate(Osc, SynthParams); break; } } return(Template); }