Home | History | Annotate | Download | only in host_src
      1 /*----------------------------------------------------------------------------
      2  *
      3  * File:
      4  * eas_types.h
      5  *
      6  * Contents and purpose:
      7  * The public interface header for the EAS synthesizer.
      8  *
      9  * This header only contains declarations that are specific
     10  * to this implementation.
     11  *
     12  * DO NOT MODIFY THIS FILE!
     13  *
     14  * Copyright Sonic Network Inc. 2004
     15 
     16  * Licensed under the Apache License, Version 2.0 (the "License");
     17  * you may not use this file except in compliance with the License.
     18  * You may obtain a copy of the License at
     19  *
     20  *      http://www.apache.org/licenses/LICENSE-2.0
     21  *
     22  * Unless required by applicable law or agreed to in writing, software
     23  * distributed under the License is distributed on an "AS IS" BASIS,
     24  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     25  * See the License for the specific language governing permissions and
     26  * limitations under the License.
     27  *
     28  *----------------------------------------------------------------------------
     29  * Revision Control:
     30  *   $Revision: 726 $
     31  *   $Date: 2007-06-14 23:10:46 -0700 (Thu, 14 Jun 2007) $
     32  *----------------------------------------------------------------------------
     33 */
     34 
     35 #ifndef _EAS_TYPES_H
     36 #define _EAS_TYPES_H
     37 
     38 /* EAS_RESULT return codes */
     39 typedef long EAS_RESULT;
     40 #define EAS_SUCCESS                         0
     41 #define EAS_FAILURE                         -1
     42 #define EAS_ERROR_INVALID_MODULE            -2
     43 #define EAS_ERROR_MALLOC_FAILED             -3
     44 #define EAS_ERROR_FILE_POS                  -4
     45 #define EAS_ERROR_INVALID_FILE_MODE         -5
     46 #define EAS_ERROR_FILE_SEEK                 -6
     47 #define EAS_ERROR_FILE_LENGTH               -7
     48 #define EAS_ERROR_NOT_IMPLEMENTED           -8
     49 #define EAS_ERROR_CLOSE_FAILED              -9
     50 #define EAS_ERROR_FILE_OPEN_FAILED          -10
     51 #define EAS_ERROR_INVALID_HANDLE            -11
     52 #define EAS_ERROR_NO_MIX_BUFFER             -12
     53 #define EAS_ERROR_PARAMETER_RANGE           -13
     54 #define EAS_ERROR_MAX_FILES_OPEN            -14
     55 #define EAS_ERROR_UNRECOGNIZED_FORMAT       -15
     56 #define EAS_BUFFER_SIZE_MISMATCH            -16
     57 #define EAS_ERROR_FILE_FORMAT               -17
     58 #define EAS_ERROR_SMF_NOT_INITIALIZED       -18
     59 #define EAS_ERROR_LOCATE_BEYOND_END         -19
     60 #define EAS_ERROR_INVALID_PCM_TYPE          -20
     61 #define EAS_ERROR_MAX_PCM_STREAMS           -21
     62 #define EAS_ERROR_NO_VOICE_ALLOCATED        -22
     63 #define EAS_ERROR_INVALID_CHANNEL           -23
     64 #define EAS_ERROR_ALREADY_STOPPED           -24
     65 #define EAS_ERROR_FILE_READ_FAILED          -25
     66 #define EAS_ERROR_HANDLE_INTEGRITY          -26
     67 #define EAS_ERROR_MAX_STREAMS_OPEN          -27
     68 #define EAS_ERROR_INVALID_PARAMETER         -28
     69 #define EAS_ERROR_FEATURE_NOT_AVAILABLE     -29
     70 #define EAS_ERROR_SOUND_LIBRARY             -30
     71 #define EAS_ERROR_NOT_VALID_IN_THIS_STATE   -31
     72 #define EAS_ERROR_NO_VIRTUAL_SYNTHESIZER    -32
     73 #define EAS_ERROR_FILE_ALREADY_OPEN         -33
     74 #define EAS_ERROR_FILE_ALREADY_CLOSED       -34
     75 #define EAS_ERROR_INCOMPATIBLE_VERSION      -35
     76 #define EAS_ERROR_QUEUE_IS_FULL             -36
     77 #define EAS_ERROR_QUEUE_IS_EMPTY            -37
     78 #define EAS_ERROR_FEATURE_ALREADY_ACTIVE    -38
     79 
     80 /* special return codes */
     81 #define EAS_EOF                             3
     82 #define EAS_STREAM_BUFFERING                4
     83 #define EAS_BUFFER_FULL                     5
     84 
     85 /* EAS_STATE return codes */
     86 typedef long EAS_STATE;
     87 typedef enum
     88 {
     89     EAS_STATE_READY = 0,
     90     EAS_STATE_PLAY,
     91     EAS_STATE_STOPPING,
     92     EAS_STATE_PAUSING,
     93     EAS_STATE_STOPPED,
     94     EAS_STATE_PAUSED,
     95     EAS_STATE_OPEN,
     96     EAS_STATE_ERROR,
     97     EAS_STATE_EMPTY
     98 } E_EAS_STATE;
     99 
    100 /* constants */
    101 #ifndef EAS_CONST
    102 #define EAS_CONST const
    103 #endif
    104 
    105 /* definition for public interface functions */
    106 #ifndef EAS_PUBLIC
    107 #define EAS_PUBLIC
    108 #endif
    109 
    110 /* boolean values */
    111 typedef unsigned EAS_BOOL;
    112 typedef unsigned char EAS_BOOL8;
    113 
    114 #define EAS_FALSE   0
    115 #define EAS_TRUE    1
    116 
    117 /* scalar variable definitions */
    118 typedef unsigned char EAS_U8;
    119 typedef signed char EAS_I8;
    120 typedef char EAS_CHAR;
    121 
    122 typedef unsigned short EAS_U16;
    123 typedef short EAS_I16;
    124 
    125 typedef unsigned long EAS_U32;
    126 typedef long EAS_I32;
    127 
    128 typedef unsigned EAS_UINT;
    129 typedef int EAS_INT;
    130 typedef long EAS_LONG;
    131 
    132 /* audio output type */
    133 typedef short EAS_PCM;
    134 
    135 /* file open modes */
    136 typedef EAS_I32 EAS_FILE_MODE;
    137 #define EAS_FILE_READ   1
    138 #define EAS_FILE_WRITE  2
    139 
    140 /* file locator e.g. filename or memory pointer */
    141 typedef struct s_eas_file_tag {
    142     const char* path;
    143     int         fd;
    144     long long   offset;
    145     long long   length;
    146 } EAS_FILE, *EAS_FILE_LOCATOR;
    147 
    148 /* handle to stream */
    149 typedef struct s_eas_stream_tag *EAS_HANDLE;
    150 
    151 /* handle to file */
    152 typedef struct eas_hw_file_tag *EAS_FILE_HANDLE;
    153 
    154 /* handle for synthesizer data */
    155 typedef struct s_eas_data_tag *EAS_DATA_HANDLE;
    156 
    157 /* handle to persistent data for host wrapper interface */
    158 typedef struct eas_hw_inst_data_tag *EAS_HW_DATA_HANDLE;
    159 
    160 /* handle to sound library */
    161 typedef struct s_eas_sndlib_tag *EAS_SNDLIB_HANDLE;
    162 typedef struct s_eas_dls_tag *EAS_DLSLIB_HANDLE;
    163 
    164 /* pointer to frame buffer - used in split architecture only */
    165 typedef struct s_eas_frame_buffer_tag *EAS_FRAME_BUFFER_HANDLE;
    166 
    167 /* untyped pointer for instance data */
    168 typedef void *EAS_VOID_PTR;
    169 
    170 /* inline functions */
    171 #ifndef EAS_INLINE
    172 #if defined (__XCC__)
    173 #define EAS_INLINE __inline__
    174 #elif defined (__GNUC__)
    175 #define EAS_INLINE inline static
    176 #else
    177 #define EAS_INLINE __inline
    178 #endif
    179 #endif
    180 
    181 /* define NULL value */
    182 #ifndef NULL
    183 #define NULL 0
    184 #endif
    185 
    186 /* metadata types for metadata return codes */
    187 typedef enum
    188 {
    189     EAS_METADATA_UNKNOWN = 0,
    190     EAS_METADATA_TITLE,
    191     EAS_METADATA_AUTHOR,
    192     EAS_METADATA_COPYRIGHT,
    193     EAS_METADATA_LYRIC,
    194     EAS_METADATA_TEXT
    195 } E_EAS_METADATA_TYPE;
    196 
    197 /* metadata callback function */
    198 typedef void (*EAS_METADATA_CBFUNC) (E_EAS_METADATA_TYPE metaDataType, char *metaDataBuf, EAS_VOID_PTR pUserData);
    199 
    200 /* file types for metadata return codes */
    201 typedef enum
    202 {
    203     EAS_FILE_UNKNOWN = 0,
    204     EAS_FILE_SMF0,
    205     EAS_FILE_SMF1,
    206     EAS_FILE_SMAF_UNKNOWN,
    207     EAS_FILE_SMAF_MA2,
    208     EAS_FILE_SMAF_MA3,
    209     EAS_FILE_SMAF_MA5,
    210     EAS_FILE_CMX,
    211     EAS_FILE_MFI,
    212     EAS_FILE_OTA,
    213     EAS_FILE_IMELODY,
    214     EAS_FILE_RTTTL,
    215     EAS_FILE_XMF0,
    216     EAS_FILE_XMF1,
    217     EAS_FILE_WAVE_PCM,
    218     EAS_FILE_WAVE_IMA_ADPCM,
    219     EAS_FILE_MMAPI_TONE_CONTROL
    220 } E_EAS_FILE_TYPE;
    221 
    222 /* enumeration for synthesizers */
    223 typedef enum
    224 {
    225     EAS_MCU_SYNTH = 0,
    226     EAS_DSP_SYNTH
    227 } E_SYNTHESIZER;
    228 
    229 /* external audio callback program change */
    230 typedef struct s_ext_audio_prg_chg_tag
    231 {
    232     EAS_U16     bank;
    233     EAS_U8      program;
    234     EAS_U8      channel;
    235 } S_EXT_AUDIO_PRG_CHG;
    236 
    237 /* external audio callback event */
    238 typedef struct s_ext_audio_event_tag
    239 {
    240     EAS_U8      channel;
    241     EAS_U8      note;
    242     EAS_U8      velocity;
    243     EAS_BOOL8   noteOn;
    244 } S_EXT_AUDIO_EVENT;
    245 
    246 typedef struct s_midi_controllers_tag
    247 {
    248     EAS_U8      modWheel;           /* CC1 */
    249     EAS_U8      volume;             /* CC7 */
    250     EAS_U8      pan;                /* CC10 */
    251     EAS_U8      expression;         /* CC11 */
    252     EAS_U8      channelPressure;    /* MIDI channel pressure */
    253 
    254 #ifdef  _REVERB
    255     EAS_U8      reverbSend;         /* CC91 */
    256 #endif
    257 
    258 #ifdef  _CHORUS
    259     EAS_U8      chorusSend;         /* CC93 */
    260 #endif
    261 } S_MIDI_CONTROLLERS;
    262 
    263 /* iMode play modes enumeration for EAS_SetPlayMode */
    264 typedef enum
    265 {
    266     IMODE_PLAY_ALL = 0,
    267     IMODE_PLAY_PARTIAL
    268 } E_I_MODE_PLAY_MODE;
    269 
    270 typedef EAS_BOOL (*EAS_EXT_PRG_CHG_FUNC) (EAS_VOID_PTR pInstData, S_EXT_AUDIO_PRG_CHG *pPrgChg);
    271 typedef EAS_BOOL (*EAS_EXT_EVENT_FUNC) (EAS_VOID_PTR pInstData, S_EXT_AUDIO_EVENT *pEvent);
    272 
    273 #endif /* #ifndef _EAS_TYPES_H */
    274