eas_fmsynth.h revision 56c99cd2c2c1e6ab038dac5fced5b92ccf11ff6c
1/*----------------------------------------------------------------------------
2 *
3 * File:
4 * eas_fmsynth.h
5 *
6 * Contents and purpose:
7 * Implements the FM synthesizer functions.
8 *
9 * Copyright Sonic Network Inc. 2004
10
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 *
15 *      http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 *
23 *----------------------------------------------------------------------------
24 * Revision Control:
25 *   $Revision: 90 $
26 *   $Date: 2006-07-11 20:18:13 -0700 (Tue, 11 Jul 2006) $
27 *----------------------------------------------------------------------------
28*/
29
30#ifndef fmsynthH
31#define fmsynthH
32
33#include "eas_data.h"
34
35#if defined (_FM_SYNTH)
36
37/* FM envelope state */
38typedef enum {
39    eFMEnvelopeStateAttack = 0,
40    eFMEnvelopeStateDecay,
41    eFMEnvelopeStateSustain,
42    eFMEnvelopeStateRelease,
43    eFMEnvelopeStateMuted,
44    eFMEnvelopeStateInvalid         /* should never be in this state! */
45} E_FM_ENVELOPE_STATE;
46
47/*------------------------------------
48 * S_OPERATOR data structure
49 *------------------------------------
50*/
51typedef struct s_operator_tag
52{
53    EAS_I16     pitch;              /* operator pitch in cents */
54    EAS_U16     envGain;            /* envelope target */
55    EAS_I16     baseGain;           /* patch gain (inc. vel & key scale) */
56    EAS_U16     outputGain;         /* current output gain */
57    EAS_U16     envRate;            /* calculated envelope rate */
58    EAS_U8      envState;           /* envelope state */
59    EAS_U8      pad;                /* pad to 16-bits */
60} S_OPERATOR;
61#endif
62
63typedef struct s_fm_voice_tag
64{
65    S_OPERATOR          oper[4];        /* operator data */
66    EAS_I16             voiceGain;      /* LFO + channel parameters */
67    EAS_U16             lfoPhase;       /* LFO current phase */
68    EAS_I16             lfoValue;       /* LFO current value */
69    EAS_U16             lfoDelay;       /* keeps track of elapsed delay time */
70    EAS_I8              pan;            /* stereo pan value (-64 to +64) */
71    EAS_I8              pad;            /* reserved to maintain alignment */
72} S_FM_VOICE;
73
74#ifdef _FM_EDITOR
75extern S_FM_REGION newPatch;
76extern S_FM_REGION OriginalPatch;
77#endif
78
79extern EAS_U32 freqTable[];
80
81#endif
82