/* TrackAttributeDialog.c */
/*****************************************************************************/
/*                                                                           */
/*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
/*    Copyright (C) 1994  Thomas R. Lawrence                                 */
/*                                                                           */
/*    This program is free software; you can redistribute it and/or modify   */
/*    it under the terms of the GNU General Public License as published by   */
/*    the Free Software Foundation; either version 2 of the License, or      */
/*    (at your option) any later version.                                    */
/*                                                                           */
/*    This program is distributed in the hope that it will be useful,        */
/*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
/*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
/*    GNU General Public License for more details.                           */
/*                                                                           */
/*    You should have received a copy of the GNU General Public License      */
/*    along with this program; if not, write to the Free Software            */
/*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
/*                                                                           */
/*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
/*                                                                           */
/*****************************************************************************/

#include "MiscInfo.h"
#include "Audit.h"
#include "Debug.h"
#include "Definitions.h"

#include "TrackAttributeDialog.h"
#include "Screen.h"
#include "Memory.h"
#include "Alert.h"
#include "TextEdit.h"
#include "SimpleButton.h"
#include "TrackObject.h"
#include "Main.h"
#include "WrapTextBox.h"
#include "Numbers.h"
#include "RadioButton.h"
#include "NoteObject.h"


#define WINXSIZE (490)

#define INDENTVALUE (90)

#define DESCRIPTIONX (10)
#define DESCRIPTIONY (6)
#define DESCRIPTIONWIDTH (WINXSIZE - DESCRIPTIONX - DESCRIPTIONX)
#define DESCRIPTIONHEIGHT (15)

#define NAMEPROMPTX (10)
#define NAMEPROMPTY (DESCRIPTIONY + DESCRIPTIONHEIGHT + 10)

#define NAMEEDITX (NAMEPROMPTX + INDENTVALUE)
#define NAMEEDITY (NAMEPROMPTY - 3)
#define NAMEEDITWIDTH (160)
#define NAMEEDITHEIGHT (19)

#define INSTRPROMPTX (NAMEPROMPTX)
#define INSTRPROMPTY (NAMEPROMPTY + NAMEEDITHEIGHT + 3)

#define INSTREDITX (INSTRPROMPTX + INDENTVALUE)
#define INSTREDITY (INSTRPROMPTY - 3)
#define INSTREDITWIDTH (NAMEEDITWIDTH)
#define INSTREDITHEIGHT (NAMEEDITHEIGHT)

#define EARLYLATEADJUSTPROMPTX (10)
#define EARLYLATEADJUSTPROMPTY (INSTRPROMPTY + INSTREDITHEIGHT + 3 + 5)

#define EARLYLATEADJUSTEDITX (EARLYLATEADJUSTPROMPTX + INDENTVALUE)
#define EARLYLATEADJUSTEDITY (EARLYLATEADJUSTPROMPTY - 3)
#define EARLYLATEADJUSTEDITWIDTH (80)
#define EARLYLATEADJUSTEDITHEIGHT (NAMEEDITHEIGHT)

#define RELEASEPOINT1PROMPTX (EARLYLATEADJUSTEDITX + EARLYLATEADJUSTEDITWIDTH + 10)
#define RELEASEPOINT1PROMPTY (EARLYLATEADJUSTPROMPTY)

#define RELEASEPOINT1EDITX (RELEASEPOINT1PROMPTX + INDENTVALUE)
#define RELEASEPOINT1EDITY (EARLYLATEADJUSTEDITY)
#define RELEASEPOINT1WIDTH (EARLYLATEADJUSTEDITWIDTH)
#define RELEASEPOINT1HEIGHT (NAMEEDITHEIGHT)

#define RELEASEPOINT1STARTBUTTONX (RELEASEPOINT1EDITX + RELEASEPOINT1WIDTH + 5)
#define RELEASEPOINT1STARTBUTTONY (RELEASEPOINT1EDITY)
#define RELEASEPOINT1STARTBUTTONWIDTH (50)
#define RELEASEPOINT1STARTBUTTONHEIGHT (NAMEEDITHEIGHT)

#define RELEASEPOINT1ENDBUTTONX (RELEASEPOINT1STARTBUTTONX\
					+ RELEASEPOINT1STARTBUTTONWIDTH + 5)
#define RELEASEPOINT1ENDBUTTONY (RELEASEPOINT1STARTBUTTONY)
#define RELEASEPOINT1ENDBUTTONWIDTH (RELEASEPOINT1STARTBUTTONWIDTH)
#define RELEASEPOINT1ENDBUTTONHEIGHT (RELEASEPOINT1STARTBUTTONHEIGHT)

#define LOUDNESSPROMPTX (EARLYLATEADJUSTPROMPTX)
#define LOUDNESSPROMPTY (EARLYLATEADJUSTPROMPTY + EARLYLATEADJUSTEDITHEIGHT - 1)

#define LOUDNESSEDITX (LOUDNESSPROMPTX + INDENTVALUE)
#define LOUDNESSEDITY (LOUDNESSPROMPTY - 3)
#define LOUDNESSEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define LOUDNESSEDITHEIGHT (NAMEEDITHEIGHT)

#define RELEASEPOINT2PROMPTX (LOUDNESSEDITX + LOUDNESSEDITWIDTH + 10)
#define RELEASEPOINT2PROMPTY (LOUDNESSPROMPTY)

#define RELEASEPOINT2EDITX (RELEASEPOINT2PROMPTX + INDENTVALUE)
#define RELEASEPOINT2EDITY (LOUDNESSEDITY)
#define RELEASEPOINT2EDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define RELEASEPOINT2EDITHEIGHT (NAMEEDITHEIGHT)

#define RELEASEPOINT2STARTBUTTONX (RELEASEPOINT2EDITX + RELEASEPOINT2EDITWIDTH + 5)
#define RELEASEPOINT2STARTBUTTONY (RELEASEPOINT2EDITY)
#define RELEASEPOINT2STARTBUTTONWIDTH (RELEASEPOINT1STARTBUTTONWIDTH)
#define RELEASEPOINT2STARTBUTTONHEIGHT (NAMEEDITHEIGHT)

#define RELEASEPOINT2ENDBUTTONX (RELEASEPOINT2STARTBUTTONX\
					+ RELEASEPOINT2STARTBUTTONWIDTH + 5)
#define RELEASEPOINT2ENDBUTTONY (RELEASEPOINT2STARTBUTTONY)
#define RELEASEPOINT2ENDBUTTONWIDTH (RELEASEPOINT2STARTBUTTONWIDTH)
#define RELEASEPOINT2ENDBUTTONHEIGHT (RELEASEPOINT2STARTBUTTONHEIGHT)

#define ACCENT1PROMPTX (EARLYLATEADJUSTPROMPTX)
#define ACCENT1PROMPTY (RELEASEPOINT2PROMPTY + RELEASEPOINT2EDITHEIGHT - 1)

#define ACCENT1EDITX (ACCENT1PROMPTX + INDENTVALUE)
#define ACCENT1EDITY (ACCENT1PROMPTY - 3)
#define ACCENT1EDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define ACCENT1EDITHEIGHT (NAMEEDITHEIGHT)

#define ACCENT2PROMPTX (ACCENT1EDITX + ACCENT1EDITWIDTH + 10)
#define ACCENT2PROMPTY (ACCENT1PROMPTY)

#define ACCENT2EDITX (ACCENT2PROMPTX + INDENTVALUE)
#define ACCENT2EDITY (ACCENT1EDITY)
#define ACCENT2EDITWIDTH (ACCENT1EDITWIDTH)
#define ACCENT2EDITHEIGHT (NAMEEDITHEIGHT)

#define ACCENT3PROMPTX (EARLYLATEADJUSTPROMPTX)
#define ACCENT3PROMPTY (ACCENT2PROMPTY + ACCENT2EDITHEIGHT - 1)

#define ACCENT3EDITX (ACCENT3PROMPTX + INDENTVALUE)
#define ACCENT3EDITY (ACCENT3PROMPTY - 3)
#define ACCENT3EDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define ACCENT3EDITHEIGHT (NAMEEDITHEIGHT)

#define ACCENT4PROMPTX (ACCENT3EDITX + ACCENT3EDITWIDTH + 10)
#define ACCENT4PROMPTY (ACCENT3PROMPTY)

#define ACCENT4EDITX (ACCENT4PROMPTX + INDENTVALUE)
#define ACCENT4EDITY (ACCENT4PROMPTY - 3)
#define ACCENT4EDITWIDTH (ACCENT3EDITWIDTH)
#define ACCENT4EDITHEIGHT (NAMEEDITHEIGHT)

#define PITCHDISPRATEPROMPTX (EARLYLATEADJUSTPROMPTX)
#define PITCHDISPRATEPROMPTY (ACCENT4PROMPTY + ACCENT4EDITHEIGHT - 1)

#define PITCHDISPRATEEDITX (PITCHDISPRATEPROMPTX + INDENTVALUE)
#define PITCHDISPRATEEDITY (PITCHDISPRATEPROMPTY - 3)
#define PITCHDISPRATEEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define PITCHDISPRATEEDITHEIGHT (NAMEEDITHEIGHT)

#define PITCHDISPDEPTHPROMPTX (PITCHDISPRATEEDITX + PITCHDISPRATEEDITWIDTH + 10)
#define PITCHDISPDEPTHPROMPTY (PITCHDISPRATEPROMPTY)

#define PITCHDISPDEPTHEDITX (PITCHDISPDEPTHPROMPTX + INDENTVALUE)
#define PITCHDISPDEPTHEDITY (PITCHDISPDEPTHPROMPTY - 3)
#define PITCHDISPDEPTHEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define PITCHDISPDEPTHEDITHEIGHT (NAMEEDITHEIGHT)

#define HURRYUPPROMPTX (EARLYLATEADJUSTPROMPTX)
#define HURRYUPPROMPTY (PITCHDISPDEPTHPROMPTY + PITCHDISPDEPTHEDITHEIGHT - 1)

#define HURRYUPEDITX (HURRYUPPROMPTX + INDENTVALUE)
#define HURRYUPEDITY (HURRYUPPROMPTY - 3)
#define HURRYUPEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define HURRYUPEDITHEIGHT (NAMEEDITHEIGHT)

#define PITCHDISPSTARTPROMPTX (HURRYUPEDITX + HURRYUPEDITWIDTH + 10)
#define PITCHDISPSTARTPROMPTY (HURRYUPPROMPTY)

#define PITCHDISPSTARTEDITX (PITCHDISPSTARTPROMPTX + INDENTVALUE)
#define PITCHDISPSTARTEDITY (PITCHDISPSTARTPROMPTY - 3)
#define PITCHDISPSTARTEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define PITCHDISPSTARTEDITHEIGHT (NAMEEDITHEIGHT)

#define PITCHDISPSTARTSTARTBUTTONX (PITCHDISPSTARTEDITX + PITCHDISPSTARTEDITWIDTH + 5)
#define PITCHDISPSTARTSTARTBUTTONY (PITCHDISPSTARTEDITY)
#define PITCHDISPSTARTSTARTBUTTONWIDTH (RELEASEPOINT1STARTBUTTONWIDTH)
#define PITCHDISPSTARTSTARTBUTTONHEIGHT (PITCHDISPSTARTEDITHEIGHT)

#define PITCHDISPSTARTENDBUTTONX (PITCHDISPSTARTSTARTBUTTONX\
					+ PITCHDISPSTARTSTARTBUTTONWIDTH + 5)
#define PITCHDISPSTARTENDBUTTONY (PITCHDISPSTARTSTARTBUTTONY)
#define PITCHDISPSTARTENDBUTTONWIDTH (PITCHDISPSTARTSTARTBUTTONWIDTH)
#define PITCHDISPSTARTENDBUTTONHEIGHT (PITCHDISPSTARTSTARTBUTTONHEIGHT)

#define STEREOPOSITIONPROMPTX (EARLYLATEADJUSTPROMPTX)
#define STEREOPOSITIONPROMPTY (HURRYUPPROMPTY + HURRYUPEDITHEIGHT - 1)

#define STEREOPOSITIONEDITX (STEREOPOSITIONPROMPTX + INDENTVALUE)
#define STEREOPOSITIONEDITY (STEREOPOSITIONPROMPTY - 3)
#define STEREOPOSITIONEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define STEREOPOSITIONEDITHEIGHT (NAMEEDITHEIGHT)

#define DETUNEPROMPTX (STEREOPOSITIONEDITX + STEREOPOSITIONEDITWIDTH + 10)
#define DETUNEPROMPTY (STEREOPOSITIONPROMPTY)

#define DETUNEEDITX (DETUNEPROMPTX + INDENTVALUE)
#define DETUNEEDITY (DETUNEPROMPTY - 3)
#define DETUNEEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define DETUNEEDITHEIGHT (NAMEEDITHEIGHT)

#define DETUNEHERTZBUTTONX (DETUNEEDITX + DETUNEEDITWIDTH + 5)
#define DETUNEHERTZBUTTONY (DETUNEEDITY)
#define DETUNEHERTZBUTTONWIDTH (RELEASEPOINT1STARTBUTTONWIDTH)
#define DETUNEHERTZBUTTONHEIGHT (DETUNEEDITHEIGHT)

#define DETUNEHALFSTEPBUTTONX (DETUNEHERTZBUTTONX + DETUNEHERTZBUTTONWIDTH + 5)
#define DETUNEHALFSTEPBUTTONY (DETUNEHERTZBUTTONY)
#define DETUNEHALFSTEPBUTTONWIDTH (DETUNEHERTZBUTTONWIDTH + 20)
#define DETUNEHALFSTEPBUTTONHEIGHT (DETUNEHERTZBUTTONHEIGHT)

#define SURROUNDPOSITIONPROMPTX (EARLYLATEADJUSTPROMPTX)
#define SURROUNDPOSITIONPROMPTY (STEREOPOSITIONPROMPTY + NAMEEDITHEIGHT - 1)

#define SURROUNDPOSITIONEDITX (SURROUNDPOSITIONPROMPTX + INDENTVALUE)
#define SURROUNDPOSITIONEDITY (SURROUNDPOSITIONPROMPTY - 3)
#define SURROUNDPOSITIONEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define SURROUNDPOSITIONEDITHEIGHT (NAMEEDITHEIGHT)

#define DURATIONPROMPTX (SURROUNDPOSITIONEDITX + SURROUNDPOSITIONEDITWIDTH + 10)
#define DURATIONPROMPTY (SURROUNDPOSITIONPROMPTY)

#define DURATIONEDITX (DURATIONPROMPTX + INDENTVALUE)
#define DURATIONEDITY (DURATIONPROMPTY - 3)
#define DURATIONEDITWIDTH (EARLYLATEADJUSTEDITWIDTH)
#define DURATIONEDITHEIGHT (NAMEEDITHEIGHT)

#define DURATIONADDBUTTONX (DURATIONEDITX + DURATIONEDITWIDTH + 5)
#define DURATIONADDBUTTONY (DURATIONEDITY)
#define DURATIONADDBUTTONWIDTH (RELEASEPOINT1STARTBUTTONWIDTH)
#define DURATIONADDBUTTONHEIGHT (DURATIONEDITHEIGHT)

#define DURATIONMULTBUTTONX (DURATIONADDBUTTONX + DURATIONADDBUTTONWIDTH + 5)
#define DURATIONMULTBUTTONY (DURATIONADDBUTTONY)
#define DURATIONMULTBUTTONWIDTH (DURATIONADDBUTTONWIDTH)
#define DURATIONMULTBUTTONHEIGHT (DURATIONADDBUTTONHEIGHT)

#define OKBUTTONWIDTH (80)
#define OKBUTTONHEIGHT (21)
#define OKBUTTONY (DURATIONEDITY + DURATIONEDITHEIGHT + 15)
#define OKBUTTONX ((WINXSIZE / 4) - (OKBUTTONWIDTH / 2))

#define CANCELBUTTONWIDTH (OKBUTTONWIDTH)
#define CANCELBUTTONHEIGHT (OKBUTTONHEIGHT)
#define CANCELBUTTONY (OKBUTTONY)
#define CANCELBUTTONX (((3 * WINXSIZE) / 4) - (OKBUTTONWIDTH / 2))

#define WINYSIZE (CANCELBUTTONY + CANCELBUTTONHEIGHT + 10)


typedef struct
	{
		WinType*						ScreenID;
		TextEditRec*				NameEdit;
		TextEditRec*				InstrumentEdit;
		TextEditRec*				EarlyLateAdjustEdit;
		TextEditRec*				ReleasePoint1Edit;
		RadioButtonRec*			ReleasePoint1StartButton;
		RadioButtonRec*			ReleasePoint1EndButton;
		TextEditRec*				LoudnessEdit;
		TextEditRec*				ReleasePoint2Edit;
		RadioButtonRec*			ReleasePoint2StartButton;
		RadioButtonRec*			ReleasePoint2EndButton;
		TextEditRec*				Accent1Edit;
		TextEditRec*				Accent2Edit;
		TextEditRec*				Accent3Edit;
		TextEditRec*				Accent4Edit;
		TextEditRec*				PitchDispRateEdit;
		TextEditRec*				PitchDispDepthEdit;
		TextEditRec*				HurryUpEdit;
		TextEditRec*				PitchDispStartEdit;
		RadioButtonRec*			PitchDispStartStartButton;
		RadioButtonRec*			PitchDispStartEndButton;
		TextEditRec*				StereoPositionEdit;
		TextEditRec*				DetuneEdit;
		RadioButtonRec*			DetuneHertzButton;
		RadioButtonRec*			DetuneHalfStepButton;
		TextEditRec*				SurroundEdit;
		TextEditRec*				DurationEdit;
		RadioButtonRec*			DurationAddButton;
		RadioButtonRec*			DurationMultButton;
		SimpleButtonRec*		OKButton;
		SimpleButtonRec*		CancelButton;
	} WindowRec;


static void					UpdateTheWindow(WindowRec* Window)
	{
		CheckPtrExistence(Window);
		TextEditFullRedraw(Window->NameEdit);
		TextEditFullRedraw(Window->InstrumentEdit);
		TextEditFullRedraw(Window->EarlyLateAdjustEdit);
		TextEditFullRedraw(Window->ReleasePoint1Edit);
		RedrawRadioButton(Window->ReleasePoint1StartButton);
		RedrawRadioButton(Window->ReleasePoint1EndButton);
		TextEditFullRedraw(Window->LoudnessEdit);
		TextEditFullRedraw(Window->ReleasePoint2Edit);
		RedrawRadioButton(Window->ReleasePoint2StartButton);
		RedrawRadioButton(Window->ReleasePoint2EndButton);
		TextEditFullRedraw(Window->Accent1Edit);
		TextEditFullRedraw(Window->Accent2Edit);
		TextEditFullRedraw(Window->Accent3Edit);
		TextEditFullRedraw(Window->Accent4Edit);
		TextEditFullRedraw(Window->PitchDispRateEdit);
		TextEditFullRedraw(Window->PitchDispDepthEdit);
		TextEditFullRedraw(Window->HurryUpEdit);
		TextEditFullRedraw(Window->PitchDispStartEdit);
		RedrawRadioButton(Window->PitchDispStartStartButton);
		RedrawRadioButton(Window->PitchDispStartEndButton);
		TextEditFullRedraw(Window->StereoPositionEdit);
		TextEditFullRedraw(Window->DetuneEdit);
		RedrawRadioButton(Window->DetuneHertzButton);
		RedrawRadioButton(Window->DetuneHalfStepButton);
		TextEditFullRedraw(Window->SurroundEdit);
		TextEditFullRedraw(Window->DurationEdit);
		RedrawRadioButton(Window->DurationAddButton);
		RedrawRadioButton(Window->DurationMultButton);
		RedrawSimpleButton(Window->OKButton);
		RedrawSimpleButton(Window->CancelButton);
		SetClipRect(Window->ScreenID,0,0,WINXSIZE,WINYSIZE);
		DrawWrappedTextBox(Window->ScreenID,"Adjust the track's attributes and defaults:",
			GetScreenFont(),9,DESCRIPTIONX,DESCRIPTIONY,DESCRIPTIONWIDTH,DESCRIPTIONHEIGHT);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Track Name:",11,NAMEPROMPTX,
			NAMEPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Instrument Name:",16,
			INSTRPROMPTX,INSTRPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Hit Time:",9,
			EARLYLATEADJUSTPROMPTX,EARLYLATEADJUSTPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Release 1:",10,
			RELEASEPOINT1PROMPTX,RELEASEPOINT1PROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Loudness:",9,
			LOUDNESSPROMPTX,LOUDNESSPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Release 2:",10,
			RELEASEPOINT2PROMPTX,RELEASEPOINT2PROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Accent 1:",9,
			ACCENT1PROMPTX,ACCENT1PROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Accent 2:",9,
			ACCENT2PROMPTX,ACCENT2PROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Accent 3:",9,
			ACCENT3PROMPTX,ACCENT3PROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Accent 4:",9,
			ACCENT4PROMPTX,ACCENT4PROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Pitch Disp Rate:",16,
			PITCHDISPRATEPROMPTX,PITCHDISPRATEPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Pitch Disp Depth:",17,
			PITCHDISPDEPTHPROMPTX,PITCHDISPDEPTHPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Hurry-Up:",9,
			HURRYUPPROMPTX,HURRYUPPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Pitch Disp Start:",17,
			PITCHDISPSTARTPROMPTX,PITCHDISPSTARTPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Stereo Pos:",11,
			STEREOPOSITIONPROMPTX,STEREOPOSITIONPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Detune:",7,
			DETUNEPROMPTX,DETUNEPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Surround Pos:",13,
			SURROUNDPOSITIONPROMPTX,SURROUNDPOSITIONPROMPTY,ePlain);
		DrawTextLine(Window->ScreenID,GetScreenFont(),9,"Duration Adjust:",16,
			DURATIONPROMPTX,DURATIONPROMPTY,ePlain);
	}


/* this routine asks the user for the instrument name and track name associated */
/* with a track.  It takes the track object as an argument, so it worries about */
/* the updating and cancelling & all that. */
void								TrackAttributeDialog(struct TrackObjectRec* TheTrackThing)
	{
		WindowRec*				Window;
		char*							StringTemp;
		MyBoolean					LoopFlag;
		TextEditRec*			ActiveTextEdit;
		MyBoolean					DoItFlag EXECUTE(= -31342);

		CheckPtrExistence(TheTrackThing);

		Window = (WindowRec*)AllocPtrCanFail(sizeof(WindowRec),"TrackAttributeDialogWindow");
		if (Window == NIL)
			{
			 FailurePoint1:
				AlertHalt("There is not enough memory available to edit the track attributes.",
					NIL);
				return;
			}

		Window->ScreenID = MakeNewWindow(eModelessDialogWindow,eWindowNotClosable,
			eWindowNotZoomable,eWindowNotResizable,DialogLeftEdge(WINXSIZE),
			DialogTopEdge(WINYSIZE),WINXSIZE,WINYSIZE,(void (*)(void*))&UpdateTheWindow,Window);
		if (Window->ScreenID == NIL)
			{
			 FailurePoint2:
				ReleasePtr((char*)Window);
				goto FailurePoint1;
			}
		SetWindowName(Window->ScreenID,"Edit Track Defaults");

		Window->NameEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),9,
			NAMEEDITX,NAMEEDITY,NAMEEDITWIDTH,NAMEEDITHEIGHT);
		if (Window->NameEdit == NIL)
			{
			 FailurePoint3:
				KillWindow(Window->ScreenID);
				goto FailurePoint2;
			}
		StringTemp = TrackObjectGetNameCopy(TheTrackThing);
		if (StringTemp == NIL)
			{
			 FailurePoint4:
				DisposeTextEdit(Window->NameEdit);
				goto FailurePoint3;
			}
		TextEditNewRawData(Window->NameEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->NameEdit);

		Window->InstrumentEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,INSTREDITX,INSTREDITY,INSTREDITWIDTH,INSTREDITHEIGHT);
		if (Window->InstrumentEdit == NIL)
			{
			 FailurePoint5:
				goto FailurePoint4;
			}
		StringTemp = TrackObjectGetInstrName(TheTrackThing);
		if (StringTemp == NIL)
			{
			 FailurePoint6:
				DisposeTextEdit(Window->InstrumentEdit);
				goto FailurePoint5;
			}
		TextEditNewRawData(Window->InstrumentEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->InstrumentEdit);

		Window->OKButton = NewSimpleButton(Window->ScreenID,"OK",OKBUTTONX,OKBUTTONY,
			OKBUTTONWIDTH,OKBUTTONHEIGHT);
		if (Window->OKButton == NIL)
			{
			 FailurePoint7:
				goto FailurePoint6;
			}
		SetDefaultButtonState(Window->OKButton,True);

		Window->CancelButton = NewSimpleButton(Window->ScreenID,"Cancel",CANCELBUTTONX,
			CANCELBUTTONY,CANCELBUTTONWIDTH,CANCELBUTTONHEIGHT);
		if (Window->CancelButton == NIL)
			{
			 FailurePoint8:
				DisposeSimpleButton(Window->OKButton);
				goto FailurePoint7;
			}

		Window->EarlyLateAdjustEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,EARLYLATEADJUSTEDITX,EARLYLATEADJUSTEDITY,
			EARLYLATEADJUSTEDITWIDTH,EARLYLATEADJUSTEDITHEIGHT);
		if (Window->EarlyLateAdjustEdit == NIL)
			{
			 FailurePoint9:
				DisposeSimpleButton(Window->CancelButton);
				goto FailurePoint8;
			}
		StringTemp = LongDoubleToString(TrackObjectGetEarlyLateAdjust(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint10:
				DisposeTextEdit(Window->EarlyLateAdjustEdit);
				goto FailurePoint9;
			}
		TextEditNewRawData(Window->EarlyLateAdjustEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->EarlyLateAdjustEdit);

		Window->ReleasePoint1Edit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,RELEASEPOINT1EDITX,RELEASEPOINT1EDITY,RELEASEPOINT1WIDTH,
			RELEASEPOINT1HEIGHT);
		if (Window->ReleasePoint1Edit == NIL)
			{
			 FailurePoint11:
				goto FailurePoint10;
			}
		StringTemp = LongDoubleToString(TrackObjectGetReleasePoint1(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint12:
				DisposeTextEdit(Window->ReleasePoint1Edit);
				goto FailurePoint11;
			}
		TextEditNewRawData(Window->ReleasePoint1Edit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->ReleasePoint1Edit);

		Window->ReleasePoint1StartButton = NewRadioButton(Window->ScreenID,"Start",
			RELEASEPOINT1STARTBUTTONX,RELEASEPOINT1STARTBUTTONY,RELEASEPOINT1STARTBUTTONWIDTH,
			RELEASEPOINT1STARTBUTTONHEIGHT);
		if (Window->ReleasePoint1StartButton == NIL)
			{
			 FailurePoint13:
				goto FailurePoint12;
			}

		Window->ReleasePoint1EndButton = NewRadioButton(Window->ScreenID,"End",
			RELEASEPOINT1ENDBUTTONX,RELEASEPOINT1ENDBUTTONY,RELEASEPOINT1ENDBUTTONWIDTH,
			RELEASEPOINT1ENDBUTTONHEIGHT);
		if (Window->ReleasePoint1EndButton == NIL)
			{
			 FailurePoint14:
				DisposeRadioButton(Window->ReleasePoint1StartButton);
				goto FailurePoint13;
			}

		switch (TrackObjectGetReleasePoint1StartEndFlag(TheTrackThing))
			{
				default:
					EXECUTE(PRERR(AllowResume,
						"TrackAttributeDialog:  bad release point 1 start/end flag"));
					break;
				case eRelease1FromStart:
					SetRadioButtonState(Window->ReleasePoint1StartButton,True);
					break;
				case eRelease1FromEnd:
					SetRadioButtonState(Window->ReleasePoint1EndButton,True);
					break;
			}

		Window->LoudnessEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,LOUDNESSEDITX,LOUDNESSEDITY,LOUDNESSEDITWIDTH,LOUDNESSEDITHEIGHT);
		if (Window->LoudnessEdit == NIL)
			{
			 FailurePoint15:
				DisposeRadioButton(Window->ReleasePoint1EndButton);
				goto FailurePoint14;
			}
		StringTemp = LongDoubleToString(TrackObjectGetOverallLoudness(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint16:
				DisposeTextEdit(Window->LoudnessEdit);
				goto FailurePoint15;
			}
		TextEditNewRawData(Window->LoudnessEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->LoudnessEdit);

		Window->ReleasePoint2Edit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,RELEASEPOINT2EDITX,RELEASEPOINT2EDITY,RELEASEPOINT2EDITWIDTH,
			RELEASEPOINT2EDITHEIGHT);
		if (Window->ReleasePoint2Edit == NIL)
			{
			 FailurePoint17:
				goto FailurePoint16;
			}
		StringTemp = LongDoubleToString(TrackObjectGetReleasePoint2(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint18:
				DisposeTextEdit(Window->ReleasePoint2Edit);
				goto FailurePoint17;
			}
		TextEditNewRawData(Window->ReleasePoint2Edit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->ReleasePoint2Edit);

		Window->ReleasePoint2StartButton = NewRadioButton(Window->ScreenID,"Start",
			RELEASEPOINT2STARTBUTTONX,RELEASEPOINT2STARTBUTTONY,RELEASEPOINT2STARTBUTTONWIDTH,
			RELEASEPOINT2STARTBUTTONHEIGHT);
		if (Window->ReleasePoint2StartButton == NIL)
			{
			 FailurePoint19:
				goto FailurePoint18;
			}

		Window->ReleasePoint2EndButton = NewRadioButton(Window->ScreenID,"End",
			RELEASEPOINT2ENDBUTTONX,RELEASEPOINT2ENDBUTTONY,RELEASEPOINT2ENDBUTTONWIDTH,
			RELEASEPOINT2ENDBUTTONHEIGHT);
		if (Window->ReleasePoint2EndButton == NIL)
			{
			 FailurePoint20:
				DisposeRadioButton(Window->ReleasePoint2StartButton);
				goto FailurePoint19;
			}

		switch (TrackObjectGetReleasePoint2StartEndFlag(TheTrackThing))
			{
				default:
					EXECUTE(PRERR(AllowResume,
						"TrackAttributeDialog:  bad release point 2 start/end flag"));
					break;
				case eRelease2FromStart:
					SetRadioButtonState(Window->ReleasePoint2StartButton,True);
					break;
				case eRelease2FromEnd:
					SetRadioButtonState(Window->ReleasePoint2EndButton,True);
					break;
			}

		Window->Accent1Edit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,ACCENT1EDITX,ACCENT1EDITY,ACCENT1EDITWIDTH,ACCENT1EDITHEIGHT);
		if (Window->Accent1Edit == NIL)
			{
			 FailurePoint21:
				DisposeRadioButton(Window->ReleasePoint2EndButton);
				goto FailurePoint20;
			}
		StringTemp = LongDoubleToString(TrackObjectGetAccent1(TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint22:
				DisposeTextEdit(Window->Accent1Edit);
				goto FailurePoint21;
			}
		TextEditNewRawData(Window->Accent1Edit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->Accent1Edit);

		Window->Accent2Edit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,ACCENT2EDITX,ACCENT2EDITY,ACCENT2EDITWIDTH,ACCENT2EDITHEIGHT);
		if (Window->Accent2Edit == NIL)
			{
			 FailurePoint23:
				goto FailurePoint22;
			}
		StringTemp = LongDoubleToString(TrackObjectGetAccent2(TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint24:
				DisposeTextEdit(Window->Accent2Edit);
				goto FailurePoint23;
			}
		TextEditNewRawData(Window->Accent2Edit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->Accent2Edit);

		Window->Accent3Edit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,ACCENT3EDITX,ACCENT3EDITY,ACCENT3EDITWIDTH,ACCENT3EDITHEIGHT);
		if (Window->Accent3Edit == NIL)
			{
			 FailurePoint25:
				goto FailurePoint24;
			}
		StringTemp = LongDoubleToString(TrackObjectGetAccent3(TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint26:
				DisposeTextEdit(Window->Accent3Edit);
				goto FailurePoint25;
			}
		TextEditNewRawData(Window->Accent3Edit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->Accent3Edit);

		Window->Accent4Edit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,ACCENT4EDITX,ACCENT4EDITY,ACCENT4EDITWIDTH,ACCENT4EDITHEIGHT);
		if (Window->Accent4Edit == NIL)
			{
			 FailurePoint27:
				goto FailurePoint26;
			}
		StringTemp = LongDoubleToString(TrackObjectGetAccent4(TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint28:
				DisposeTextEdit(Window->Accent4Edit);
				goto FailurePoint27;
			}
		TextEditNewRawData(Window->Accent4Edit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->Accent4Edit);

		Window->PitchDispRateEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,PITCHDISPRATEEDITX,PITCHDISPRATEEDITY,PITCHDISPRATEEDITWIDTH,
			PITCHDISPRATEEDITHEIGHT);
		if (Window->PitchDispRateEdit == NIL)
			{
			 FailurePoint29:
				goto FailurePoint28;
			}
		StringTemp = LongDoubleToString(TrackObjectGetPitchDisplacementRateAdjust(
			TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint30:
				DisposeTextEdit(Window->PitchDispRateEdit);
				goto FailurePoint29;
			}
		TextEditNewRawData(Window->PitchDispRateEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->PitchDispRateEdit);

		Window->PitchDispDepthEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,PITCHDISPDEPTHEDITX,PITCHDISPDEPTHEDITY,PITCHDISPDEPTHEDITWIDTH,
			PITCHDISPDEPTHEDITHEIGHT);
		if (Window->PitchDispDepthEdit == NIL)
			{
			 FailurePoint31:
				goto FailurePoint30;
			}
		StringTemp = LongDoubleToString(TrackObjectGetPitchDisplacementDepthAdjust(
			TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint32:
				DisposeTextEdit(Window->PitchDispDepthEdit);
				goto FailurePoint31;
			}
		TextEditNewRawData(Window->PitchDispDepthEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->PitchDispDepthEdit);

		Window->HurryUpEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,HURRYUPEDITX,HURRYUPEDITY,HURRYUPEDITWIDTH,HURRYUPEDITHEIGHT);
		if (Window->HurryUpEdit == NIL)
			{
			 FailurePoint35:
				goto FailurePoint32;
			}
		StringTemp = LongDoubleToString(TrackObjectGetHurryUp(TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint36:
				DisposeTextEdit(Window->HurryUpEdit);
				goto FailurePoint35;
			}
		TextEditNewRawData(Window->HurryUpEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->HurryUpEdit);

		Window->PitchDispStartEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,PITCHDISPSTARTEDITX,PITCHDISPSTARTEDITY,PITCHDISPSTARTEDITWIDTH,
			PITCHDISPSTARTEDITHEIGHT);
		if (Window->PitchDispStartEdit == NIL)
			{
			 FailurePoint37:
				goto FailurePoint36;
			}
		StringTemp = LongDoubleToString(TrackObjectGetPitchDisplacementStartPoint(
			TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint38:
				DisposeTextEdit(Window->PitchDispStartEdit);
				goto FailurePoint37;
			}
		TextEditNewRawData(Window->PitchDispStartEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->PitchDispStartEdit);

		Window->PitchDispStartStartButton = NewRadioButton(Window->ScreenID,"Start",
			PITCHDISPSTARTSTARTBUTTONX,PITCHDISPSTARTSTARTBUTTONY,
			PITCHDISPSTARTSTARTBUTTONWIDTH,PITCHDISPSTARTSTARTBUTTONHEIGHT);
		if (Window->PitchDispStartStartButton == NIL)
			{
			 FailurePoint39:
				goto FailurePoint38;
			}

		Window->PitchDispStartEndButton = NewRadioButton(Window->ScreenID,"End",
			PITCHDISPSTARTENDBUTTONX,PITCHDISPSTARTENDBUTTONY,PITCHDISPSTARTENDBUTTONWIDTH,
			PITCHDISPSTARTENDBUTTONHEIGHT);
		if (Window->PitchDispStartEndButton == NIL)
			{
			 FailurePoint40:
				DisposeRadioButton(Window->PitchDispStartStartButton);
				goto FailurePoint39;
			}

		switch (TrackObjectGetPitchDisplacementFromStartOrEnd(TheTrackThing))
			{
				default:
					EXECUTE(PRERR(AllowResume,
						"TrackAttributeDialog:  bad pitch displacement start/end flag"));
					break;
				case ePitchDisplacementStartFromStart:
					SetRadioButtonState(Window->PitchDispStartStartButton,True);
					break;
				case ePitchDisplacementStartFromEnd:
					SetRadioButtonState(Window->PitchDispStartEndButton,True);
					break;
			}

		Window->DetuneEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,DETUNEEDITX,DETUNEEDITY,DETUNEEDITWIDTH,DETUNEEDITHEIGHT);
		if (Window->DetuneEdit == NIL)
			{
			 FailurePoint41:
				DisposeRadioButton(Window->PitchDispStartEndButton);
				goto FailurePoint40;
			}
		StringTemp = LongDoubleToString(TrackObjectGetDetune(TheTrackThing),7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint42:
				DisposeTextEdit(Window->DetuneEdit);
				goto FailurePoint41;
			}
		TextEditNewRawData(Window->DetuneEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->DetuneEdit);

		Window->DetuneHertzButton = NewRadioButton(Window->ScreenID,"Hertz",
			DETUNEHERTZBUTTONX,DETUNEHERTZBUTTONY,DETUNEHERTZBUTTONWIDTH,
			DETUNEHERTZBUTTONHEIGHT);
		if (Window->DetuneHertzButton == NIL)
			{
			 FailurePoint43:
				goto FailurePoint42;
			}

		Window->DetuneHalfStepButton = NewRadioButton(Window->ScreenID,"Halfsteps",
			DETUNEHALFSTEPBUTTONX,DETUNEHALFSTEPBUTTONY,DETUNEHALFSTEPBUTTONWIDTH,
			DETUNEHALFSTEPBUTTONHEIGHT);
		if (Window->DetuneHalfStepButton == NIL)
			{
			 FailurePoint44:
				DisposeRadioButton(Window->DetuneHertzButton);
				goto FailurePoint43;
			}

		switch (TrackObjectGetDetuneControlFlag(TheTrackThing))
			{
				default:
					EXECUTE(PRERR(AllowResume,
						"TrackAttributeDialog:  bad detune pitch conversion flag"));
					break;
				case eDetuningModeHertz:
					SetRadioButtonState(Window->DetuneHertzButton,True);
					break;
				case eDetuningModeHalfSteps:
					SetRadioButtonState(Window->DetuneHalfStepButton,True);
					break;
			}

		Window->StereoPositionEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,STEREOPOSITIONEDITX,STEREOPOSITIONEDITY,STEREOPOSITIONEDITWIDTH,
			STEREOPOSITIONEDITHEIGHT);
		if (Window->StereoPositionEdit == NIL)
			{
			 FailurePoint45:
				DisposeRadioButton(Window->DetuneHalfStepButton);
				goto FailurePoint44;
			}
		StringTemp = LongDoubleToString(TrackObjectGetStereoPositioning(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint46:
				DisposeTextEdit(Window->StereoPositionEdit);
				goto FailurePoint45;
			}
		TextEditNewRawData(Window->StereoPositionEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->StereoPositionEdit);

		Window->DurationEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,GetScreenFont(),
			9,DURATIONEDITX,DURATIONEDITY,DURATIONEDITWIDTH,DURATIONEDITHEIGHT);
		if (Window->DurationEdit == NIL)
			{
			 FailurePoint47:
				goto FailurePoint46;
			}
		StringTemp = LongDoubleToString(TrackObjectGetDurationAdjust(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint48:
				DisposeTextEdit(Window->DurationEdit);
				goto FailurePoint47;
			}
		TextEditNewRawData(Window->DurationEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->DurationEdit);

		Window->DurationAddButton = NewRadioButton(Window->ScreenID,"Add",
			DURATIONADDBUTTONX,DURATIONADDBUTTONY,DURATIONADDBUTTONWIDTH,
			DURATIONADDBUTTONHEIGHT);
		if (Window->DurationAddButton == NIL)
			{
			 FailurePoint49:
				goto FailurePoint48;
			}

		Window->DurationMultButton = NewRadioButton(Window->ScreenID,"Mult",
			DURATIONMULTBUTTONX,DURATIONMULTBUTTONY,DURATIONMULTBUTTONWIDTH,
			DURATIONMULTBUTTONHEIGHT);
		if (Window->DurationMultButton == NIL)
			{
			 FailurePoint50:
				DisposeRadioButton(Window->DurationAddButton);
				goto FailurePoint49;
			}

		switch (TrackObjectGetDurationModeFlag(TheTrackThing))
			{
				default:
					EXECUTE(PRERR(AllowResume,
						"TrackAttributeDialog:  bad duration mode flag"));
					break;
				case eDurationAdjustAdditive:
					SetRadioButtonState(Window->DurationAddButton,True);
					break;
				case eDurationAdjustMultiplicative:
					SetRadioButtonState(Window->DurationMultButton,True);
					break;
			}


		Window->SurroundEdit = NewTextEdit(Window->ScreenID,eTENoScrollBars,
			GetScreenFont(),9,SURROUNDPOSITIONEDITX,SURROUNDPOSITIONEDITY,
			SURROUNDPOSITIONEDITWIDTH,SURROUNDPOSITIONEDITHEIGHT);
		if (Window->SurroundEdit == NIL)
			{
			 FailurePoint51:
				DisposeRadioButton(Window->DurationMultButton);
				goto FailurePoint50;
			}
		StringTemp = LongDoubleToString(TrackObjectGetSurroundPositioning(TheTrackThing),
			7,1e-4,1e6);
		if (StringTemp == NIL)
			{
			 FailurePoint52:
				DisposeTextEdit(Window->SurroundEdit);
				goto FailurePoint51;
			}
		TextEditNewRawData(Window->SurroundEdit,StringTemp,SYSTEMLINEFEED);
		ReleasePtr(StringTemp);
		TextEditHasBeenSaved(Window->SurroundEdit);


		ActiveTextEdit = Window->NameEdit;
		EnableTextEditSelection(ActiveTextEdit);
		TextEditDoMenuSelectAll(ActiveTextEdit);
		LoopFlag = True;
		while (LoopFlag)
			{
				OrdType							X;
				OrdType							Y;
				ModifierFlags				Modifiers;
				MenuItemType*				MenuItem;
				char								KeyPress;

				switch (GetAnEvent(&X,&Y,&Modifiers,NIL,&MenuItem,&KeyPress))
					{
						default:
							break;
						case eCheckCursor:
							if (TextEditIBeamTest(Window->NameEdit,X,Y)
								|| TextEditIBeamTest(Window->InstrumentEdit,X,Y)
								|| TextEditIBeamTest(Window->EarlyLateAdjustEdit,X,Y)
								|| TextEditIBeamTest(Window->ReleasePoint1Edit,X,Y)
								|| TextEditIBeamTest(Window->LoudnessEdit,X,Y)
								|| TextEditIBeamTest(Window->ReleasePoint2Edit,X,Y)
								|| TextEditIBeamTest(Window->Accent1Edit,X,Y)
								|| TextEditIBeamTest(Window->Accent2Edit,X,Y)
								|| TextEditIBeamTest(Window->Accent3Edit,X,Y)
								|| TextEditIBeamTest(Window->Accent4Edit,X,Y)
								|| TextEditIBeamTest(Window->PitchDispRateEdit,X,Y)
								|| TextEditIBeamTest(Window->PitchDispDepthEdit,X,Y)
								|| TextEditIBeamTest(Window->HurryUpEdit,X,Y)
								|| TextEditIBeamTest(Window->PitchDispStartEdit,X,Y)
								|| TextEditIBeamTest(Window->DetuneEdit,X,Y)
								|| TextEditIBeamTest(Window->StereoPositionEdit,X,Y)
								|| TextEditIBeamTest(Window->SurroundEdit,X,Y)
								|| TextEditIBeamTest(Window->DurationEdit,X,Y))
								{
									SetIBeamCursor();
								}
							 else
								{
									SetArrowCursor();
								}
							goto UpdateCursorPoint;
							break;
						case eNoEvent:
						 UpdateCursorPoint:
							TextEditUpdateCursor(ActiveTextEdit);
							break;
						case eMenuStarting:
							EnableMenuItem(mPaste);
							if (TextEditIsThereValidSelection(ActiveTextEdit))
								{
									EnableMenuItem(mCut);
									EnableMenuItem(mCopy);
									EnableMenuItem(mClear);
								}
							EnableMenuItem(mSelectAll);
							if (TextEditCanWeUndo(ActiveTextEdit))
								{
									EnableMenuItem(mUndo);
								}
							break;
						case eMenuCommand:
							if (MenuItem == mPaste)
								{
									TextEditDoMenuPaste(ActiveTextEdit);
								}
							else if (MenuItem == mCut)
								{
									TextEditDoMenuCut(ActiveTextEdit);
								}
							else if (MenuItem == mCopy)
								{
									TextEditDoMenuCopy(ActiveTextEdit);
								}
							else if (MenuItem == mClear)
								{
									TextEditDoMenuClear(ActiveTextEdit);
								}
							else if (MenuItem == mUndo)
								{
									TextEditDoMenuUndo(ActiveTextEdit);
									TextEditShowSelection(ActiveTextEdit);
								}
							else if (MenuItem == mSelectAll)
								{
									TextEditDoMenuSelectAll(ActiveTextEdit);
								}
							else
								{
									EXECUTE(PRERR(AllowResume,
										"TrackAttributeDialog: Undefined menu option chosen"));
								}
							break;
						case eKeyPressed:
							if (KeyPress == 13)
								{
									FlashButton(Window->OKButton);
									DoItFlag = True;
									LoopFlag = False;
								}
							else if (KeyPress == 9)
								{
									DisableTextEditSelection(ActiveTextEdit);
									if ((eShiftKey & Modifiers) == 0)
										{
											/* tab forwards */
											if (ActiveTextEdit == Window->NameEdit)
												{
													ActiveTextEdit = Window->InstrumentEdit;
												}
											else if (ActiveTextEdit == Window->InstrumentEdit)
												{
													ActiveTextEdit = Window->EarlyLateAdjustEdit;
												}
											else if (ActiveTextEdit == Window->EarlyLateAdjustEdit)
												{
													ActiveTextEdit = Window->ReleasePoint1Edit;
												}
											else if (ActiveTextEdit == Window->ReleasePoint1Edit)
												{
													ActiveTextEdit = Window->LoudnessEdit;
												}
											else if (ActiveTextEdit == Window->LoudnessEdit)
												{
													ActiveTextEdit = Window->ReleasePoint2Edit;
												}
											else if (ActiveTextEdit == Window->ReleasePoint2Edit)
												{
													ActiveTextEdit = Window->Accent1Edit;
												}
											else if (ActiveTextEdit == Window->Accent1Edit)
												{
													ActiveTextEdit = Window->Accent2Edit;
												}
											else if (ActiveTextEdit == Window->Accent2Edit)
												{
													ActiveTextEdit = Window->Accent3Edit;
												}
											else if (ActiveTextEdit == Window->Accent3Edit)
												{
													ActiveTextEdit = Window->Accent4Edit;
												}
											else if (ActiveTextEdit == Window->Accent4Edit)
												{
													ActiveTextEdit = Window->PitchDispRateEdit;
												}
											else if (ActiveTextEdit == Window->PitchDispRateEdit)
												{
													ActiveTextEdit = Window->PitchDispDepthEdit;
												}
											else if (ActiveTextEdit == Window->PitchDispDepthEdit)
												{
													ActiveTextEdit = Window->HurryUpEdit;
												}
											else if (ActiveTextEdit == Window->HurryUpEdit)
												{
													ActiveTextEdit = Window->PitchDispStartEdit;
												}
											else if (ActiveTextEdit == Window->PitchDispStartEdit)
												{
													ActiveTextEdit = Window->StereoPositionEdit;
												}
											else if (ActiveTextEdit == Window->StereoPositionEdit)
												{
													ActiveTextEdit = Window->DetuneEdit;
												}
											else if (ActiveTextEdit == Window->DetuneEdit)
												{
													ActiveTextEdit = Window->SurroundEdit;
												}
											else if (ActiveTextEdit == Window->SurroundEdit)
												{
													ActiveTextEdit = Window->DurationEdit;
												}
											else
												{
													ActiveTextEdit = Window->NameEdit;
												}
										}
									 else
										{
											/* tab backwards */
											if (ActiveTextEdit == Window->DurationEdit)
												{
													ActiveTextEdit = Window->SurroundEdit;
												}
											else if (ActiveTextEdit == Window->SurroundEdit)
												{
													ActiveTextEdit = Window->DetuneEdit;
												}
											else if (ActiveTextEdit == Window->DetuneEdit)
												{
													ActiveTextEdit = Window->StereoPositionEdit;
												}
											else if (ActiveTextEdit == Window->StereoPositionEdit)
												{
													ActiveTextEdit = Window->PitchDispStartEdit;
												}
											else if (ActiveTextEdit == Window->PitchDispStartEdit)
												{
													ActiveTextEdit = Window->HurryUpEdit;
												}
											else if (ActiveTextEdit == Window->HurryUpEdit)
												{
													ActiveTextEdit = Window->PitchDispDepthEdit;
												}
											else if (ActiveTextEdit == Window->PitchDispDepthEdit)
												{
													ActiveTextEdit = Window->PitchDispRateEdit;
												}
											else if (ActiveTextEdit == Window->PitchDispRateEdit)
												{
													ActiveTextEdit = Window->Accent4Edit;
												}
											else if (ActiveTextEdit == Window->Accent4Edit)
												{
													ActiveTextEdit = Window->Accent3Edit;
												}
											else if (ActiveTextEdit == Window->Accent3Edit)
												{
													ActiveTextEdit = Window->Accent2Edit;
												}
											else if (ActiveTextEdit == Window->Accent2Edit)
												{
													ActiveTextEdit = Window->Accent1Edit;
												}
											else if (ActiveTextEdit == Window->Accent1Edit)
												{
													ActiveTextEdit = Window->ReleasePoint2Edit;
												}
											else if (ActiveTextEdit == Window->ReleasePoint2Edit)
												{
													ActiveTextEdit = Window->LoudnessEdit;
												}
											else if (ActiveTextEdit == Window->LoudnessEdit)
												{
													ActiveTextEdit = Window->ReleasePoint1Edit;
												}
											else if (ActiveTextEdit == Window->ReleasePoint1Edit)
												{
													ActiveTextEdit = Window->EarlyLateAdjustEdit;
												}
											else if (ActiveTextEdit == Window->EarlyLateAdjustEdit)
												{
													ActiveTextEdit = Window->InstrumentEdit;
												}
											else if (ActiveTextEdit == Window->InstrumentEdit)
												{
													ActiveTextEdit = Window->NameEdit;
												}
											else
												{
													ActiveTextEdit = Window->DurationEdit;
												}
										}
									TextEditDoMenuSelectAll(ActiveTextEdit);
									EnableTextEditSelection(ActiveTextEdit);
								}
							else if (KeyPress == eCancelKey)
								{
									FlashButton(Window->CancelButton);
									DoItFlag = False;
									LoopFlag = False;
								}
							else
								{
									TextEditDoKeyPressed(ActiveTextEdit,KeyPress,Modifiers);
								}
							break;
						case eMouseDown:
							if (SimpleButtonHitTest(Window->OKButton,X,Y))
								{
									if (SimpleButtonMouseDown(Window->OKButton,X,Y,NIL,NIL))
										{
											DoItFlag = True;
											LoopFlag = False;
										}
								}
							else if (SimpleButtonHitTest(Window->CancelButton,X,Y))
								{
									if (SimpleButtonMouseDown(Window->CancelButton,X,Y,NIL,NIL))
										{
											DoItFlag = False;
											LoopFlag = False;
										}
								}
							else if (TextEditHitTest(Window->NameEdit,X,Y))
								{
									if (ActiveTextEdit != Window->NameEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->NameEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->InstrumentEdit,X,Y))
								{
									if (ActiveTextEdit != Window->InstrumentEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->InstrumentEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->EarlyLateAdjustEdit,X,Y))
								{
									if (ActiveTextEdit != Window->EarlyLateAdjustEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->EarlyLateAdjustEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->ReleasePoint1Edit,X,Y))
								{
									if (ActiveTextEdit != Window->ReleasePoint1Edit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->ReleasePoint1Edit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (RadioButtonHitTest(Window->ReleasePoint1StartButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->ReleasePoint1StartButton,X,Y))
										{
											SetRadioButtonState(Window->ReleasePoint1EndButton,False);
										}
								}
							else if (RadioButtonHitTest(Window->ReleasePoint1EndButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->ReleasePoint1EndButton,X,Y))
										{
											SetRadioButtonState(Window->ReleasePoint1StartButton,False);
										}
								}
							else if (TextEditHitTest(Window->LoudnessEdit,X,Y))
								{
									if (ActiveTextEdit != Window->LoudnessEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->LoudnessEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->ReleasePoint2Edit,X,Y))
								{
									if (ActiveTextEdit != Window->ReleasePoint2Edit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->ReleasePoint2Edit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (RadioButtonHitTest(Window->ReleasePoint2StartButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->ReleasePoint2StartButton,X,Y))
										{
											SetRadioButtonState(Window->ReleasePoint2EndButton,False);
										}
								}
							else if (RadioButtonHitTest(Window->ReleasePoint2EndButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->ReleasePoint2EndButton,X,Y))
										{
											SetRadioButtonState(Window->ReleasePoint2StartButton,False);
										}
								}
							else if (TextEditHitTest(Window->Accent1Edit,X,Y))
								{
									if (ActiveTextEdit != Window->Accent1Edit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->Accent1Edit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->Accent2Edit,X,Y))
								{
									if (ActiveTextEdit != Window->Accent2Edit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->Accent2Edit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->Accent3Edit,X,Y))
								{
									if (ActiveTextEdit != Window->Accent3Edit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->Accent3Edit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->Accent4Edit,X,Y))
								{
									if (ActiveTextEdit != Window->Accent4Edit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->Accent4Edit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->PitchDispRateEdit,X,Y))
								{
									if (ActiveTextEdit != Window->PitchDispRateEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->PitchDispRateEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->PitchDispDepthEdit,X,Y))
								{
									if (ActiveTextEdit != Window->PitchDispDepthEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->PitchDispDepthEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->HurryUpEdit,X,Y))
								{
									if (ActiveTextEdit != Window->HurryUpEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->HurryUpEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->PitchDispStartEdit,X,Y))
								{
									if (ActiveTextEdit != Window->PitchDispStartEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->PitchDispStartEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (RadioButtonHitTest(Window->PitchDispStartStartButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->PitchDispStartStartButton,X,Y))
										{
											SetRadioButtonState(Window->PitchDispStartEndButton,False);
										}
								}
							else if (RadioButtonHitTest(Window->PitchDispStartEndButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->PitchDispStartEndButton,X,Y))
										{
											SetRadioButtonState(Window->PitchDispStartStartButton,False);
										}
								}
							else if (TextEditHitTest(Window->DetuneEdit,X,Y))
								{
									if (ActiveTextEdit != Window->DetuneEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->DetuneEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (RadioButtonHitTest(Window->DetuneHertzButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->DetuneHertzButton,X,Y))
										{
											SetRadioButtonState(Window->DetuneHalfStepButton,False);
										}
								}
							else if (RadioButtonHitTest(Window->DetuneHalfStepButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->DetuneHalfStepButton,X,Y))
										{
											SetRadioButtonState(Window->DetuneHertzButton,False);
										}
								}
							else if (TextEditHitTest(Window->StereoPositionEdit,X,Y))
								{
									if (ActiveTextEdit != Window->StereoPositionEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->StereoPositionEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->SurroundEdit,X,Y))
								{
									if (ActiveTextEdit != Window->SurroundEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->SurroundEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (TextEditHitTest(Window->DurationEdit,X,Y))
								{
									if (ActiveTextEdit != Window->DurationEdit)
										{
											DisableTextEditSelection(ActiveTextEdit);
											ActiveTextEdit = Window->DurationEdit;
											EnableTextEditSelection(ActiveTextEdit);
										}
									TextEditDoMouseDown(ActiveTextEdit,X,Y,Modifiers);
								}
							else if (RadioButtonHitTest(Window->DurationAddButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->DurationAddButton,X,Y))
										{
											SetRadioButtonState(Window->DurationMultButton,False);
										}
								}
							else if (RadioButtonHitTest(Window->DurationMultButton,X,Y))
								{
									if (RadioButtonMouseDown(Window->DurationMultButton,X,Y))
										{
											SetRadioButtonState(Window->DurationAddButton,False);
										}
								}
							break;
					}
			}
		ERROR((DoItFlag != True) && (DoItFlag != False),PRERR(ForceAbort,
			"TrackAttributeDialog:  DoItFlag is neither true nor false"));

		if (DoItFlag)
			{
				MyBoolean					ErrorNoMemory;

				ErrorNoMemory = False;

				if (TextEditDoesItNeedToBeSaved(Window->InstrumentEdit))
					{
						StringTemp = TextEditGetRawData(Window->InstrumentEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								TrackObjectPutNewInstrName(TheTrackThing,StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->NameEdit))
					{
						StringTemp = TextEditGetRawData(Window->NameEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								TrackObjectPutName(TheTrackThing,StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->EarlyLateAdjustEdit))
					{
						StringTemp = TextEditGetRawData(Window->EarlyLateAdjustEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectEarlyLateAdjust(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->ReleasePoint1Edit))
					{
						StringTemp = TextEditGetRawData(Window->ReleasePoint1Edit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectReleasePoint1(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (GetRadioButtonState(Window->ReleasePoint1StartButton))
					{
						PutTrackObjectReleasePoint1StartEndFlag(TheTrackThing,eRelease1FromStart);
					}
				else if (GetRadioButtonState(Window->ReleasePoint1EndButton))
					{
						PutTrackObjectReleasePoint1StartEndFlag(TheTrackThing,eRelease1FromEnd);
					}
				else
					{
						EXECUTE(PRERR(AllowResume,"TrackAttributeDialog:  release point 1 radio "
							"buttons are in an inconsistent state"));
					}

				if (TextEditDoesItNeedToBeSaved(Window->LoudnessEdit))
					{
						StringTemp = TextEditGetRawData(Window->LoudnessEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectOverallLoudness(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->ReleasePoint2Edit))
					{
						StringTemp = TextEditGetRawData(Window->ReleasePoint2Edit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectReleasePoint2(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (GetRadioButtonState(Window->ReleasePoint2StartButton))
					{
						PutTrackObjectReleasePoint2StartEndFlag(TheTrackThing,eRelease2FromStart);
					}
				else if (GetRadioButtonState(Window->ReleasePoint2EndButton))
					{
						PutTrackObjectReleasePoint2StartEndFlag(TheTrackThing,eRelease2FromEnd);
					}
				else
					{
						EXECUTE(PRERR(AllowResume,"TrackAttributeDialog:  release point 2 radio "
							"buttons are in an inconsistent state"));
					}

				if (TextEditDoesItNeedToBeSaved(Window->Accent1Edit))
					{
						StringTemp = TextEditGetRawData(Window->Accent1Edit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectAccent1(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->Accent2Edit))
					{
						StringTemp = TextEditGetRawData(Window->Accent2Edit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectAccent2(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->Accent3Edit))
					{
						StringTemp = TextEditGetRawData(Window->Accent3Edit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectAccent3(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->Accent4Edit))
					{
						StringTemp = TextEditGetRawData(Window->Accent4Edit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectAccent4(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->PitchDispRateEdit))
					{
						StringTemp = TextEditGetRawData(Window->PitchDispRateEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectPitchDisplacementRateAdjust(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->PitchDispDepthEdit))
					{
						StringTemp = TextEditGetRawData(Window->PitchDispDepthEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectPitchDisplacementDepthAdjust(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->HurryUpEdit))
					{
						StringTemp = TextEditGetRawData(Window->HurryUpEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectHurryUp(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->PitchDispStartEdit))
					{
						StringTemp = TextEditGetRawData(Window->PitchDispStartEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectPitchDisplacementStartPoint(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (GetRadioButtonState(Window->PitchDispStartStartButton))
					{
						PutTrackObjectPitchDisplacementFromStartOrEnd(TheTrackThing,
							ePitchDisplacementStartFromStart);
					}
				else if (GetRadioButtonState(Window->PitchDispStartEndButton))
					{
						PutTrackObjectPitchDisplacementFromStartOrEnd(TheTrackThing,
							ePitchDisplacementStartFromEnd);
					}
				else
					{
						EXECUTE(PRERR(AllowResume,"TrackAttributeDialog:  pitch displacement "
							"start/end radio buttons are in an inconsistent state"));
					}

				if (TextEditDoesItNeedToBeSaved(Window->DetuneEdit))
					{
						StringTemp = TextEditGetRawData(Window->DetuneEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectDetune(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (GetRadioButtonState(Window->DetuneHertzButton))
					{
						PutTrackObjectDetuneControlFlag(TheTrackThing,eDetuningModeHertz);
					}
				else if (GetRadioButtonState(Window->DetuneHalfStepButton))
					{
						PutTrackObjectDetuneControlFlag(TheTrackThing,eDetuningModeHalfSteps);
					}
				else
					{
						EXECUTE(PRERR(AllowResume,"TrackAttributeDialog:  detune conversion mode "
							"radio buttons are in an inconsistent state"));
					}

				if (TextEditDoesItNeedToBeSaved(Window->StereoPositionEdit))
					{
						StringTemp = TextEditGetRawData(Window->StereoPositionEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectStereoPositioning(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->SurroundEdit))
					{
						StringTemp = TextEditGetRawData(Window->SurroundEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectSurroundPositioning(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (TextEditDoesItNeedToBeSaved(Window->DurationEdit))
					{
						StringTemp = TextEditGetRawData(Window->DurationEdit,SYSTEMLINEFEED);
						if (StringTemp == NIL)
							{
								ErrorNoMemory = True;
							}
						 else
							{
								PutTrackObjectDurationAdjust(TheTrackThing,
									StringToLongDouble(StringTemp,PtrSize(StringTemp)));
								ReleasePtr(StringTemp);
							}
					}

				if (GetRadioButtonState(Window->DurationAddButton))
					{
						PutTrackObjectDurationModeFlag(TheTrackThing,eDurationAdjustAdditive);
					}
				else if (GetRadioButtonState(Window->DurationMultButton))
					{
						PutTrackObjectDurationModeFlag(TheTrackThing,eDurationAdjustMultiplicative);
					}
				else
					{
						EXECUTE(PRERR(AllowResume,"TrackAttributeDialog:  duration mode "
							"radio buttons are in an inconsistent state"));
					}

				if (ErrorNoMemory)
					{
						AlertHalt("There was not enough memory to save all of the attributes.",NIL);
					}
			}

		DisposeSimpleButton(Window->OKButton);
		DisposeSimpleButton(Window->CancelButton);
		DisposeTextEdit(Window->NameEdit);
		DisposeTextEdit(Window->InstrumentEdit);
		DisposeTextEdit(Window->EarlyLateAdjustEdit);
		DisposeTextEdit(Window->ReleasePoint1Edit);
		DisposeRadioButton(Window->ReleasePoint1StartButton);
		DisposeRadioButton(Window->ReleasePoint1EndButton);
		DisposeTextEdit(Window->LoudnessEdit);
		DisposeTextEdit(Window->ReleasePoint2Edit);
		DisposeRadioButton(Window->ReleasePoint2StartButton);
		DisposeRadioButton(Window->ReleasePoint2EndButton);
		DisposeTextEdit(Window->Accent1Edit);
		DisposeTextEdit(Window->Accent2Edit);
		DisposeTextEdit(Window->Accent3Edit);
		DisposeTextEdit(Window->Accent4Edit);
		DisposeTextEdit(Window->PitchDispRateEdit);
		DisposeTextEdit(Window->PitchDispDepthEdit);
		DisposeTextEdit(Window->HurryUpEdit);
		DisposeTextEdit(Window->PitchDispStartEdit);
		DisposeRadioButton(Window->PitchDispStartStartButton);
		DisposeRadioButton(Window->PitchDispStartEndButton);
		DisposeTextEdit(Window->StereoPositionEdit);
		DisposeTextEdit(Window->SurroundEdit);
		DisposeTextEdit(Window->DetuneEdit);
		DisposeRadioButton(Window->DetuneHertzButton);
		DisposeRadioButton(Window->DetuneHalfStepButton);
		DisposeTextEdit(Window->DurationEdit);
		DisposeRadioButton(Window->DurationAddButton);
		DisposeRadioButton(Window->DurationMultButton);
		KillWindow(Window->ScreenID);
		ReleasePtr((char*)Window);
		/* no return value */
	}
