/****************************************************************************************************

		IShSound.h
		Copyright: (c) 2004 Eovia Corp. All rights reserved.

		Author:	Jeremy
		Date:	6/22/2004

****************************************************************************************************/

#ifndef __IShSound__
#define __IShSound__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "ComTypes.h"
#include <MCString.h>
#include <MCClassArray.h>

//#include "APITypes.h"

struct IExSound;
struct I3DShScene; 
struct I3DShMaster;
struct IShMasterSound;

#define kTwosComplement 'twos'
#define kBinaryOffset	'raw '

//****** Globally Unique Ids **************************************************

MCDEFINE_GUID_H(IID_IShSound);
MCDEFINE_GUID_H(IID_IShMasterSound);

MCDEFINE_GUID_H(CLSID_StandardMasterSound);

/*****************************************************************************\
*                                                                             *
*  I3DShSound                                                                 *
*                                                                             *
*    Interface to Sound objects                                               *
*                                                                             *
\*****************************************************************************/

struct IShSound : public IMCUnknown
{
	// ****************************************************************************
	//								
	// 
	// -Description: Accessor for duration of a Sound
	//
	// -Returns: The duration of a sound in milliseconds
	//
	virtual uint32 GetDuration() =0;

	// ****************************************************************************
	//								
	// 
	// -Description: Attaches the Sound to the current Scene.  
	//
	// -Parameters: 
	//			scene	:	Pointer to the scene
	//
	// -Returns: Nothing
	//
	virtual void	SetScene(I3DShScene* scene) =0;

	// ****************************************************************************
	//								
	// 
	// -Description: Sets the node ID for the Sound (for Selection)
	//
	// -Parameters:
	//			inID	:	ID to be assigned
	//
	// -Returns: Nothing
	//
	virtual void	SetID(uint32 inID) =0;

	// ****************************************************************************
	//								
	// 
	// -Description: Accessor for the node ID for Selection use
	//
	// -Returns: the ID of the ShSound
	//
	virtual	uint32	GetID() =0;

	// ****************************************************************************
	//								
	// 
	// -Description: Accessor for filename associated with a Sound
	//
	// -Parameters:
	//			outName	:	destination string to hold the name
	//
	virtual void	GetFilename(TMCString& outName) =0;

	// ****************************************************************************
	//								
	// 
	// -Description: Fills an array with values corresponding to the Sounds waveform.
	//				 Used for drawing the Sound.  outArray should already be sized
	//				 to the desired number of elements, and GetPreviewData will fill
	//				 it appropriately 
	//
	// -Parameters:  outArray, a TMCArray to fill with values.
	//
	// -Returns:	 nothing
	//
	virtual void	GetPreviewData(TMCArray<real32>* outArray) =0; 

	// ****************************************************************************
	//								
	// 
	// -Description: Accessor for the master sound corresponding to this sound instance
	//
	// -Returns:	The pointer to the master sound
	//
	virtual IShMasterSound*	GetMaster()	=0;
};


struct TSoundTextRecord : TMCObject
{
    TMCDynamicString  fText;
    uint32            fStart;
    uint32            fEnd;
    TSoundTextRecord():fStart(0), fEnd(0)   { ;  }
    TSoundTextRecord(const TSoundTextRecord& other):fText(other.fText), fStart(other.fStart), fEnd(other.fEnd)     {; }
    TSoundTextRecord& operator=(const TSoundTextRecord& other)
    {
        if (this != &other)
        {
            fText = other.fText;
            fStart = other.fStart;
            fEnd = other.fEnd;
        }
        return *this;
    }
};

struct IShMasterSound : public IMCUnknown
{
	virtual MCCOMErr	  MCCOMAPI GetName(TMCString& name)										= 0;
	virtual MCCOMErr	  MCCOMAPI SetName(const TMCString& name)								= 0;

	virtual MCCOMErr	  MCCOMAPI SetSound(IExSound* sound)									= 0;
	virtual MCCOMErr	  MCCOMAPI GetSound(IExSound** sound)									= 0;
	virtual MCCOMErr	  MCCOMAPI GetSoundInstance(IShSound** sound)							= 0;
	virtual MCCOMErr	  MCCOMAPI SetScene(I3DShScene* topScene)								= 0;
	virtual MCCOMErr	  MCCOMAPI Clone(IShMasterSound** clone) const							= 0;
	virtual uint32		  MCCOMAPI GetInstancesCount()											= 0;
//	virtual MCCOMErr	  MCCOMAPI GetInstanceArray(TMCCountedPtrArray<I3DShInstance>& instances) =0;
	virtual uint32		  MCCOMAPI GetDuration()												= 0;
	virtual void		  MCCOMAPI GetPreviewData(TMCArray<real32>* outArray)					=0; 
	virtual uint32		  MCCOMAPI GetSoundType()												=0;

//	virtual boolean		  MCCOMAPI IsDefaultMaster() const										= 0;

	//returns the I3DShMaster interface
	virtual I3DShMaster*  MCCOMAPI GetThisMaster	()											= 0;

    // Text sound association functions
    virtual const TMCClassArray<TSoundTextRecord>&  MCCOMAPI GetAssociatedText() const = 0;
    virtual MCCOMErr      MCCOMAPI SetAssociatedText(const TMCClassArray<TSoundTextRecord>& inArray) = 0;
    virtual boolean       MCCOMAPI GetHasAssociatedText() const                                 = 0;
    
};







#endif
