1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // $Id: musserver.h 1294 2017-01-19 15:18:29Z wesleyjohnson $ 5 // 6 // Copyright (C) 1995-1996 Michael Heasley (mheasley@hmc.edu) 7 // GNU General Public License 8 // Portions Copyright (C) 1996-2016 by DooM Legacy Team. 9 // GNU General Public License 10 // Heavily modified for use with Doom Legacy. 11 // Removed wad search and Doom version dependencies. 12 // Is now dependent upon IPC msgs from the Doom program 13 // for all wad information, and the music lump id. 14 15 /************************************************************************* 16 * musserver.h 17 * 18 * Copyright (C) 1995 Michael Heasley (mheasley@hmc.edu) 19 * 20 * This program is free software; you can redistribute it and/or modify 21 * it under the terms of the GNU General Public License as published by 22 * the Free Software Foundation; either version 2 of the License, or 23 * (at your option) any later version. 24 * 25 * This program is distributed in the hope that it will be useful, 26 * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 * GNU General Public License for more details. 29 * 30 * You should have received a copy of the GNU General Public License 31 * along with this program; if not, write to the Free Software 32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 33 *************************************************************************/ 34 35 #ifndef MUSSERVER_H 36 37 38 /**************************************************/ 39 /* User-configurable parameters: program defaults */ 40 /**************************************************/ 41 42 43 /************************************************************************* 44 * Change this to your preferred default playback device: external midi, * 45 * FM synth, or AWE32 synth * 46 *************************************************************************/ 47 48 /* #define DEFAULT_EXT_MIDI */ 49 #define DEFAULT_FM_SYNTH 50 /* #define DEFAULT_AWE32_SYNTH */ 51 52 53 /************************************************************************ 54 * To compile in support for AWE32 synth (requires AWE32 kernel driver, * 55 * see README) regardless of the default playback device, define the * 56 * following * 57 ************************************************************************/ 58 59 /* #define AWE32_SYNTH_SUPPORT */ 60 61 62 /*************************************************************************** 63 * If you normally need the -u command-line switch to specify a particular * 64 * device type, uncomment this line and change the type as needed * 65 ***************************************************************************/ 66 67 /* #define DEFAULT_TYPE 8 */ 68 69 70 // A unique key for getting the right queue. 71 #define MUSSERVER_MSG_KEY ((key_t)53075) 72 73 /************************************/ 74 /* End of user-configurable section */ 75 /************************************/ 76 77 78 #ifdef DEFAULT_AWE32_SYNTH 79 # define AWE32_SYNTH_SUPPORT 80 #endif 81 82 #ifdef linux 83 # include <sys/soundcard.h> 84 # ifdef AWE32_SYNTH_SUPPORT 85 # include <linux/awe_voice.h> 86 # endif 87 #elif defined(SCOOS5) || defined(SCOUW2) || defined(SCOUW7) 88 # include <sys/soundcard.h> 89 # ifdef AWE32_SYNTH_SUPPORT 90 # include <sys/awe_voice.h> 91 # endif 92 #elif defined(__FreeBSD__) 93 # include <machine/soundcard.h> 94 # ifdef AWE32_SYNTH_SUPPORT 95 # include <awe_voice.h> 96 # endif 97 #endif 98 99 #define MUS_VERSION "1.4_DoomLegacy" 100 101 #include <stdint.h> 102 #include "doomtype.h" 103 // byte 104 //typedef unsigned char byte; 105 #include "doomdef.h" 106 // MAX_WADPATH 107 108 // Length of mtext, which now includes a directory/filename. 109 #define MUS_MSG_MTEXT_LENGTH MAX_WADPATH 110 // This message structure is dictated by message operations msgrcv, msgsnd. 111 typedef struct 112 { 113 long mtype; /* type of received/sent message */ 114 char mtext[MUS_MSG_MTEXT_LENGTH]; /* text of the message */ 115 } mus_msg_t; 116 117 #if __GNUC_PREREQ(2,2) 118 // Since glibc 2.2 this parameter has been void* as required by SUSv2 an SUSv3. 119 # define MSGBUF(x) ((void*)&(x)) 120 #else 121 // Previous to glib 2.2 122 # define MSGBUF(x) ((struct msgbuf*)&(x)) 123 #endif 124 125 126 127 typedef struct { 128 uint16_t flags; 129 byte finetune; 130 byte note; 131 sbi_instr_data patchdata; 132 } opl_instr_t; 133 134 typedef struct { 135 int32_t note; 136 int32_t channel; 137 } synth_voice_t; 138 139 140 // Device types 141 typedef enum { 142 DVT_DEFAULT, // preset default device 143 DVT_SEARCH1, 144 DVT_SEARCH2, 145 DVT_SEARCH3, 146 DVT_MIDI, // TIMIDITY, FLUIDSYNTH, then EXT_MIDI 147 DVT_TIMIDITY, 148 DVT_FLUIDSYNTH, 149 DVT_EXT_MIDI, 150 DVT_SYNTH, // synth devices 151 DVT_FM_SYNTH, 152 DVT_AWE32_SYNTH, 153 DVT_DEV6, 154 DVT_DEV7, 155 DVT_DEV8, 156 DVT_DEV9, 157 DVT_LIST, 158 } dvtype_e; 159 160 // music play state, set by IPC messages 161 typedef enum { 162 PLAY_OFF, 163 PLAY_START, 164 PLAY_RUNNING, 165 PLAY_PAUSE, 166 PLAY_STOP, 167 PLAY_RESTART, 168 PLAY_QUITMUS 169 } play_e; 170 171 #define TERMINATED 0xFFFFF 172 173 typedef struct { 174 char * wad_name; // malloc 175 int lumpnum; 176 byte state; // play_e 177 } music_wad_t; 178 179 typedef struct { 180 uint32_t filepos; // position in file 181 uint32_t size; // music data size 182 byte * data; // music data, malloc 183 } music_data_t; 184 185 // from IPC message 186 extern char * option_string; 187 188 extern music_wad_t music_lump; 189 extern music_wad_t genmidi_lump; 190 191 extern byte option_pending; // msg has set the option string 192 extern byte continuous_looping; 193 extern byte music_paused; 194 extern byte verbose; 195 extern byte changevol_allowed; 196 extern byte parent_check; // check parent process 197 extern byte no_devices_exit; 198 extern char parent_proc[32]; // parent process /proc/num 199 200 extern int queue_size; 201 int queue_free( void ); 202 203 204 // Music midi timer. 205 typedef enum { MMT_START, MMT_STOP, MMT_CONT } mmt_e; 206 // action : mmt_e 207 void midi_timer(int action); 208 209 void all_off_midi(void); 210 void pause_midi(void); 211 void reset_midi(void); 212 void midi_wait(uint32_t wtime); 213 214 void seqbuf_dump(void); 215 void note_off(int note, int channel, int volume); 216 void note_on(int note, int channel, int volume); 217 void pitch_bend(int channel, int value); 218 void control_change(int controller, int channel, int value); 219 void patch_change(int patch, int channel); 220 void vol_change(int volume); 221 222 void playmus(music_data_t * music_data, byte check_msg); 223 224 extern int qid; // IPC message queue id 225 226 enum{ MSG_NOWAIT=0, MSG_WAIT=1 }; 227 // wait_flag : MSG_WAIT, MSG_NOWAIT 228 void get_mesg(byte wait_flag); 229 230 // Init, load, setup the selected device 231 void seq_midi_init_setup(int sel_dev, int dev_type, int port_num); 232 void cleanup_midi(void); 233 void list_devs(void); 234 235 // Wad read 236 // Read the GENMIDI lump from a wad. 237 // gen_wad : the wad name and lumpnum 238 void read_wad_genmidi( music_wad_t * gen_wad ); 239 240 // Return music size. 241 // music_wad : the wad name and lumpnum 242 // music_data : the music lump read 243 int read_wad_music( music_wad_t * music_wad, 244 /* OUT */ music_data_t * music_data ); 245 246 // Exit the program. 247 void cleanup_exit(int status, char * exit_msg); 248 #endif 249