]> 4ch.mooo.com Git - 16.git/blob - src/lib/opl2.h
5c0a1cfb7e7b8e0dd818cca9c3d78099f733c5ed
[16.git] / src / lib / opl2.h
1 #ifndef _DOSLIB_SND_H_\r
2 #define _DOSLIB_SND_H_\r
3 /* C Header File: ADLIB *****************************************************\r
4 \r
5 Author:   Kevin A. Lee\r
6 \r
7 Last Amended: 27th April, 1993\r
8 \r
9 Description:    Low-level interface to the Adlib (or compatible)\r
10     FM sound card. All information gleaned from\r
11     Jeffrey S. Lee's "Programming the Adlib/Sound\r
12     Blaster FM Music Chips". See Lee's document for\r
13     further information.\r
14 \r
15 Compiled succesfully under Turbo C, Borland C++,\r
16 and Microsoft Quick C (all latest versions).\r
17 \r
18 ****************************************************************************/\r
19 #include "src\lib\lib_com.h"\r
20 \r
21 #define NUMVOICE 11\r
22 #define FACTOR  1193180\r
23 #define OCTAVE  4
24 \r
25 #define MIN_REGISTER                    0x01\r
26 #define MAX_REGISTER                    0xF5\r
27 #define ADLIB_FM_ADDRESS        0x388   /* adlib address/status register */\r
28 #define ADLIB_FM_DATA           0x389   /* adlib data register           */\r
29 \r
30 /*\r
31 static int percussiveMode = 0,currentBDContents = 0;\r
32 //static int opTable[18] = {0,1,2,3,4,5,8,9,10,11,12,13,16,17,18,19,20,21};\r
33 static int voiceModulator[11] = {0,1,2,6,7,8,12,16,14,17,13};\r
34 static int voiceCarrier[9] = {3,4,5,9,10,11,15,16,17};\r
35 */\r
36 \r
37 /*\r
38 * FM Instrument definition for .SBI files - SoundBlaster instrument\r
39 * - these are the important parts - we will skip the header, but since\r
40 *   I am not sure where it starts and ends so I have had to guess.\r
41 *   However it SEEMS! to work. Each array has two values, one for\r
42 *   each operator.\r
43 */\r
44 typedef struct{\r
45         byte SoundCharacteristic[2];    /* modulator frequency multiple...  */\r
46         byte Level[2];                  /* modulator frequency level...     */\r
47         byte AttackDecay[2];            /* modulator attack/decay...        */\r
48         byte SustainRelease[2];         /* modulator sustain/release...     */\r
49         byte WaveSelect[2];             /* output waveform distortion       */\r
50         byte Feedback;                  /* feedback algorithm and strength  */\r
51 } FMInstrument;\r
52 \r
53 /*\r
54 * Enumerated F-Numbers (in octave 4) for the chromatic scale.\r
55 */\r
56 /*enum oct{\r
57         B4 = 493.88,\r
58         B4b = 466.16,\r
59         A4 = 440,\r
60         A4b = 415.3,\r
61         G4 = 392,\r
62         G4b = 369.99,\r
63         F4 = 349.23,\r
64         E4 = 329.63,\r
65         E4b = 311.13,\r
66         D4 = 293.66,\r
67         D4b = 277.18,\r
68         C4 = 261.63,\r
69         A0 = 27.50\r
70 };*/\r
71 enum SCALE{\r
72         B4  = 0x1EE,\r
73         B4b = 0x1D2,\r
74         A4  = 440,\r
75         A4b = 0x19F,\r
76         G4 = 0x188,\r
77         G4b  = 0x172,\r
78         F4  = 0x15D,\r
79         E4  = 0x14A,\r
80         E4b  = 0x137,\r
81         D4  = 0x126,\r
82         D4b = 0x115,\r
83         C4  = 0x106,\r
84         A0 = 0x7F2\r
85 };
86 \r
87 /* function prototyping */\r
88 void WriteFM(int reg, int value);\r
89 int ReadFM(void);\r
90 int AdlibExists(void);\r
91 void FMReset(/*int percusiveMode*/);    /* Resets the card, quiets all voices, sets the percussive mode state */\r
92 void FMKeyOff(int voice);\r
93 void FMKeyOn(int voice, int freq, int octave);\r
94 void FMVoiceVolume(int voice, int vol);\r
95 void FMSetVoice(int voiceNum, FMInstrument *ins);\r
96 /* Remember: percussion instruments must be assigned only to the correct voice number. */\r
97 //void FMSetPercusiveMode(int state);\r
98 //int  LoadSBI(char filename[], FMInstrument *ins);\r
99 void fmtest(void);
100 int soundtest();\r
101 #endif/*_DOSLIB_SND_H_*/