/* PlayTrackInfoThang.h */

#ifndef Included_PlayTrackInfoThang_h
#define Included_PlayTrackInfoThang_h

/* PlayTrackInfoThang module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* FixedPoint */
/* BinaryCodedDecimal */
/* Array */
/* Memory */
/* OscBankPlayer */
/* TrackObject */
/* IncrementalParameterUpdator */
/* Fractions */
/* FrameObject */
/* DeterminedNoteStructure */
/* NoteObject */
/* ErrorDaemon */
/* TrackEffectGenerator */
/* InstrumentStructure */

#include "FixedPoint.h"
#include "BinaryCodedDecimal.h"

struct PlayTrackInfoRec;
typedef struct PlayTrackInfoRec PlayTrackInfoRec;

/* this module keeps track of all the information for playing one track. */

/* forwards */
struct TrackObjectRec;
struct InstrumentRec;
struct FractionRec;
struct TempoControlRec;
struct ErrorDaemonRec;
struct MainWindowRec;
struct TrackEffectGenRec;

/* this number is the number of duration update pulses that occur in every whole note. */
#define DURATIONUPDATECLOCKRESOLUTION (64L*2L*3L*5L*7L)

/* dispose of cached track data structures */
void								FlushPlayTrackInfo(void);

/* create a new track play info thing and set a bunch of parameters.  this also */
/* builds the internal representations for instruments & oscillators for this track. */
PlayTrackInfoRec*		NewPlayTrackInfo(struct TrackObjectRec* TheTrack,
											struct InstrumentRec* InstrumentSpecification,
											MyBoolean StereoFlag, LargeBCDType OverallVolumeScalingReciprocal,
											long SamplingRate, float EnvelopeRate, MyBoolean TimeInterp,
											MyBoolean WaveInterp, struct TempoControlRec* TempoControl,
											long ScanningGapWidthInEnvelopeTicks,
											struct ErrorDaemonRec* ErrorDaemon,
											struct MainWindowRec* MainWindow,
											struct TrackEffectGenRec* ScoreEffectGenerator);

/* dump a track play info thing and all the stuff in it */
void								DisposePlayTrackInfo(PlayTrackInfoRec* TrackInfo);

/* cue track forward to the specified point.  returns False if it fails */
MyBoolean						CuePlayTrackInfoToPoint(PlayTrackInfoRec* TrackInfo,
											struct FractionRec* StartTime);

/* check to see if the track has finished and can be dropped. */
MyBoolean						PlayTrackIsItStillActive(PlayTrackInfoRec* TrackInfo);

/* perform one envelope clock cycle update.  if UpdateEnvelopes is true, then */
/* wave data should be generated and envelopes should be updated, otherwise only */
/* note scheduling should be performed. */
MyBoolean						PlayTrackUpdate(PlayTrackInfoRec* TrackInfo,
											MyBoolean UpdateEnvelopes, long NumDurationTicks,
											long NumFrames, largefixedsigned* OutputData,
											float EnvelopeTicksPerDurationTick,
											long ScanningGapFrontInEnvelopeTicks);

#endif
