File: musserver.h

package info (click to toggle)
lxmusserv 0.94-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 176 kB
  • ctags: 189
  • sloc: ansic: 1,530; makefile: 73
file content (142 lines) | stat: -rw-r--r-- 4,852 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*************************************************************************
 *  musserver.h
 *
 *  update to lxdoom
 *  Copyright (C) 1999 Rafael Reilova (rreilova@ececs.uc.edu)
 *
 *  Original code
 *  Copyright (C) 1995 Michael Heasley (mheasley@hmc.edu)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *************************************************************************/

#ifdef __linux__
#  include <sys/soundcard.h>
#  include <linux/version.h>
/* Seems AWE began to work on 2.1.64 */
#  if (LINUX_VERSION_CODE > 131392)
#    define ENABLE_AWE
#    include <linux/awe_voice.h>
#  endif
#elif defined(__FreeBSD__)
#  include <machine/soundcard.h>
#  include <awe_voice.h>
#endif

extern char *progname;
extern int verbose;
extern int unknevents;
extern int timer_res;          /* sequencer timer resolution (tics/sec) */
extern int curtime;            /* current song time in sequencer tics   */
extern int voxware_octave_bug; /* increase octave by 1 when using FM    */
extern int dumpmus;            /* dump to disk music and FM-patches     */

#define DFL_VOL 12      /* default volume when standalone 1-15 (0 == off) */
#define CLEAN_EXIT   0
#define IO_ERROR     1
#define MISC_ERROR   2  /* doesn't call perror() */

#define MUS_LOOP     1
#define MUS_NOLOOP   0
#define MUS_NEWSONG  1
#define MUS_SAMESONG 0

#define NO_PATCH_NEEDED 0
#define PATCH_NEEDED    1

/* number of instruments   */
#define N_INTR          175
/* number of MIDI channels */
#define N_CHN            16


typedef char (instr_nam)[32];

/*
 * Note: gcc attribute "packed" is used to make sure the compiler doesn't
 * try to optimize the structures by aligning elements to word boundaries, etc.
 */

struct OPL2instrument {
  unsigned char trem_vibr_1;    /* OP 1: tremolo/vibrato/sustain/KSR/multi */
  unsigned char att_dec_1;      /* OP 1: attack rate/decay rate */
  unsigned char sust_rel_1;     /* OP 1: sustain level/release rate */
  unsigned char wave_1;         /* OP 1: waveform select */
  unsigned char scale_1;        /* OP 1: key scale level */
  unsigned char level_1;        /* OP 1: output level */
  unsigned char feedback;       /* feedback/AM-FM (both operators) */
  unsigned char trem_vibr_2;    /* OP 2: tremolo/vibrato/sustain/KSR/multi */
  unsigned char att_dec_2;      /* OP 2: attack rate/decay rate */
  unsigned char sust_rel_2;     /* OP 2: sustain level/release rate */
  unsigned char wave_2;         /* OP 2: waveform select */
  unsigned char scale_2;        /* OP 2: key scale level */
  unsigned char level_2;        /* OP 2: output level */
  unsigned char unused;
  short         basenote;       /* base note offset */
} __attribute__ ((packed));


struct opl_instr {
	unsigned short        flags;
#define FL_FIXED_PITCH  0x0001          // note has fixed pitch (drum note)
#define FL_UNKNOWN      0x0002          // ??? (used in instrument #65 only)
#define FL_DOUBLE_VOICE 0x0004          // use two voices instead of one

	unsigned char         finetune;
	unsigned char         note;
	struct OPL2instrument patchdata[2];
} __attribute__ ((packed));


typedef struct OPLfile {
     unsigned char     id[8];
     struct opl_instr *opl_instruments;
     instr_nam        *instrument_nam;
} OPLFILE;


struct MUSheader {
	char           id[4];          // identifier "MUS" 0x1A
	unsigned short scoreLen;
	unsigned short scoreStart;
	unsigned short channels;       // count of primary channels
	unsigned short sec_channels;   // count of secondary channels
	unsigned short instrCnt;
	unsigned short dummy;
} __attribute__ ((packed));


typedef struct MUSfile {
	struct MUSheader  header;
        unsigned short   *instr_pnum;
	unsigned char    *musdata;
} MUSFILE;

typedef enum  {
  USE_AWE_SYNTH, USE_MIDI_SYNTH, USE_FM_SYNTH,
  USE_BEST_SYNTH, LIST_ONLY_SYNTH
} synthdev_t;

typedef enum {
  MIDI_START, MIDI_STOP, MIDI_PAUSE, MIDI_RESUME
} mid_timer_t;


extern void cleanup(int status, const char *msg) __attribute__ ((noreturn));
extern void mark_nonblock (void);
extern void mark_block (void);
extern const MUSFILE *readmus(FILE *fp);
extern const OPLFILE *read_genmidi(FILE *fp);
extern int playmus(const struct MUSfile *mus, int newsong, int looping);