1 /*
2 * include file for midi synthesizer interface.
3 *
4 * Copyright by Seigo Tanimura 1999.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: releng/5.0/sys/dev/sound/midi/midisynth.h 88773 2002-01-01 17:36:26Z tanimura $
28 *
29 */
30
31 #define SYNTH_MAX_VOICES 32
32
33 /* This is the voice allocation state for a synthesizer. */
34 struct voice_alloc_info {
35 int max_voice;
36 int used_voices;
37 int ptr; /* For device specific use */
38 u_short map[SYNTH_MAX_VOICES]; /* (ch << 8) | (note+1) */
39 int timestamp;
40 int alloc_times[SYNTH_MAX_VOICES];
41 };
42
43 /* This is the channel information for a synthesizer. */
44 struct channel_info {
45 int pgm_num;
46 int bender_value;
47 u_char controllers[128];
48 };
49
50 /* These are the function types for a midi synthesizer interface. */
51 typedef int (mdsy_killnote_t)(mididev_info *md, int chn, int note, int vel);
52 typedef int (mdsy_setinstr_t)(mididev_info *md, int chn, int instr);
53 typedef int (mdsy_startnote_t)(mididev_info *md, int chn, int note, int vel);
54 typedef int (mdsy_reset_t)(mididev_info *md);
55 typedef int (mdsy_hwcontrol_t)(mididev_info *md, u_char *event);
56 typedef int (mdsy_loadpatch_t)(mididev_info *md, int format, struct uio *buf, int offs, int count, int pmgr_flag);
57 typedef int (mdsy_panning_t)(mididev_info *md, int chn, int pan);
58 typedef int (mdsy_aftertouch_t)(mididev_info *md, int chn, int press);
59 typedef int (mdsy_controller_t)(mididev_info *md, int chn, int ctrlnum, int val);
60 typedef int (mdsy_patchmgr_t)(mididev_info *md, struct patmgr_info *rec);
61 typedef int (mdsy_bender_t)(mididev_info *md, int chn, int val);
62 typedef int (mdsy_allocvoice_t)(mididev_info *md, int chn, int note, struct voice_alloc_info *alloc);
63 typedef int (mdsy_setupvoice_t)(mididev_info *md, int voice, int chn);
64 typedef int (mdsy_sendsysex_t)(mididev_info *md, u_char *sysex, int len);
65 typedef int (mdsy_prefixcmd_t)(mididev_info *md, int status);
66 typedef int (mdsy_volumemethod_t)(mididev_info *md, int mode);
67 typedef int (mdsy_readraw_t)(mididev_info *md, u_char *buf, int len, int *lenr, int nonblock);
68 typedef int (mdsy_writeraw_t)(mididev_info *md, u_char *buf, int len, int *lenw, int nonblock);
69
70 /*
71 * The order of mutex lock (from the first to the last)
72 *
73 * 1. sequencer flags, queues, timer and devlice list
74 * 2. midi synth voice and channel
75 * 3. midi synth status
76 * 4. generic midi flags and queues
77 * 5. midi device
78 */
79
80 /* This is a midi synthesizer interface and state. */
81 struct _synthdev_info {
82 mdsy_killnote_t *killnote;
83 mdsy_setinstr_t *setinstr;
84 mdsy_startnote_t *startnote;
85 mdsy_reset_t *reset;
86 mdsy_hwcontrol_t *hwcontrol;
87 mdsy_loadpatch_t *loadpatch;
88 mdsy_panning_t *panning;
89 mdsy_aftertouch_t *aftertouch;
90 mdsy_controller_t *controller;
91 mdsy_patchmgr_t *patchmgr;
92 mdsy_bender_t *bender;
93 mdsy_allocvoice_t *allocvoice;
94 mdsy_setupvoice_t *setupvoice;
95 mdsy_sendsysex_t *sendsysex;
96 mdsy_prefixcmd_t *prefixcmd;
97 mdsy_volumemethod_t *volumemethod;
98 mdsy_readraw_t *readraw;
99 mdsy_writeraw_t *writeraw;
100
101 /* Voice and channel */
102 struct mtx vc_mtx; /* Mutex to protect voice and channel. */
103 struct voice_alloc_info alloc; /* Voice allocation. */
104 struct channel_info chn_info[16]; /* Channel information. */
105
106 /* Status */
107 struct mtx status_mtx; /* Mutex to protect status. */
108 int sysex_state; /* State of sysex transmission. */
109 };
110 typedef struct _synthdev_info synthdev_info;
Cache object: 8871f436c98c207724639eceaac31e26
|