_al_midi.h
1 /* 2 Copyright (C) 1994-1995 Apogee Software, Ltd. 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 */ 20 #ifndef ___AL_MIDI_H 21 #define ___AL_MIDI_H 22 23 #include <inttypes.h> 24 #include "_midi.h" 25 26 #define lobyte(num) ((uint32_t)*((char *)&(num))) 27 #define hibyte(num) ((uint32_t)*(((char *)&(num)) + 1)) 28 29 #define AL_MaxVolume 127 30 #define AL_DefaultChannelVolume 90 31 #define AL_DefaultPitchBendRange 200 32 #define AL_VoiceNotFound -1 33 34 #define ADLIB_PORT 0x388 35 36 /* Number of slots for the voices on the chip */ 37 #define AL_NumChipSlots 18 38 39 #define NUMADLIBVOICES 9 40 #define NUMADLIBCHANNELS 16 41 42 #define NOTE_ON 0x2000 /* Used to turn note on or toggle note */ 43 #define NOTE_OFF 0x0000 44 45 #define MAX_VELOCITY 0x7f 46 #define MAX_OCTAVE 7 47 #define MAX_NOTE (MAX_OCTAVE * 12 + 11) 48 #define FINETUNE_MAX 31 49 #define FINETUNE_RANGE (FINETUNE_MAX + 1) 50 51 #define PITCHBEND_CENTER 1638400 52 53 typedef struct AdLibVoice 54 { 55 struct AdLibVoice *next; 56 struct AdLibVoice *prev; 57 58 uint32_t num; 59 uint32_t key; 60 uint32_t velocity; 61 uint32_t channel; 62 uint32_t pitchleft; 63 uint32_t pitchright; 64 int timbre; 65 int port; 66 uint32_t status; 67 } AdLibVoice; 68 69 typedef struct 70 { 71 AdLibVoice *start; 72 AdLibVoice *end; 73 } AdLibVoiceList; 74 75 typedef struct 76 { 77 AdLibVoiceList Voices; 78 79 int Timbre; 80 int Pitchbend; 81 int KeyOffset; 82 uint32_t KeyDetune; 83 uint32_t Volume; 84 uint32_t EffectiveVolume; 85 int Pan; 86 int Detune; 87 uint32_t RPN; 88 int16_t PitchBendRange; 89 int16_t PitchBendSemiTones; 90 int16_t PitchBendHundreds; 91 } AdLibChannel; 92 93 static int AL_Init(void); 94 static void AL_NoteOff(int channel, int key, int velocity); 95 static void AL_NoteOn(int channel, int key, int vel); 96 static void AL_ControlChange(int channel, int type, int data); 97 static void AL_ProgramChange(int channel, int patch); 98 static void AL_SetPitchBend(int channel, int lsb, int msb); 99 static void AL_SetVolume(int volume); 100 101 #endif