1 | /**
|
---|
2 | * \file <file/instr.h>
|
---|
3 | * \brief Application interface library for the ALSA driver
|
---|
4 | * \author Jaroslav Kysela <perex@suse.cz>
|
---|
5 | * \author Abramo Bagnara <abramo@alsa-project.org>
|
---|
6 | * \author Takashi Iwai <tiwai@suse.de>
|
---|
7 | * \date 1998-2001
|
---|
8 | *
|
---|
9 | * Application interface library for the ALSA driver
|
---|
10 | *
|
---|
11 | *
|
---|
12 | * This library is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU Lesser General Public License as
|
---|
14 | * published by the Free Software Foundation; either version 2.1 of
|
---|
15 | * the License, or (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU Lesser General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU Lesser General Public
|
---|
23 | * License along with this library; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef __ALSA_INSTR_H
|
---|
29 | #define __ALSA_INSTR_H
|
---|
30 |
|
---|
31 | #ifdef __cplusplus
|
---|
32 | extern "C" {
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * \defgroup Instrument Instrument Interface
|
---|
37 | * The Instrument Interface.
|
---|
38 | * \{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /* instrument get/put */
|
---|
42 |
|
---|
43 | /** container for sequencer instrument header */
|
---|
44 | typedef struct sndrv_seq_instr_header snd_instr_header_t;
|
---|
45 |
|
---|
46 | size_t snd_instr_header_sizeof(void);
|
---|
47 | #define snd_instr_header_alloca(ptr) \
|
---|
48 | do {\
|
---|
49 | assert(ptr);\
|
---|
50 | *ptr = (snd_instr_header_t *)alloca(snd_instr_header_sizeof());\
|
---|
51 | memset(*ptr, 0, snd_instr_header_sizeof());\
|
---|
52 | } while (0) /**< allocate instrument header on stack */
|
---|
53 | int snd_instr_header_malloc(snd_instr_header_t **ptr, size_t len);
|
---|
54 | void snd_instr_header_free(snd_instr_header_t *ptr);
|
---|
55 | void snd_instr_header_copy(snd_instr_header_t *dst, const snd_instr_header_t *src);
|
---|
56 |
|
---|
57 | const snd_seq_instr_t *snd_instr_header_get_id(const snd_instr_header_t *info);
|
---|
58 | snd_seq_instr_cluster_t snd_instr_header_get_cluster(const snd_instr_header_t *info);
|
---|
59 | unsigned int snd_instr_header_get_cmd(const snd_instr_header_t *info);
|
---|
60 | size_t snd_instr_header_get_len(const snd_instr_header_t *info);
|
---|
61 | const char *snd_instr_header_get_name(const snd_instr_header_t *info);
|
---|
62 | int snd_instr_header_get_type(const snd_instr_header_t *info);
|
---|
63 | const char *snd_instr_header_get_format(const snd_instr_header_t *info);
|
---|
64 | const snd_seq_instr_t *snd_instr_header_get_alias(const snd_instr_header_t *info);
|
---|
65 | void *snd_instr_header_get_data(const snd_instr_header_t *info);
|
---|
66 | int snd_instr_header_get_follow_alias(const snd_instr_header_t *info);
|
---|
67 |
|
---|
68 | void snd_instr_header_set_id(snd_instr_header_t *info, const snd_seq_instr_t *id);
|
---|
69 | void snd_instr_header_set_cluster(snd_instr_header_t *info, snd_seq_instr_cluster_t cluster);
|
---|
70 | void snd_instr_header_set_cmd(snd_instr_header_t *info, unsigned int cmd);
|
---|
71 | void snd_instr_header_set_len(snd_instr_header_t *info, size_t len);
|
---|
72 | void snd_instr_header_set_name(snd_instr_header_t *info, const char *name);
|
---|
73 | void snd_instr_header_set_type(snd_instr_header_t *info, int type);
|
---|
74 | void snd_instr_header_set_format(snd_instr_header_t *info, const char *format);
|
---|
75 | void snd_instr_header_set_alias(snd_instr_header_t *info, const snd_seq_instr_t *instr);
|
---|
76 | void snd_instr_header_set_follow_alias(snd_instr_header_t *info, int val);
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Instrument abstraction layer
|
---|
80 | * - based on events
|
---|
81 | */
|
---|
82 |
|
---|
83 | /** instrument types */
|
---|
84 | #define SND_SEQ_INSTR_ATYPE_DATA 0 /**< instrument data */
|
---|
85 | #define SND_SEQ_INSTR_ATYPE_ALIAS 1 /**< instrument alias */
|
---|
86 |
|
---|
87 | /** instrument ASCII identifiers */
|
---|
88 | #define SND_SEQ_INSTR_ID_DLS1 "DLS1" /**< DLS1 */
|
---|
89 | #define SND_SEQ_INSTR_ID_DLS2 "DLS2" /**< DLS2 */
|
---|
90 | #define SND_SEQ_INSTR_ID_SIMPLE "Simple Wave" /**< Simple Wave */
|
---|
91 | #define SND_SEQ_INSTR_ID_SOUNDFONT "SoundFont" /**< SoundFont */
|
---|
92 | #define SND_SEQ_INSTR_ID_GUS_PATCH "GUS Patch" /**< Gravis Patch */
|
---|
93 | #define SND_SEQ_INSTR_ID_INTERWAVE "Interwave FFFF" /**< InterWave FFFF */
|
---|
94 | #define SND_SEQ_INSTR_ID_OPL2_3 "OPL2/3 FM" /**< OPL2/3 FM */
|
---|
95 | #define SND_SEQ_INSTR_ID_OPL4 "OPL4" /**< OPL4 */
|
---|
96 |
|
---|
97 | /** instrument types */
|
---|
98 | #define SND_SEQ_INSTR_TYPE0_DLS1 (1<<0) /**< MIDI DLS v1 */
|
---|
99 | #define SND_SEQ_INSTR_TYPE0_DLS2 (1<<1) /**< MIDI DLS v2 */
|
---|
100 | #define SND_SEQ_INSTR_TYPE1_SIMPLE (1<<0) /**< Simple Wave */
|
---|
101 | #define SND_SEQ_INSTR_TYPE1_SOUNDFONT (1<<1) /**< EMU SoundFont */
|
---|
102 | #define SND_SEQ_INSTR_TYPE1_GUS_PATCH (1<<2) /**< Gravis UltraSound Patch */
|
---|
103 | #define SND_SEQ_INSTR_TYPE1_INTERWAVE (1<<3) /**< InterWave FFFF */
|
---|
104 | #define SND_SEQ_INSTR_TYPE2_OPL2_3 (1<<0) /**< Yamaha OPL2/3 FM */
|
---|
105 | #define SND_SEQ_INSTR_TYPE2_OPL4 (1<<1) /**< Yamaha OPL4 */
|
---|
106 |
|
---|
107 | /** put commands */
|
---|
108 | #define SND_SEQ_INSTR_PUT_CMD_CREATE 0 /**< create a new layer */
|
---|
109 | #define SND_SEQ_INSTR_PUT_CMD_REPLACE 1 /**< replace the old layer with new one */
|
---|
110 | #define SND_SEQ_INSTR_PUT_CMD_MODIFY 2 /**< modify the existing layer */
|
---|
111 | #define SND_SEQ_INSTR_PUT_CMD_ADD 3 /**< add one to the existing layer */
|
---|
112 | #define SND_SEQ_INSTR_PUT_CMD_REMOVE 4 /**< remove the layer */
|
---|
113 |
|
---|
114 | /** get commands */
|
---|
115 | #define SND_SEQ_INSTR_GET_CMD_FULL 0 /**< get the full data stream */
|
---|
116 | #define SND_SEQ_INSTR_GET_CMD_PARTIAL 1 /**< get the partial data stream */
|
---|
117 |
|
---|
118 | /* query flags */
|
---|
119 | #define SND_SEQ_INSTR_QUERY_FOLLOW_ALIAS (1<<0) /**< follow alias to get the instrument data */
|
---|
120 |
|
---|
121 | /** free commands */
|
---|
122 | #define SND_SEQ_INSTR_FREE_CMD_ALL 0 /**< remove all matching instruments */
|
---|
123 | #define SND_SEQ_INSTR_FREE_CMD_PRIVATE 1 /**< remove only private instruments */
|
---|
124 | #define SND_SEQ_INSTR_FREE_CMD_CLUSTER 2 /**< remove only cluster instruments */
|
---|
125 | #define SND_SEQ_INSTR_FREE_CMD_SINGLE 3 /**< remove single instrument */
|
---|
126 |
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * FM instrument support
|
---|
130 | */
|
---|
131 |
|
---|
132 | /** FM instrument data structure */
|
---|
133 | typedef void snd_instr_fm_t;
|
---|
134 |
|
---|
135 | int snd_instr_fm_convert_to_stream(snd_instr_fm_t *fm, const char *name, snd_instr_header_t **put, size_t *size);
|
---|
136 | int snd_instr_fm_convert_from_stream(snd_instr_header_t *data, size_t size, snd_instr_fm_t **fm);
|
---|
137 | int snd_instr_fm_free(snd_instr_fm_t *fm);
|
---|
138 |
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Simple Wave support
|
---|
142 | */
|
---|
143 |
|
---|
144 | /** simple instrument data structure */
|
---|
145 | typedef void snd_instr_simple_t;
|
---|
146 |
|
---|
147 | int snd_instr_simple_convert_to_stream(snd_instr_simple_t *simple, const char *name, snd_instr_header_t **put, size_t *size);
|
---|
148 | int snd_instr_simple_convert_from_stream(snd_instr_header_t *data, size_t size, snd_instr_simple_t **simple);
|
---|
149 | int snd_instr_simple_free(snd_instr_simple_t *simple);
|
---|
150 |
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * InterWave FFFF support
|
---|
154 | */
|
---|
155 |
|
---|
156 | /** IW FFFF instrument data structure */
|
---|
157 | typedef void snd_instr_iwffff_t;
|
---|
158 | /** IW FFFF handler */
|
---|
159 | typedef struct _snd_iwffff_handle snd_iwffff_handle_t;
|
---|
160 |
|
---|
161 | int snd_instr_iwffff_open(snd_iwffff_handle_t **handle, const char *name_fff, const char *name_dta);
|
---|
162 | int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank, int file);
|
---|
163 | int snd_instr_iwffff_open_rom_file(snd_iwffff_handle_t **handle, const char *name, int bank, int file);
|
---|
164 | int snd_instr_iwffff_close(snd_iwffff_handle_t *handle);
|
---|
165 | int snd_instr_iwffff_load(snd_iwffff_handle_t *handle, int bank, int prg, snd_instr_iwffff_t **iwffff);
|
---|
166 | int snd_instr_iwffff_convert_to_stream(snd_instr_iwffff_t *iwffff, const char *name, snd_instr_header_t **data, size_t *size);
|
---|
167 | int snd_instr_iwffff_convert_from_stream(snd_instr_header_t *data, size_t size, snd_instr_iwffff_t **iwffff);
|
---|
168 | int snd_instr_iwffff_free(snd_instr_iwffff_t *iwffff);
|
---|
169 |
|
---|
170 | /** \} */
|
---|
171 |
|
---|
172 | #ifdef __cplusplus
|
---|
173 | }
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | #endif /* __ALSA_INSTR_H */
|
---|
177 |
|
---|