// xappmsg.h
// Author : Dominique Lorre
// $Id: xappmsg.h 1.2 1998/03/09 15:32:08 dlorre Exp dlorre $

#if !defined( CLASS_XAPPMSG_H )
#define CLASS_XAPPMSG_H

#if !defined( EXEC_TYPES_H )
#include <exec/types.h>
#endif

#if !defined( EXEC_PORTS_H )
#include <exec/ports.h>
#endif

#if !defined( UTILITY_HOOKS_H )
#include <utility/hooks.h>
#endif

#if !defined( UTILITY_TAGITEM_H )
#include <utility/tagitem.h>
#endif

#define XAPPNAMELENGTH  40
#define XAPPPORTNAME    "Euterpe.xapp"

#define XAPP_TagBase        (TAG_USER+100)
#define XAPP_Name           (XAPP_TagBase+1)
#define XAPP_PortName       (XAPP_TagBase+2)
#define XAPP_Type           (XAPP_TagBase+3)
#define XAPP_Handle         (XAPP_TagBase+4)
#define XAPP_FileName       (XAPP_TagBase+5)

#define FX_TagBase          (TAG_USER+200)
#define FX_Hook             (FX_TagBase+1)

#define BANK_TagBase        (TAG_USER+300)
#define BANK_MidiBuffer     (BANK_TagBase+1)
#define BANK_MidiLength     (BANK_TagBase+2)
#define BANK_ProgramList    (BANK_TagBase+3)

enum XAppAction {
    XAPPACT_ADD,            // Add the xapp
    XAPPACT_INIT,           // The xapp has successfully initialized it's Port
    XAPPACT_FAILURE,        // The xapp has failed somewhere in it's initialization
    XAPPACT_REMOVE,         // Remove the xapp
    XAPPACT_SHOW,           // Show the xapp window
    XAPPACT_HIDE,           // Hide the xapp window
    XAPPACT_SENDMIDI,       // Send midi to an output
    XAPPACT_RECVMIDI,       // Receive midi from an input
    XAPPACT_LOCKMIDI,       // Get the midi input as exclusive access
    XAPPACT_UNLOCKMIDI,     // Frees the midi input
    XAPPACT_LOADSOUND,      // Load a sound and map it to the specified PGMCHANGE
    XAPPACT_LOADBANK,       // Load a complete sound configuration
    XAPPACT_LOADCONFIG,     // Load an xapp configuration
    XAPPACT_SAVECONFIG,     // Save an xapp configuration
    XAPPACT_PROGRAMLIST     // Ask the bankeditor for the program names
};

enum XAppType {
    XAPPTYP_UNKWNOWN,          // Default value if not set by the xapp
    XAPPTYP_BANKEDITOR,        // Independent application using Euterpe's IO
    XAPPTYP_EFFECTSPROCESSOR   // Effect controlled by Euterpe
};

enum XAppError {
    XAPPERR_ACTION_NOT_KNOWN,   // The XApp do not support this command
    XAPPERR_FILE_NOT_FOUND,     // The XApp could not open the file
    XAPPERR_MIDI_LOCKED,        // Another XApp already locked the Midi Input
    XAPPERR_OK                  // No error
};

struct XAppMsg {
    struct Message  xm_Message ;
    enum XAppAction xm_Action ;
    struct TagItem* xm_Tags ;
    APTR            xm_Result ;
    LONG            xm_Length ;
    enum XAppError  xm_Error ;
} ;

struct FXNode
{
    struct MinNode      x_Node ;
    union {
        UBYTE           x_Data[4] ;
        ULONG           x_Msg ;
    };
    LONG    x_Pos ;     // Position in Sequencer
    LONG    x_Len ;     // Length of a NoteOn
};

#define FXNODEB_INUSE   0
#define FXNODEB_ALLOC   1

#define FXNODEF_INUSE   (1 << FXNODEB_INUSE)
#define FXNODEF_ALLOC   (1 << FXNODEB_ALLOC)

struct FXParams
{
    struct FXNode   *fp_Array ;
    struct MinList  *fp_List ;
    LONG            fp_Size ;
    LONG            fp_Pos ;
};

#endif
