/* WaveTableObject.h */

#ifndef Included_WaveTableObject_h
#define Included_WaveTableObject_h

/* WaveTableObject module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* Array */
/* WaveTableList */
/* Memory */
/* DataMunging */
/* FixedPoint */
/* WaveTableWindow */
/* SampleConsts */
/* FixedPoint */
/* WaveTableStorage */
/* MainWindowStuff */
/* BufferedFileInput */
/* BufferedFileOutput */
/* BinaryCodedDecimal */

#include "SampleConsts.h"
#include "FixedPoint.h"
#include "MainWindowStuff.h"

struct WaveTableObjectRec;
typedef struct WaveTableObjectRec WaveTableObjectRec;

/* forward declarations */
struct CodeCenterRec;
struct MainWindowRec;
struct WaveTableListRec;
struct ArrayRec;
struct WaveTableStorageRec;
struct BufferedInputRec;
struct BufferedOutputRec;

/* create a new wave table object with reasonable defaults. */
WaveTableObjectRec*		NewWaveTableObject(struct CodeCenterRec* CodeCenter,
												struct MainWindowRec* MainWindow,
												struct WaveTableListRec* WaveTableList);

/* create a new wave table based on the data being passed in. */
WaveTableObjectRec*		NewWaveTableObjectFromData(struct CodeCenterRec* CodeCenter,
												struct MainWindowRec* MainWindow,
												struct WaveTableListRec* WaveTableList, char* RawData,
												NumBitsType NumBits, long NumTables, long FramesPerTable);

/* dispose of a wave table object */
void									DisposeWaveTableObject(WaveTableObjectRec* WaveTableObj);

/* find out if wave table object has been modified */
MyBoolean							HasWaveTableObjectBeenModified(WaveTableObjectRec* WaveTableObj);

/* get a copy of the wave table's name */
char*									WaveTableObjectGetNameCopy(WaveTableObjectRec* WaveTableObj);

/* set the wave table's name.  the object becomes the owner of the Name block, */
/* so the caller should not release it. */
void									WaveTableObjectNewName(WaveTableObjectRec* WaveTableObj,
												char* Name);

/* get a copy of the formula applied to the wave table. */
char*									WaveTableObjectGetFormulaCopy(WaveTableObjectRec* WaveTableObj);

/* install a new formula into the wave table.  the object becomes the owner of */
/* the formula, so the caller should not dispose it. */
void									WaveTableObjectNewFormula(WaveTableObjectRec* WaveTableObj,
												char* Formula);

/* find out whether its 8 or 16 bits. */
NumBitsType						WaveTableObjectGetNumBits(WaveTableObjectRec* WaveTableObj);

/* find out how many tables there are in the wave table */
long									WaveTableObjectGetNumTables(WaveTableObjectRec* WaveTableObj);

/* find out how many entries there are in a single table */
long									WaveTableObjectEntriesPerTable(WaveTableObjectRec* WaveTableObj);

/* get the raw data for a particular wave table.  this returns the actual data, so */
/* don't dispose it.  if any operations are performed on the wave table, this */
/* pointer may become invalid.  the data is in the following format: */
/*  - 8-bit:  array of signed bytes */
/*  - 16-bit:  array of signed short integers */
char*									WaveTableObjectGetRawSlice(WaveTableObjectRec* WaveTableObj,
												long WaveTableIndex);

/* put new data into the wave table. the object becomes the owner of all data passed in. */
void									WaveTableObjectPutNewData(WaveTableObjectRec* WaveTableObj,
												struct WaveTableStorageRec* NewWaveTable);

/* tell the wave table to open it's editor window */
MyBoolean							WaveTableObjectOpenWindow(WaveTableObjectRec* WaveTableObj);

/* this is called by the window when it is closing to notify the object. */
/* the object should not take any action. */
void									WaveTableObjectClosingWindowNotify(
												WaveTableObjectRec* WaveTableObj, short NewX, short NewY,
												short NewWidth, short NewHeight);

/* obtain a fixedpoint array of data.  NIL is returned if there isn't enough memory. */
largefixedsigned*			WaveTableObjectGetFixed(WaveTableObjectRec* WaveTableObj);

/* the document's name has changed, so we need to update the windows */
void									WaveTableObjectGlobalNameChange(WaveTableObjectRec* WaveTableObj,
												char* NewFilename);

/* get the test attack duration */
double								WaveTableObjectGetTestAttack(WaveTableObjectRec* WaveTableObj);

/* put a new test attack duration */
void									SetWaveTableObjectTestAttack(WaveTableObjectRec* WaveTableObj,
												double NewTestAttack);

/* get the test decay duration */
double								WaveTableObjectGetTestDecay(WaveTableObjectRec* WaveTableObj);

/* put a new test decay duration */
void									SetWaveTableObjectTestDecay(WaveTableObjectRec* WaveTableObj,
												double NewTestDecay);

/* get the test sampling rate */
long									WaveTableObjectGetTestSamplingRate(WaveTableObjectRec* WaveTableObj);

/* put a new test sampling rate */
void									SetWaveTableObjectTestSamplingRate(WaveTableObjectRec* WaveTableObj,
												long NewTestSamplingRate);

/* get the test pitch */
double								WaveTableObjectGetTestPitch(WaveTableObjectRec* WaveTableObj);

/* put a new test pitch */
void									SetWaveTableObjectTestPitch(WaveTableObjectRec* WaveTableObj,
												double NewTestPitch);

/* load an object from the file */
FileLoadingErrors			WaveTableObjectNewFromFile(WaveTableObjectRec** ObjectOut,
												struct BufferedInputRec* Input, struct CodeCenterRec* CodeCenter,
												struct MainWindowRec* MainWindow,
												struct WaveTableListRec* WaveTableList);

/* write the object out to the file. */
FileLoadingErrors			WaveTableObjectWriteDataOut(WaveTableObjectRec* WaveTableObj,
												struct BufferedOutputRec* Output);

/* mark wave table object as saved */
void									WaveTableObjectMarkAsSaved(WaveTableObjectRec* WaveTableObj);

#endif
