/* BuildInstrument2.h */

#ifndef Included_BuildInstrument2_h
#define Included_BuildInstrument2_h

/* BuildInstrument2 module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* BuildInstrument */
/* FilterSpec */
/* InstrumentStructure */
/* CompilerScanner */
/* Memory */
/* LFOSpecifier */
/* LFOListSpecifier */
/* OscillatorSpecifier */
/* OscillatorListSpecifier */
/* SampleSelector */
/* DataMunging */
/* AnalyzerSpec */
/* EffectSpecList */
/* DelayEffectSpec */
/* Envelope */
/* WaveTableList */
/* AlgoWaveTableList */
/* NonlinearProcSpec */
/* TrashTracker */
/* FixedPoint */
/* SampleConsts */
/* BuildInstrument3 */


#include "BuildInstrument.h"
#include "FilterSpec.h"


/* token enumeration definitions */
typedef enum
	{
		eKeywordInstrument EXECUTE(= -1274),
		eKeywordLoudness,
		eKeywordFrequencylfo,
		eKeywordOscillator,
		eKeywordFreqenvelope,
		eKeywordModulation,
		eKeywordConstant,
		eKeywordSignsine,
		eKeywordPlussine,
		eKeywordSigntriangle,
		eKeywordPlustriangle,
		eKeywordSignsquare,
		eKeywordPlussquare,
		eKeywordSignramp,
		eKeywordPlusramp,
		eKeywordSignlinfuzz,
		eKeywordPluslinfuzz,
		eKeywordAdditive,
		eKeywordMultiplicative,
		eKeywordInversemult,
		eKeywordType,
		eKeywordSampled,
		eKeywordWavetable,
		eKeywordSamplelist,
		eKeywordFreqmultiplier,
		eKeywordFreqdivisor,
		eKeywordFreqadder,
		eKeywordLoudnessenvelope,
		eKeywordTotalscaling,
		eKeywordExponential,
		eKeywordLinear,
		eKeywordLevel,
		eKeywordDelay,
		eKeywordSustainpoint,
		eKeywordReleasepoint,
		eKeywordSustainpointnoskip,
		eKeywordReleasepointnoskip,
		eKeywordAmpaccent1,
		eKeywordAmpaccent2,
		eKeywordAmpaccent3,
		eKeywordAmpaccent4,
		eKeywordAmpaccent5,
		eKeywordAmpaccent6,
		eKeywordAmpaccent7,
		eKeywordAmpaccent8,
		eKeywordAmpfreq,
		eKeywordRateaccent1,
		eKeywordRateaccent2,
		eKeywordRateaccent3,
		eKeywordRateaccent4,
		eKeywordRateaccent5,
		eKeywordRateaccent6,
		eKeywordRateaccent7,
		eKeywordRateaccent8,
		eKeywordRatefreq,
		eKeywordScale,
		eKeywordAmpenvelope,
		eKeywordLoudnesslfo,
		eKeywordIndexenvelope,
		eKeywordIndexlfo,
		eKeywordPoints,
		eKeywordStereobias,
		eKeywordDisplacement,
		eKeywordSurroundbias,
		eKeywordHertz,
		eKeywordOrigin,
		eKeywordHalfsteps,
		eKeywordSquare,
		eKeywordTriangle,
		eKeywordTrackeffect,
		eKeywordTap,
		eKeywordTo,
		eKeywordSourceaccent1,
		eKeywordSourceaccent2,
		eKeywordSourceaccent3,
		eKeywordSourceaccent4,
		eKeywordTargetaccent1,
		eKeywordTargetaccent2,
		eKeywordTargetaccent3,
		eKeywordTargetaccent4,
		eKeywordScaleaccent1,
		eKeywordScaleaccent2,
		eKeywordScaleaccent3,
		eKeywordScaleaccent4,
		eKeywordLeft,
		eKeywordRight,
		eKeywordMono,
		eKeywordDelayline,
		eKeywordMaxdelaytime,
		eKeywordSlope,
		eKeywordCenter,
		eKeywordEnvelope,
		eKeywordNlproc,
		eKeywordInputscaling,
		eKeywordOutputscaling,
		eKeywordInputaccent1,
		eKeywordInputaccent2,
		eKeywordInputaccent3,
		eKeywordInputaccent4,
		eKeywordOutputaccent1,
		eKeywordOutputaccent2,
		eKeywordOutputaccent3,
		eKeywordOutputaccent4,
		eKeywordWavetableindex,
		eKeywordIndexaccent1,
		eKeywordIndexaccent2,
		eKeywordIndexaccent3,
		eKeywordIndexaccent4,
		eKeywordFilter,
		eKeywordFreq,
		eKeywordBandwidth,
		eKeywordDefaultscaling,
		eKeywordUnitymidbandgain,
		eKeywordUnitynoisegain,
		eKeywordUnityzerohertzgain,
		eKeywordLowpass,
		eKeywordHighpass,
		eKeywordReson,
		eKeywordZero,
		eKeywordButterworthlowpass,
		eKeywordButterworthhighpass,
		eKeywordButterworthbandpass,
		eKeywordButterworthbandreject,
		eKeywordFreqaccent1,
		eKeywordFreqaccent2,
		eKeywordFreqaccent3,
		eKeywordFreqaccent4,
		eKeywordBandwidthaccent1,
		eKeywordBandwidthaccent2,
		eKeywordBandwidthaccent3,
		eKeywordBandwidthaccent4,
		eKeywordNull,
		eKeywordAnalyzer,
		eKeywordScoreeffect,
		eKeywordEffect,
		eKeywordSourceenvelope,
		eKeywordTargetenvelope,
		eKeywordScaleenvelope,
		eKeywordSourcelfo,
		eKeywordTargetlfo,
		eKeywordScalelfo,
		eKeywordInputscalingenvelope,
		eKeywordOutputscalingenvelope,
		eKeywordInputscalinglfo,
		eKeywordOutputscalinglfo,
		eKeywordBandwidthenvelope,
		eKeywordFreqlfo,
		eKeywordBandwidthlfo,
		eKeywordAmplfo,
		eKeywordPitchcontrol,
		eKeywordParameq,
		eKeywordGain,
		eKeywordGainaccent1,
		eKeywordGainaccent2,
		eKeywordGainaccent3,
		eKeywordGainaccent4,
		eKeywordGainenvelope,
		eKeywordGainlfo,
		eKeywordOrder,
		eKeywordResonantlowpass
	} KeywordType;


#define INSTRLIST_ONCEONLY_LOUDNESS (1L << 0)

#define INSTRLIST_REQUIRED_OSCILLATOR (1L << 0)
#define INSTRLIST_REQUIREDMASK (INSTRLIST_REQUIRED_OSCILLATOR)


#define LFODEFINITION_ONCEONLY_FREQENVELOPE (1L << 0)
#define LFODEFINITION_ONCEONLY_AMPENVELOPE (1L << 1)
#define LFODEFINITION_ONCEONLY_OSCILLATORTYPE (1L << 2)
#define LFODEFINITION_ONCEONLY_MODULATIONTYPE (1L << 3)
#define LFODEFINITION_ONCEONLY_ADDINGMODE (1L << 4)

#define LFODEFINITION_REQUIRED_AMPENVELOPE (1L << 0)
#define LFODEFINITION_REQUIREDMASK (LFODEFINITION_REQUIRED_AMPENVELOPE)


#define OSCILLATORDEFINITION_ONCEONLY_TYPE (1L << 0)
#define OSCILLATORDEFINITION_ONCEONLY_SAMPLELIST (1L << 1)
#define OSCILLATORDEFINITION_ONCEONLY_LOUDNESS (1L << 3)
#define OSCILLATORDEFINITION_ONCEONLY_FREQMULTIPLIER (1L << 4)
#define OSCILLATORDEFINITION_ONCEONLY_FREQDIVISOR (1L << 5)
#define OSCILLATORDEFINITION_ONCEONLY_LOUDNESSENVELOPE (1L << 7)
#define OSCILLATORDEFINITION_ONCEONLY_INDEXENVELOPE (1L << 8)
#define OSCILLATORDEFINITION_ONCEONLY_STEREOBIAS (1L << 9)
#define OSCILLATORDEFINITION_ONCEONLY_TIMEDISPLACEMENT (1L << 10)
#define OSCILLATORDEFINITION_ONCEONLY_SURROUNDBIAS (1L << 11)
#define OSCILLATORDEFINITION_ONCEONLY_FREQADDER (1L << 12)

#define OSCILLATORDEFINITION_REQUIRED_TYPE (1L << 0)
#define OSCILLATORDEFINITION_REQUIRED_LOUDNESSENVELOPE (1L << 1)
#define OSCILLATORDEFINITION_REQUIRED_SAMPLELIST (1L << 2)

#define OSCILLATORDEFINITION_REQUIREDMASK (OSCILLATORDEFINITION_REQUIRED_TYPE\
					| OSCILLATORDEFINITION_REQUIRED_LOUDNESSENVELOPE\
					| OSCILLATORDEFINITION_REQUIRED_SAMPLELIST)


#define ENVELOPEDEFINITION_ONCEONLY_TOTALSCALING (1L << 0)
#define ENVELOPEDEFINITION_ONCEONLY_POINTS (1L << 1)
#define ENVELOPEDEFINITION_ONCEONLY_PITCHCONTROL (1L << 2)

#define ENVELOPEDEFINITION_REQUIREDMASK (0L)


#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT1 (1L << 0)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT2 (1L << 1)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT3 (1L << 2)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT4 (1L << 3)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT5 (1L << 4)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT6 (1L << 5)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT7 (1L << 6)
#define ENVPOINTDEFINITION_ONCEONLY_AMPACCENT8 (1L << 7)
#define ENVPOINTDEFINITION_ONCEONLY_AMPFREQ (1L << 8)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT1 (1L << 9)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT2 (1L << 10)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT3 (1L << 11)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT4 (1L << 12)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT5 (1L << 13)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT6 (1L << 14)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT7 (1L << 15)
#define ENVPOINTDEFINITION_ONCEONLY_RATEACCENT8 (1L << 16)
#define ENVPOINTDEFINITION_ONCEONLY_RATEFREQ (1L << 17)
#define ENVPOINTDEFINITION_ONCEONLY_CURVE (1L << 18)


#define DELAYEFFECT_ONCEONLY_MAXDELAYTIME (1L << 0)


#define DELAYEFFECTATTR_ONCEONLY_SOURCEACCENT1 (1L << 0)
#define DELAYEFFECTATTR_ONCEONLY_SOURCEACCENT2 (1L << 1)
#define DELAYEFFECTATTR_ONCEONLY_SOURCEACCENT3 (1L << 2)
#define DELAYEFFECTATTR_ONCEONLY_SOURCEACCENT4 (1L << 3)
#define DELAYEFFECTATTR_ONCEONLY_TARGETACCENT1 (1L << 4)
#define DELAYEFFECTATTR_ONCEONLY_TARGETACCENT2 (1L << 5)
#define DELAYEFFECTATTR_ONCEONLY_TARGETACCENT3 (1L << 6)
#define DELAYEFFECTATTR_ONCEONLY_TARGETACCENT4 (1L << 7)
#define DELAYEFFECTATTR_ONCEONLY_SCALEACCENT1 (1L << 8)
#define DELAYEFFECTATTR_ONCEONLY_SCALEACCENT2 (1L << 9)
#define DELAYEFFECTATTR_ONCEONLY_SCALEACCENT3 (1L << 10)
#define DELAYEFFECTATTR_ONCEONLY_SCALEACCENT4 (1L << 11)
#define DELAYEFFECTATTR_ONCEONLY_LOWPASSCUTOFF (1L << 12)
#define DELAYEFFECTATTR_ONCEONLY_CUTOFFACCENT1 (1L << 13)
#define DELAYEFFECTATTR_ONCEONLY_CUTOFFACCENT2 (1L << 14)
#define DELAYEFFECTATTR_ONCEONLY_CUTOFFACCENT3 (1L << 15)
#define DELAYEFFECTATTR_ONCEONLY_CUTOFFACCENT4 (1L << 16)


#define NLPROCEFFECTATTR_ONCEONLY_INPUTACCENT1 (1L << 0)
#define NLPROCEFFECTATTR_ONCEONLY_INPUTACCENT2 (1L << 1)
#define NLPROCEFFECTATTR_ONCEONLY_INPUTACCENT3 (1L << 2)
#define NLPROCEFFECTATTR_ONCEONLY_INPUTACCENT4 (1L << 3)
#define NLPROCEFFECTATTR_ONCEONLY_OUTPUTACCENT1 (1L << 4)
#define NLPROCEFFECTATTR_ONCEONLY_OUTPUTACCENT2 (1L << 5)
#define NLPROCEFFECTATTR_ONCEONLY_OUTPUTACCENT3 (1L << 6)
#define NLPROCEFFECTATTR_ONCEONLY_OUTPUTACCENT4 (1L << 7)
#define NLPROCEFFECTATTR_ONCEONLY_INDEXACCENT1 (1L << 4)
#define NLPROCEFFECTATTR_ONCEONLY_INDEXACCENT2 (1L << 5)
#define NLPROCEFFECTATTR_ONCEONLY_INDEXACCENT3 (1L << 6)
#define NLPROCEFFECTATTR_ONCEONLY_INDEXACCENT4 (1L << 7)


#define FILTEREFFECTATTR_ONCEONLY_FREQACCENT1 (1L << 0)
#define FILTEREFFECTATTR_ONCEONLY_FREQACCENT2 (1L << 1)
#define FILTEREFFECTATTR_ONCEONLY_FREQACCENT3 (1L << 2)
#define FILTEREFFECTATTR_ONCEONLY_FREQACCENT4 (1L << 3)
#define FILTEREFFECTATTR_ONCEONLY_BANDWIDTHACCENT1 (1L << 4)
#define FILTEREFFECTATTR_ONCEONLY_BANDWIDTHACCENT2 (1L << 5)
#define FILTEREFFECTATTR_ONCEONLY_BANDWIDTHACCENT3 (1L << 6)
#define FILTEREFFECTATTR_ONCEONLY_BANDWIDTHACCENT4 (1L << 7)
#define FILTEREFFECTATTR_ONCEONLY_OUTPUTSCALING (1L << 8)
#define FILTEREFFECTATTR_ONCEONLY_OUTPUTSCALINGACCENT1 (1L << 9)
#define FILTEREFFECTATTR_ONCEONLY_OUTPUTSCALINGACCENT2 (1L << 10)
#define FILTEREFFECTATTR_ONCEONLY_OUTPUTSCALINGACCENT3 (1L << 11)
#define FILTEREFFECTATTR_ONCEONLY_OUTPUTSCALINGACCENT4 (1L << 12)
#define FILTEREFFECTATTR_ONCEONLY_GAINACCENT1 (1L << 13)
#define FILTEREFFECTATTR_ONCEONLY_GAINACCENT2 (1L << 14)
#define FILTEREFFECTATTR_ONCEONLY_GAINACCENT3 (1L << 15)
#define FILTEREFFECTATTR_ONCEONLY_GAINACCENT4 (1L << 16)


/* structure prototypes */
struct InstrumentRec;
struct ScannerRec;
struct LFOSpecRec;
struct OscillatorRec;
struct EnvelopeRec;
struct SampleSelectorRec;
struct EffectSpecListRec;
struct SampleListRec;
struct AlgoSampListRec;
struct WaveTableListRec;
struct AlgoWaveTableListRec;
struct DelayEffectRec;
struct DelayTapRec;
struct NonlinProcSpecRec;
struct FilterSpecRec;
struct OneFilterRec;
struct LFOListSpecRec;


/* parse function prototypes */
BuildInstrErrors						ParseInstrDefinition(struct InstrumentRec* Instrument,
															struct ScannerRec* Scanner, long* ErrorLine,
															struct SampleListRec* SampleList,
															struct AlgoSampListRec* AlgoSampList,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseInstrList(struct InstrumentRec* Instrument,
															struct ScannerRec* Scanner, long* ErrorLine,
															unsigned long* RequiredDefinitions,
															unsigned long OnceOnlyDefinitions,
															struct SampleListRec* SampleList,
															struct AlgoSampListRec* AlgoSampList,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseInstrElem(struct InstrumentRec* Instrument,
															struct ScannerRec* Scanner, long* ErrorLine,
															unsigned long* RequiredDefinitions,
															unsigned long* OnceOnlyDefinitions,
															struct SampleListRec* SampleList,
															struct AlgoSampListRec* AlgoSampList,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseNumber(struct ScannerRec* Scanner, long* ErrorLine,
															double* NumberOut);
BuildInstrErrors						ParseLfoDefinition(struct LFOSpecRec* LFO, struct ScannerRec* Scanner,
															long* ErrorLine, unsigned long* RequiredDefinitions,
															unsigned long OnceOnlyDefinitions,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseIdentifier(struct ScannerRec* Scanner, long* ErrorLine,
															char** IdentifierOut);
BuildInstrErrors						ParseOscillatorDefinition(struct OscillatorRec* Oscillator,
															struct ScannerRec* Scanner, long* ErrorLine,
															unsigned long* RequiredDefinitions,
															unsigned long OnceOnlyDefinitions,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseLfoElem(struct LFOSpecRec* LFO, struct ScannerRec* Scanner,
															long* ErrorLine, unsigned long* RequiredDefinitions,
															unsigned long* OnceOnlyDefinitions,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseOscillatorElem(struct OscillatorRec* Oscillator,
															struct ScannerRec* Scanner, long* ErrorLine,
															unsigned long* RequiredDefinitions,
															unsigned long* OnceOnlyDefinitions,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseEnvelopeDefinition(struct EnvelopeRec* Envelope,
															struct ScannerRec* Scanner, long* ErrorLine,
															unsigned long* RequiredDefinitions,
															unsigned long OnceOnlyDefinitions);
BuildInstrErrors						ParseSamplelistDefinition(struct SampleSelectorRec* SampleList,
															struct ScannerRec* Scanner, long* ErrorLine);
BuildInstrErrors						ParseEnvelopeElem(struct EnvelopeRec* Envelope,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* RequiredDefinitions,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseSamplelistElem(struct SampleSelectorRec* SampleList,
															struct ScannerRec* Scanner, long* ErrorLine);
BuildInstrErrors						ParseEnvPointList(struct EnvelopeRec* Envelope,
															struct ScannerRec* Scanner, long *ErrorLine);
BuildInstrErrors						ParseEnvPointElem(struct EnvelopeRec* Envelope,
															struct ScannerRec* Scanner, long *ErrorLine);
BuildInstrErrors						ParseEnvAttributes(struct EnvelopeRec* Envelope,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long OnceOnly);
BuildInstrErrors						ParseEnvOneAttribute(struct EnvelopeRec* Envelope,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseTrackEffect(struct EffectSpecListRec* EffectList,
															struct ScannerRec* Scanner, long *ErrorLine,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);
BuildInstrErrors						ParseDelayElemList(struct DelayEffectRec* DelayEffect,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseDelayElem(struct DelayEffectRec* DelayEffect,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseTapAttributes(struct DelayTapRec* Tap,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseTapAttr(struct DelayTapRec* Tap,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseNLAttributes(struct NonlinProcSpecRec* NLProcSpec,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions);
BuildInstrErrors						ParseFilterList(struct FilterSpecRec* FilterSpec,
															struct ScannerRec* Scanner, long *ErrorLine);
BuildInstrErrors						ParseFilter(struct FilterSpecRec* FilterSpec,
															struct ScannerRec* Scanner, long *ErrorLine);
BuildInstrErrors						ParseFilterAttributes(struct OneFilterRec* FilterElement,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions,
															FilterTypes FilterType);
BuildInstrErrors						ParseFilterAttr(struct OneFilterRec* FilterElement,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions,
															FilterTypes FilterType);
BuildInstrErrors						ParseOscDelayElems(struct DelayEffectRec* DelayEffect,
															struct ScannerRec* Scanner, long *ErrorLine,
															unsigned long* OnceOnlyDefinitions,
															struct WaveTableListRec* WaveTableList,
															struct AlgoWaveTableListRec* AlgoWaveTableList);

#endif
