comparison src/Input/timidity/libtimidity/timidity.h @ 0:13389e613d67 trunk

[svn] - initial import of audacious-plugins tree (lots to do)
author nenolod
date Mon, 18 Sep 2006 01:11:49 -0700
parents
children 088092a52fea
comparison
equal deleted inserted replaced
-1:000000000000 0:13389e613d67
1 /*
2
3 libTiMidity -- MIDI to WAVE converter library
4 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
5 Copyright (C) 2004 Konstantin Korikov <lostclus@ua.fm>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23 #ifndef TIMIDITY_H
24 #define TIMIDITY_H
25
26 #include "libaudacious/vfs.h"
27 #include <stdlib.h>
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 #define LIBTIMIDITY_VERSION_MAJOR 0L
35 #define LIBTIMIDITY_VERSION_MINOR 1L
36 #define LIBTIMIDITY_PATCHLEVEL 0L
37
38 #define LIBTIMIDITY_VERSION \
39 ((LIBTIMIDITY_VERSION_MAJOR<<16)| \
40 (LIBTIMIDITY_VERSION_MINOR<< 8)| \
41 (LIBTIMIDITY_PATCHLEVEL))
42
43 /* Audio format flags (defaults to LSB byte order)
44 */
45 #define MID_AUDIO_U8 0x0008 /* Unsigned 8-bit samples */
46 #define MID_AUDIO_S8 0x8008 /* Signed 8-bit samples */
47 #define MID_AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */
48 #define MID_AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */
49 #define MID_AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */
50 #define MID_AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */
51 #define MID_AUDIO_U16 MID_AUDIO_U16LSB
52 #define MID_AUDIO_S16 MID_AUDIO_S16LSB
53
54 /* Core Library Types
55 */
56 typedef unsigned char uint8;
57 typedef signed char sint8;
58 typedef unsigned short uint16;
59 typedef signed short sint16;
60 typedef unsigned int uint32;
61 typedef signed int sint32;
62
63 typedef size_t (*MidIStreamReadFunc) (void *ctx, void *ptr, size_t size,
64 size_t nmemb);
65 typedef int (*MidIStreamCloseFunc) (void *ctx);
66
67 typedef struct _MidIStream MidIStream;
68 typedef struct _MidDLSPatches MidDLSPatches;
69 typedef struct _MidSong MidSong;
70
71 typedef struct _MidSongOptions MidSongOptions;
72 struct _MidSongOptions
73 {
74 sint32 rate; /* DSP frequency -- samples per second */
75 uint16 format; /* Audio data format */
76 uint8 channels; /* Number of channels: 1 mono, 2 stereo */
77 uint16 buffer_size; /* Sample buffer size in samples */
78 };
79
80 typedef enum
81 {
82 MID_SONG_TEXT = 0,
83 MID_SONG_COPYRIGHT = 1
84 } MidSongMetaId;
85
86
87 /* Core Library Functions
88 * ======================
89 */
90
91 /* Initialize the library. If config_file is NULL
92 * search for configuratin file in default directories
93 */
94 extern int mid_init (char *config_file);
95
96 /* Initialize the library without reading any
97 * configuratin file
98 */
99 extern int mid_init_no_config (void);
100
101 /* Shutdown the library
102 */
103 extern void mid_exit (void);
104
105
106 /* Input Stream Functions
107 * ======================
108 */
109
110 /* Create input stream from a file name
111 */
112 extern MidIStream *mid_istream_open_file (const char *file);
113
114 /* Create input stream from a file pointer
115 */
116 extern MidIStream *mid_istream_open_fp (VFSFile *fp, int autoclose);
117
118 /* Create input stream from memory
119 */
120 extern MidIStream *mid_istream_open_mem (void *mem, size_t size,
121 int autofree);
122
123 /* Create custom input stream
124 */
125 extern MidIStream *mid_istream_open_callbacks (MidIStreamReadFunc read,
126 MidIStreamCloseFunc close,
127 void *context);
128
129 /* Read data from input stream
130 */
131 extern size_t mid_istream_read (MidIStream * stream, void *ptr, size_t size,
132 size_t nmemb);
133
134 /* Skip data from input stream
135 */
136 extern void mid_istream_skip (MidIStream * stream, size_t len);
137
138 /* Close and destroy input stream
139 */
140 extern int mid_istream_close (MidIStream * stream);
141
142
143 /* DLS Pathes Functions
144 * ====================
145 */
146
147 /* Load DLS patches
148 */
149 extern MidDLSPatches *mid_dlspatches_load (MidIStream * stream);
150
151 /* Destroy DLS patches
152 */
153 extern void mid_dlspatches_free (MidDLSPatches * patches);
154
155
156 /* MIDI Song Functions
157 * ===================
158 */
159
160 /* Load MIDI song
161 */
162 extern MidSong *mid_song_load (MidIStream * stream,
163 MidSongOptions * options);
164
165 /* Load MIDI song with specified DLS pathes
166 */
167 extern MidSong *mid_song_load_dls (MidIStream * stream,
168 MidDLSPatches * patches,
169 MidSongOptions * options);
170
171 /* Set song amplification value
172 */
173 extern void mid_song_set_volume (MidSong * song, int volume);
174
175 /* Seek song to the start position and initialize conversion
176 */
177 extern void mid_song_start (MidSong * song);
178
179 /* Read WAVE data
180 */
181 extern size_t mid_song_read_wave (MidSong * song, void *ptr, size_t size);
182
183 /* Seek song to specified offset in millseconds
184 */
185 extern void mid_song_seek (MidSong * song, uint32 ms);
186
187 /* Get total song time in millseconds
188 */
189 extern uint32 mid_song_get_total_time (MidSong * song);
190
191 /* Get current song time in millseconds
192 */
193 extern uint32 mid_song_get_time (MidSong * song);
194
195 /* Get song meta data. Return NULL if no meta data found
196 */
197 extern char *mid_song_get_meta (MidSong * song, MidSongMetaId what);
198
199 /* Destroy song
200 */
201 extern void mid_song_free (MidSong * song);
202
203 #ifdef __cplusplus
204 }
205 #endif
206 #endif /* TIMIDITY_H */