1/*----------------------------------------------------------------------------
2 *
3 * File:
4 * eas_config.c
5 *
6 * Contents and purpose:
7 * This file contains the Configuration Module interface (CM). The CM
8 * is a module compiled external to the library that sets the configuration
9 * for this build. It allows the library to find optional components and
10 * links to static memory allocations (when used in a static configuration).
11 *
12 * DO NOT MODIFY THIS FILE!
13 *
14 * NOTE: This module is not intended to be modified by the customer. It
15 * needs to be included in the build process with the correct configuration
16 * defines (see the library documentation for information on how to configure
17 * the library).
18 *
19 * Copyright Sonic Network Inc. 2004-2006
20
21 * Licensed under the Apache License, Version 2.0 (the "License");
22 * you may not use this file except in compliance with the License.
23 * You may obtain a copy of the License at
24 *
25 *      http://www.apache.org/licenses/LICENSE-2.0
26 *
27 * Unless required by applicable law or agreed to in writing, software
28 * distributed under the License is distributed on an "AS IS" BASIS,
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 * See the License for the specific language governing permissions and
31 * limitations under the License.
32 *
33 *----------------------------------------------------------------------------
34 * Revision Control:
35 *   $Revision: 796 $
36 *   $Date: 2007-08-01 00:15:25 -0700 (Wed, 01 Aug 2007) $
37 *----------------------------------------------------------------------------
38*/
39
40#include "eas.h"
41#include "eas_config.h"
42
43
44#ifdef _MFI_PARSER
45/*----------------------------------------------------------------------------
46 * Vendor/Device ID for MFi Extensions
47 *
48 * Define the preprocessor symbols to establish the vendor ID and
49 * device ID for the MFi PCM/ADPCM extensions.
50 *----------------------------------------------------------------------------
51*/
52const EAS_U8 eas_MFIVendorIDMSB = (MFI_VENDOR_ID >> 8) & 0xff;
53const EAS_U8 eas_MFIVendorIDLSB = MFI_VENDOR_ID & 0xff;
54const EAS_U8 eas_MFIDeviceID = MFI_DEVICE_ID;
55#endif
56
57/*----------------------------------------------------------------------------
58 *
59 * parserModules
60 *
61 * This structure is used by the EAS library to locate file parsing
62 * modules.
63 *----------------------------------------------------------------------------
64*/
65
66/* define the external file parsers */
67extern EAS_VOID_PTR EAS_SMF_Parser;
68
69#ifdef _XMF_PARSER
70extern EAS_VOID_PTR EAS_XMF_Parser;
71#endif
72
73#ifdef _SMAF_PARSER
74extern EAS_VOID_PTR EAS_SMAF_Parser;
75#endif
76
77#ifdef _WAVE_PARSER
78extern EAS_VOID_PTR EAS_Wave_Parser;
79#endif
80
81#ifdef _OTA_PARSER
82extern EAS_VOID_PTR EAS_OTA_Parser;
83#endif
84
85#ifdef _IMELODY_PARSER
86extern EAS_VOID_PTR EAS_iMelody_Parser;
87#endif
88
89#ifdef _RTTTL_PARSER
90extern EAS_VOID_PTR EAS_RTTTL_Parser;
91#endif
92
93#if defined (_CMX_PARSER) || defined(_MFI_PARSER)
94extern EAS_VOID_PTR EAS_CMF_Parser;
95#endif
96
97/* initalize pointers to parser interfaces */
98/*lint -e{605} not pretty, but it works */
99EAS_VOID_PTR const parserModules[] =
100{
101    &EAS_SMF_Parser,
102
103#ifdef _XMF_PARSER
104    &EAS_XMF_Parser,
105#endif
106
107#ifdef _WAVE_PARSER
108    &EAS_Wave_Parser,
109#endif
110
111#ifdef _SMAF_PARSER
112    &EAS_SMAF_Parser,
113#endif
114
115#ifdef _OTA_PARSER
116    &EAS_OTA_Parser,
117#endif
118
119#ifdef _IMELODY_PARSER
120    &EAS_iMelody_Parser,
121#endif
122
123#ifdef _RTTTL_PARSER
124    &EAS_RTTTL_Parser,
125#endif
126
127#if defined (_CMX_PARSER) || defined(_MFI_PARSER)
128    &EAS_CMF_Parser
129#endif
130};
131#define NUM_PARSER_MODULES (sizeof(parserModules) / sizeof(EAS_VOID_PTR))
132
133/*----------------------------------------------------------------------------
134 * Data Modules
135 *----------------------------------------------------------------------------
136*/
137
138#ifdef _STATIC_MEMORY
139extern EAS_VOID_PTR eas_SMFData;
140extern EAS_VOID_PTR eas_Data;
141extern EAS_VOID_PTR eas_MixBuffer;
142extern EAS_VOID_PTR eas_Synth;
143extern EAS_VOID_PTR eas_MIDI;
144extern EAS_VOID_PTR eas_PCMData;
145extern EAS_VOID_PTR eas_MIDIData;
146
147#ifdef _XMF_PARSER
148extern EAS_VOID_PTR eas_XMFData;
149#endif
150
151#ifdef _SMAF_PARSER
152extern EAS_VOID_PTR eas_SMAFData;
153#endif
154
155#ifdef _OTA_PARSER
156extern EAS_VOID_PTR eas_OTAData;
157#endif
158
159#ifdef _IMELODY_PARSER
160extern EAS_VOID_PTR eas_iMelodyData;
161#endif
162
163#ifdef _RTTTL_PARSER
164extern EAS_VOID_PTR eas_RTTTLData;
165#endif
166
167#ifdef _WAVE_PARSER
168extern EAS_VOID_PTR eas_WaveData;
169#endif
170
171#if defined (_CMX_PARSER) || defined(_MFI_PARSER)
172extern EAS_VOID_PTR eas_CMFData;
173#endif
174#endif
175
176/*----------------------------------------------------------------------------
177 *
178 * Effects Modules
179 *
180 * These declarations are used by the EAS library to locate
181 * effects modules.
182 *----------------------------------------------------------------------------
183*/
184
185#ifdef _ENHANCER_ENABLED
186extern EAS_VOID_PTR                 EAS_Enhancer;
187#define EAS_ENHANCER_INTERFACE      &EAS_Enhancer
188#ifdef _STATIC_MEMORY
189extern EAS_VOID_PTR                 eas_EnhancerData;
190#define EAS_ENHANCER_DATA           &eas_EnhancerData
191#else
192#define EAS_ENHANCER_DATA           NULL
193#endif
194#else
195#define EAS_ENHANCER_INTERFACE      NULL
196#define EAS_ENHANCER_DATA           NULL
197#endif
198
199#ifdef _COMPRESSOR_ENABLED
200extern EAS_VOID_PTR                 EAS_Compressor;
201#define EAS_COMPRESSOR_INTERFACE    &EAS_Compressor
202#ifdef _STATIC_MEMORY
203extern EAS_VOID_PTR                 eas_CompressorData;
204#define EAS_COMPRESSOR_DATA         &eas_CompressorData
205#else
206#define EAS_COMPRESSOR_DATA         NULL
207#endif
208#else
209#define EAS_COMPRESSOR_INTERFACE    NULL
210#define EAS_COMPRESSOR_DATA         NULL
211#endif
212
213#ifdef _MAXIMIZER_ENABLED
214extern EAS_VOID_PTR                 EAS_Maximizer;
215#define EAS_MAXIMIZER_INTERFACE     &EAS_Maximizer
216#ifdef _STATIC_MEMORY
217extern EAS_VOID_PTR                 eas_MaximizerData;
218#define EAS_MAXIMIZER_DATA          &eas_MaximizerData
219#else
220#define EAS_MAXIMIZER_DATA          NULL
221#endif
222#else
223#define EAS_MAXIMIZER_INTERFACE NULL
224#define EAS_MAXIMIZER_DATA          NULL
225#endif
226
227
228#ifdef _REVERB_ENABLED
229extern EAS_VOID_PTR                 EAS_Reverb;
230#define EAS_REVERB_INTERFACE        &EAS_Reverb
231#ifdef _STATIC_MEMORY
232extern EAS_VOID_PTR                 eas_ReverbData;
233#define EAS_REVERB_DATA             &eas_ReverbData
234#else
235#define EAS_REVERB_DATA             NULL
236#endif
237#else
238#define EAS_REVERB_INTERFACE        NULL
239#define EAS_REVERB_DATA             NULL
240#endif
241
242#ifdef _CHORUS_ENABLED
243extern EAS_VOID_PTR                 EAS_Chorus;
244#define EAS_CHORUS_INTERFACE        &EAS_Chorus
245#ifdef _STATIC_MEMORY
246extern EAS_VOID_PTR                 eas_ChorusData;
247#define EAS_CHORUS_DATA             &eas_ChorusData
248#else
249#define EAS_CHORUS_DATA             NULL
250#endif
251#else
252#define EAS_CHORUS_INTERFACE        NULL
253#define EAS_CHORUS_DATA             NULL
254#endif
255
256#ifdef _WIDENER_ENABLED
257extern EAS_VOID_PTR                 EAS_Widener;
258#define EAS_WIDENER_INTERFACE       &EAS_Widener
259#ifdef _STATIC_MEMORY
260extern EAS_VOID_PTR                 eas_WidenerData;
261#define EAS_WIDENER_DATA            &eas_WidenerData
262#else
263#define EAS_WIDENER_DATA            NULL
264#endif
265#else
266#define EAS_WIDENER_INTERFACE       NULL
267#define EAS_WIDENER_DATA            NULL
268#endif
269
270#ifdef _GRAPHIC_EQ_ENABLED
271extern EAS_VOID_PTR                 EAS_GraphicEQ;
272#define EAS_GRAPHIC_EQ_INTERFACE    &EAS_GraphicEQ
273#ifdef _STATIC_MEMORY
274extern EAS_VOID_PTR                 eas_GraphicEQData;
275#define EAS_GRAPHIC_EQ_DATA         &eas_GraphicEQData
276#else
277#define EAS_GRAPHIC_EQ_DATA         NULL
278#endif
279#else
280#define EAS_GRAPHIC_EQ_INTERFACE    NULL
281#define EAS_GRAPHIC_EQ_DATA         NULL
282#endif
283
284#ifdef _WOW_ENABLED
285extern EAS_VOID_PTR                 EAS_Wow;
286#define EAS_WOW_INTERFACE           &EAS_Wow
287#ifdef _STATIC_MEMORY
288#error "WOW module requires dynamic memory model"
289#else
290#define EAS_WOW_DATA                NULL
291#endif
292#else
293#define EAS_WOW_INTERFACE           NULL
294#define EAS_WOW_DATA                NULL
295#endif
296
297#ifdef _TONECONTROLEQ_ENABLED
298extern EAS_VOID_PTR                 EAS_ToneControlEQ;
299#define EAS_TONECONTROLEQ_INTERFACE &EAS_ToneControlEQ
300#ifdef _STATIC_MEMORY
301extern EAS_VOID_PTR                 eas_ToneControlEQData;
302#define EAS_TONECONTROLEQ_DATA      &eas_ToneControlEQData
303#else
304#define EAS_TONECONTROLEQ_DATA      NULL
305#endif
306#else
307#define EAS_TONECONTROLEQ_INTERFACE NULL
308#define EAS_TONECONTROLEQ_DATA      NULL
309#endif
310
311/*lint -e{605} not pretty, but it works */
312EAS_VOID_PTR const effectsModules[] =
313{
314    EAS_ENHANCER_INTERFACE,
315    EAS_COMPRESSOR_INTERFACE,
316    EAS_REVERB_INTERFACE,
317    EAS_CHORUS_INTERFACE,
318    EAS_WIDENER_INTERFACE,
319    EAS_GRAPHIC_EQ_INTERFACE,
320    EAS_WOW_INTERFACE,
321    EAS_MAXIMIZER_INTERFACE,
322    EAS_TONECONTROLEQ_INTERFACE
323};
324
325EAS_VOID_PTR const effectsData[] =
326{
327    EAS_ENHANCER_DATA,
328    EAS_COMPRESSOR_DATA,
329    EAS_REVERB_DATA,
330    EAS_CHORUS_DATA,
331    EAS_WIDENER_DATA,
332    EAS_GRAPHIC_EQ_DATA,
333    EAS_WOW_DATA,
334    EAS_MAXIMIZER_DATA,
335    EAS_TONECONTROLEQ_DATA
336};
337
338/*----------------------------------------------------------------------------
339 *
340 * Optional Modules
341 *
342 * These declarations are used by the EAS library to locate
343 * effects modules.
344 *----------------------------------------------------------------------------
345*/
346
347#ifdef _METRICS_ENABLED
348extern EAS_VOID_PTR                 EAS_Metrics;
349#define EAS_METRICS_INTERFACE       &EAS_Metrics
350#ifdef _STATIC_MEMORY
351extern EAS_VOID_PTR                 eas_MetricsData;
352#define EAS_METRICS_DATA            &eas_MetricsData
353#else
354#define EAS_METRICS_DATA            NULL
355#endif
356#else
357#define EAS_METRICS_INTERFACE       NULL
358#define EAS_METRICS_DATA            NULL
359#endif
360
361#ifdef MMAPI_SUPPORT
362extern EAS_VOID_PTR                 EAS_TC_Parser;
363#define EAS_TONE_CONTROL_PARSER     &EAS_TC_Parser
364#ifdef _STATIC_MEMORY
365extern EAS_VOID_PTR                 eas_TCData;
366#define EAS_TONE_CONTROL_DATA       &eas_TCData
367#else
368#define EAS_TONE_CONTROL_DATA       NULL
369#endif
370#else
371#define EAS_TONE_CONTROL_PARSER     NULL
372#define EAS_TONE_CONTROL_DATA       NULL
373#endif
374
375/*lint -e{605} not pretty, but it works */
376EAS_VOID_PTR const optionalModules[] =
377{
378    EAS_TONE_CONTROL_PARSER,
379    EAS_METRICS_INTERFACE
380};
381
382EAS_VOID_PTR const optionalData[] =
383{
384    EAS_TONE_CONTROL_DATA,
385    EAS_METRICS_DATA
386};
387
388/*----------------------------------------------------------------------------
389 * EAS_CMStaticMemoryModel()
390 *----------------------------------------------------------------------------
391 * Purpose:
392 * This function returns true if EAS has been configured for
393 * a static memory model. There are some limitations in the
394 * static memory model, see the documentation for more
395 * information.
396 *
397 * Outputs:
398 *  returns EAS_TRUE if a module is found
399 *----------------------------------------------------------------------------
400*/
401EAS_BOOL EAS_CMStaticMemoryModel (void)
402{
403#ifdef _STATIC_MEMORY
404    return EAS_TRUE;
405#else
406    return EAS_FALSE;
407#endif
408}
409
410/*----------------------------------------------------------------------------
411 * EAS_CMEnumModules()
412 *----------------------------------------------------------------------------
413 * Purpose:
414 * This function is used to find pointers to optional modules.
415 *
416 * Inputs:
417 *  module          - module number
418 *
419 * Outputs:
420 *  returns a pointer to the module function table or NULL if no module
421 *----------------------------------------------------------------------------
422*/
423EAS_VOID_PTR EAS_CMEnumModules (EAS_INT module)
424{
425
426    if (module >= (EAS_INT) NUM_PARSER_MODULES)
427        return NULL;
428    return parserModules[module];
429}
430
431/*----------------------------------------------------------------------------
432 * EAS_CMEnumData()
433 *----------------------------------------------------------------------------
434 * Purpose:
435 * This function is used to find pointers to static memory allocations.
436 *
437 * Inputs:
438 *  dataModule          - enumerated module number
439 *
440 * Outputs:
441 * Returns handle to data or NULL if not found
442 *----------------------------------------------------------------------------
443*/
444/*lint -esym(715, dataModule) used only when _STATIC_MEMORY is defined */
445EAS_VOID_PTR EAS_CMEnumData (EAS_INT dataModule)
446{
447
448#ifdef _STATIC_MEMORY
449    switch (dataModule)
450    {
451
452    /* main instance data for synthesizer */
453    case EAS_CM_EAS_DATA:
454        return &eas_Data;
455
456    /* mix buffer for mix engine */
457    case EAS_CM_MIX_BUFFER:
458        /*lint -e{545} lint doesn't like this because it sees the underlying type */
459        return &eas_MixBuffer;
460
461    /* instance data for synth */
462    case EAS_CM_SYNTH_DATA:
463        return &eas_Synth;
464
465    /* instance data for MIDI parser */
466    case EAS_CM_MIDI_DATA:
467        return &eas_MIDI;
468
469    /* instance data for SMF parser */
470    case EAS_CM_SMF_DATA:
471        return &eas_SMFData;
472
473#ifdef _XMF_PARSER
474    /* instance data for XMF parser */
475    case EAS_CM_XMF_DATA:
476        return &eas_XMFData;
477#endif
478
479#ifdef _SMAF_PARSER
480    /* instance data for SMAF parser */
481    case EAS_CM_SMAF_DATA:
482        return &eas_SMAFData;
483#endif
484
485    /* instance data for the PCM engine */
486    case EAS_CM_PCM_DATA:
487        /*lint -e{545} lint doesn't like this because it sees the underlying type */
488        return &eas_PCMData;
489
490    case EAS_CM_MIDI_STREAM_DATA:
491        return &eas_MIDIData;
492
493#ifdef _OTA_PARSER
494    /* instance data for OTA parser */
495    case EAS_CM_OTA_DATA:
496        return &eas_OTAData;
497#endif
498
499#ifdef _IMELODY_PARSER
500    /* instance data for iMelody parser */
501    case EAS_CM_IMELODY_DATA:
502        return &eas_iMelodyData;
503#endif
504
505#ifdef _RTTTL_PARSER
506    /* instance data for RTTTL parser */
507    case EAS_CM_RTTTL_DATA:
508        return &eas_RTTTLData;
509#endif
510
511#ifdef _WAVE_PARSER
512    /* instance data for WAVE parser */
513    case EAS_CM_WAVE_DATA:
514        return &eas_WaveData;
515#endif
516
517#if defined (_CMX_PARSER) || defined(_MFI_PARSER)
518    /* instance data for CMF parser */
519    case EAS_CM_CMF_DATA:
520        return &eas_CMFData;
521#endif
522
523    default:
524        return NULL;
525    }
526
527#else
528    return NULL;
529#endif
530}
531
532/*----------------------------------------------------------------------------
533 * EAS_CMEnumFXModules()
534 *----------------------------------------------------------------------------
535 * Purpose:
536 * This function is used to find pointers to optional effects modules.
537 *
538 * Inputs:
539 *  module          - enumerated module number
540 *  pModule         - pointer to module interface
541 *
542 * Outputs:
543 *  Returns pointer to function table or NULL if not found
544 *----------------------------------------------------------------------------
545*/
546EAS_VOID_PTR EAS_CMEnumFXModules (EAS_INT module)
547{
548
549    if (module >= NUM_EFFECTS_MODULES)
550        return NULL;
551    return effectsModules[module];
552}
553
554/*----------------------------------------------------------------------------
555 * EAS_CMEnumFXData()
556 *----------------------------------------------------------------------------
557 * Purpose:
558 * This function is used to find pointers to static memory allocations.
559 *
560 * Inputs:
561 *  dataModule          - enumerated module number
562 *  pData               - pointer to handle variable
563 *
564 * Outputs:
565 * Returns handle to data or NULL if not found
566 *----------------------------------------------------------------------------
567*/
568EAS_VOID_PTR EAS_CMEnumFXData (EAS_INT dataModule)
569{
570
571    if (dataModule >= NUM_EFFECTS_MODULES)
572        return NULL;
573    return effectsData[dataModule];
574}
575
576/*----------------------------------------------------------------------------
577 * EAS_CMEnumOptModules()
578 *----------------------------------------------------------------------------
579 * Purpose:
580 * This function is used to find pointers to optional modules.
581 *
582 * Inputs:
583 *  module          - enumerated module number
584 *
585 * Outputs:
586 *  returns pointer to function table or NULL if no module
587 *----------------------------------------------------------------------------
588*/
589EAS_VOID_PTR EAS_CMEnumOptModules (EAS_INT module)
590{
591
592    /* sanity check */
593    if (module >= NUM_OPTIONAL_MODULES)
594        return EAS_FALSE;
595    return optionalModules[module];
596}
597
598/*----------------------------------------------------------------------------
599 * EAS_CMEnumOptData()
600 *----------------------------------------------------------------------------
601 * Purpose:
602 * This function is used to find pointers to static memory allocations.
603 *
604 * Inputs:
605 *  dataModule          - enumerated module number
606 *
607 * Outputs:
608 * Returns handle to data or NULL if not found
609 *----------------------------------------------------------------------------
610*/
611EAS_VOID_PTR EAS_CMEnumOptData (EAS_INT dataModule)
612{
613
614    if (dataModule >= NUM_OPTIONAL_MODULES)
615        return NULL;
616    return optionalData[dataModule];
617}
618
619
620