/* TrackObject.h */

#ifndef Included_TrackObject_h
#define Included_TrackObject_h

/* TrackObject module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* TrackWindow */
/* TrackList */
/* Memory */
/* DataMunging */
/* Array */
/* FrameObject */
/* Screen */
/* TrackView */
/* NoteObject */
/* Menus */
/* MainWindowStuff */
/* BufferedFileInput */
/* BufferedFileOutput */
/* BinaryCodedDecimal */
/* LoadSaveNoteVectors */

#include "MainWindowStuff.h"

struct TrackObjectRec;
typedef struct TrackObjectRec TrackObjectRec;

/* forward declarations */
struct CodeCenterRec;
struct MainWindowRec;
struct TrackListRec;
struct FrameObjectRec;
struct ArrayRec;
struct TrackViewRec;
struct MenuItemType;
struct NoteObjectRec;
struct BufferedInputRec;
struct BufferedOutputRec;

/* create a new empty track object */
TrackObjectRec*				NewTrackObject(struct CodeCenterRec* CodeCenter,
												struct MainWindowRec* MainWindow, struct TrackListRec* TrackList);

/* dispose of track object and all the crud it contains */
void									DisposeTrackObject(TrackObjectRec* TrackObj);

/* find out if the object has been changed */
MyBoolean							HasTrackObjectBeenModified(TrackObjectRec* TrackObj);

/* get a copy of the object's name */
char*									TrackObjectGetNameCopy(TrackObjectRec* TrackObj);

/* put a new name.  the object becomes the owner of the name block, so the */
/* caller should not release it */
void									TrackObjectPutName(TrackObjectRec* TrackObj, char* Name);

/* get a copy of the name of the instrument that the track will be played with */
char*									TrackObjectGetInstrName(TrackObjectRec* TrackObj);

/* change the name of the instrument that the track will be played with.  the */
/* track object will become the owner of the block of memory. */
void									TrackObjectPutNewInstrName(TrackObjectRec* TrackObj, char* Name);

/* get a copy of the postprocessing formula */
char*									TrackObjectGetPostProcessing(TrackObjectRec* TrackObj);

/* change the postprocessing formula.  the object becomes owner of the memory block. */
void									TrackObjectPutNewPostProcessing(TrackObjectRec* TrackObj,
												char* PostProcExpr);

/* get number of frames in track */
long									TrackObjectGetNumFrames(TrackObjectRec* TrackObj);

/* get the frame for a given track index */
struct FrameObjectRec*	TrackObjectGetFrame(TrackObjectRec* TrackObj, long Index);

/* delete a range of frames from the track. */
void									TrackObjectDeleteFrameRun(TrackObjectRec* TrackObj,
												long Index, long Count);

/* get a list of frames and copy them out of the track */
struct ArrayRec*			TrackObjectCopyFrameRun(TrackObjectRec* TrackObj,
												long Index, long Count);

/* find any notes that are referencing the specified note via a tie and nullify the tie. */
void									TrackObjectNullifyTies(TrackObjectRec* TrackObj,
												struct NoteObjectRec* NoteThatIsDying);

/* insert a frame at the specified position */
MyBoolean							TrackObjectInsertFrame(TrackObjectRec* TrackObj, long Index,
												struct FrameObjectRec* NewFrame);

/* show the window for this object.  returns True if successful */
MyBoolean							TrackObjectOpenWindow(TrackObjectRec* TrackObj);

/* notify the object that it's window is closing.  the object should take no action */
void									TrackObjectClosingWindowNotify(TrackObjectRec* TrackObj,
												short NewX, short NewY, short NewWidth, short NewHeight);

/* indicate that the track has been altered starting at a certain position */
/* this sends a message to all track views that have been registered. */
void									TrackObjectAltered(TrackObjectRec* TrackObj, long Index);

/* add a track view object to the list of things that want to be notified when */
/* data in this track is altered */
MyBoolean							TrackObjectAddDependentView(TrackObjectRec* TrackObj,
												struct TrackViewRec* TheView);

/* remove a track view object that no longer wants to be notified upon changes */
void									TrackObjectRemoveDependentView(TrackObjectRec* TrackObj,
												struct TrackViewRec* TheView);

/* add a track view that wants to be seen in the background of this one. */
/* this doesn't actually do too much, since we only keep the list, we don't */
/* do any of the stuff required to actually show it in the background. */
MyBoolean							TrackObjectAddBackgroundObj(TrackObjectRec* TrackObj,
												TrackObjectRec* OtherTrackObj);

/* remove a track view that no longer wants to be seen in the background of this one */
/* the list should call this on everyone when one is deleted so that there aren't */
/* any dangling dependencies left around.  it is not an error to delete something */
/* that isn't in the list */
/* this doesn't actually do too much, since we only keep the list, we don't */
/* do any of the stuff required to actually show it in the background. */
void									TrackObjectRemoveBackgroundObj(TrackObjectRec* TrackObj,
												TrackObjectRec* OtherTrackObj);

/* get background object list.  (Actual thing). List of TrackObjectRec*'s */
struct ArrayRec*			TrackObjectGetBackgroundList(TrackObjectRec* TrackObj);

/* get the menu item associated with this track */
struct MenuItemType*	TrackObjectGetMenuItem(TrackObjectRec* TrackObj);

/* the document's name changed, so we need to update the window */
void									TrackObjectGlobalNameChange(TrackObjectRec* TrackObj,
												char* NewFilename);


/* get the default early/late hit adjustment factor */
double								TrackObjectGetEarlyLateAdjust(TrackObjectRec* TrackObj);

/* get the default first release point */
double								TrackObjectGetReleasePoint1(TrackObjectRec* TrackObj);

/* get the default first release point's from start or end flag (this is the same */
/* as the mask used in each note) */
unsigned long					TrackObjectGetReleasePoint1StartEndFlag(TrackObjectRec* TrackObj);

/* get the default second release point */
double								TrackObjectGetReleasePoint2(TrackObjectRec* TrackObj);

/* get the default second release point's from start or end flag */
unsigned long					TrackObjectGetReleasePoint2StartEndFlag(TrackObjectRec* TrackObj);

/* get the default overall loudness adjustment factor */
double								TrackObjectGetOverallLoudness(TrackObjectRec* TrackObj);

/* get the default stereo positioning */
double								TrackObjectGetStereoPositioning(TrackObjectRec* TrackObj);

/* get the default surround positioning */
double								TrackObjectGetSurroundPositioning(TrackObjectRec* TrackObj);

/* get the default first accent adjust */
double								TrackObjectGetAccent1(TrackObjectRec* TrackObj);

/* get the default second accent adjust */
double								TrackObjectGetAccent2(TrackObjectRec* TrackObj);

/* get the default third accent adjust */
double								TrackObjectGetAccent3(TrackObjectRec* TrackObj);

/* get the default fourth accent adjust */
double								TrackObjectGetAccent4(TrackObjectRec* TrackObj);

/* get the default pitch displacement depth adjust */
double								TrackObjectGetPitchDisplacementDepthAdjust(TrackObjectRec* TrackObj);

/* get the default pitch displacement rate adjust */
double								TrackObjectGetPitchDisplacementRateAdjust(TrackObjectRec* TrackObj);

/* get the default pitch displacement start point */
double								TrackObjectGetPitchDisplacementStartPoint(TrackObjectRec* TrackObj);

/* get the default pitch displacement start point control flag */
unsigned long					TrackObjectGetPitchDisplacementFromStartOrEnd(
												TrackObjectRec* TrackObj);

/* get the default hurry-up factor */
double								TrackObjectGetHurryUp(TrackObjectRec* TrackObj);

/* get the default detuning */
double								TrackObjectGetDetune(TrackObjectRec* TrackObj);

/* get the detuning control flag */
unsigned long					TrackObjectGetDetuneControlFlag(TrackObjectRec* TrackObj);

/* get the default duration adjustment */
double								TrackObjectGetDurationAdjust(TrackObjectRec* TrackObj);

/* get the default duration adjust mode flag */
unsigned long					TrackObjectGetDurationModeFlag(TrackObjectRec* TrackObj);


/* change the default early/late hit adjustment factor */
void									PutTrackObjectEarlyLateAdjust(TrackObjectRec* TrackObj,
												double NewEarlyLateAdjust);

/* change the default first release point */
void									PutTrackObjectReleasePoint1(TrackObjectRec* TrackObj,
												double NewReleasePoint1);

/* change the default first release point's from start or end flag */
void									PutTrackObjectReleasePoint1StartEndFlag(TrackObjectRec* TrackObj,
												unsigned long NewReleasePoint1Flag);

/* change the default second release point */
void									PutTrackObjectReleasePoint2(TrackObjectRec* TrackObj,
												double NewReleasePoint2);

/* change the default second release point's from start or end flag */
void									PutTrackObjectReleasePoint2StartEndFlag(TrackObjectRec* TrackObj,
												unsigned long NewReleasePoint2Flag);

/* change the default overall loudness adjustment factor */
void									PutTrackObjectOverallLoudness(TrackObjectRec* TrackObj,
												double NewOverallLoudness);

/* change the default stereo positioning value */
void									PutTrackObjectStereoPositioning(TrackObjectRec* TrackObj,
												double NewStereoPositioning);

/* change the default surround positioning value */
void									PutTrackObjectSurroundPositioning(TrackObjectRec* TrackObj,
												double NewSurroundPositioning);

/* change the default first accent adjust */
void									PutTrackObjectAccent1(TrackObjectRec* TrackObj,
												double NewAccent1);

/* change the default second accent adjust */
void									PutTrackObjectAccent2(TrackObjectRec* TrackObj,
												double NewAccent2);

/* change the default third accent adjust */
void									PutTrackObjectAccent3(TrackObjectRec* TrackObj,
												double NewAccent3);

/* change the default fourth accent adjust */
void									PutTrackObjectAccent4(TrackObjectRec* TrackObj,
												double NewAccent4);

/* change the default pitch displacement depth adjust */
void									PutTrackObjectPitchDisplacementDepthAdjust(TrackObjectRec* TrackObj,
												double NewPitchDisplacementDepthAdjust);

/* change the default pitch displacement rate adjust */
void									PutTrackObjectPitchDisplacementRateAdjust(TrackObjectRec* TrackObj,
												double NewPitchDisplacementRate);

/* change the default pitch displacement start point */
void									PutTrackObjectPitchDisplacementStartPoint(TrackObjectRec* TrackObj,
												double NewPitchDisplacementStartPoint);

/* change the default pitch displacement start point control flag */
void									PutTrackObjectPitchDisplacementFromStartOrEnd(TrackObjectRec*
												TrackObj, unsigned long NewPitchDisplacementStartPointControl);

/* change the default hurry-up factor */
void									PutTrackObjectHurryUp(TrackObjectRec* TrackObj, double NewHurryUp);

/* change the default detuning */
void									PutTrackObjectDetune(TrackObjectRec* TrackObj, double NewDetune);

/* change the detuning control flag */
void									PutTrackObjectDetuneControlFlag(TrackObjectRec* TrackObj,
												unsigned long NewDetuneControlFlag);

/* change the default duration adjustment */
void									PutTrackObjectDurationAdjust(TrackObjectRec* TrackObj,
												double NewDurationAdjust);

/* change the default duration adjust mode flag */
void									PutTrackObjectDurationModeFlag(TrackObjectRec* TrackObj,
												unsigned long NewDurationModeFlag);

/* find out if this track should be included when we play the score */
MyBoolean							TrackObjectShouldItBePlayed(TrackObjectRec* TrackObj);

/* chage status of whether track should be played */
void									ChangeTrackObjectShouldBePlayed(TrackObjectRec* TrackObj,
												MyBoolean ShouldWePlayIt);

/* read track information from the file and create a new track object */
FileLoadingErrors			TrackObjectNewFromFile(TrackObjectRec** ObjectOut,
												struct BufferedInputRec* Input, struct CodeCenterRec* CodeCenter,
												struct MainWindowRec* MainWindow, struct TrackListRec* TrackList);

/* write the track information to the file. */
FileLoadingErrors			TrackObjectWriteDataOut(TrackObjectRec* TrackObj,
												struct BufferedOutputRec* Output);

/* mark track object as saved */
void									TrackObjectMarkAsSaved(TrackObjectRec* TrackObj);

/* make the track object write out the note array to the file */
MyBoolean							TrackObjectWriteNotesOutToFile(TrackObjectRec* TrackObj,
												struct BufferedOutputRec* Output);

/* load notes from the file & replace track's notes with them */
MyBoolean							TrackObjectRecoverNotesFromFile(TrackObjectRec* TrackObj,
												struct BufferedInputRec* Input);

#endif
