aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/soundfont.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/soundfont.h')
-rw-r--r--include/sound/soundfont.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/include/sound/soundfont.h b/include/sound/soundfont.h
new file mode 100644
index 000000000000..c992958f5e3c
--- /dev/null
+++ b/include/sound/soundfont.h
@@ -0,0 +1,130 @@
1#ifndef __SOUND_SOUNDFONT_H
2#define __SOUND_SOUNDFONT_H
3
4/*
5 * Soundfont defines and definitions.
6 *
7 * Copyright (C) 1999 Steve Ratcliffe
8 * Copyright (c) 1999-2000 Takashi iwai <tiwai@suse.de>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include "sfnt_info.h"
26#include "util_mem.h"
27
28#define SF_MAX_INSTRUMENTS 128 /* maximum instrument number */
29#define SF_MAX_PRESETS 256 /* drums are mapped from 128 to 256 */
30#define SF_IS_DRUM_BANK(z) ((z) == 128)
31
32typedef struct snd_sf_zone {
33 struct snd_sf_zone *next; /* Link to next */
34 unsigned char bank; /* Midi bank for this zone */
35 unsigned char instr; /* Midi program for this zone */
36 unsigned char mapped; /* True if mapped to something else */
37
38 soundfont_voice_info_t v; /* All the soundfont parameters */
39 int counter;
40 struct snd_sf_sample *sample; /* Link to sample */
41
42 /* The following deals with preset numbers (programs) */
43 struct snd_sf_zone *next_instr; /* Next zone of this instrument */
44 struct snd_sf_zone *next_zone; /* Next zone in play list */
45} snd_sf_zone_t;
46
47typedef struct snd_sf_sample {
48 soundfont_sample_info_t v;
49 int counter;
50 snd_util_memblk_t *block; /* allocated data block */
51 struct snd_sf_sample *next;
52} snd_sf_sample_t;
53
54/*
55 * This represents all the information relating to a soundfont.
56 */
57typedef struct snd_soundfont {
58 struct snd_soundfont *next; /* Link to next */
59 /*struct snd_soundfont *prev;*/ /* Link to previous */
60 short id; /* file id */
61 short type; /* font type */
62 unsigned char name[SNDRV_SFNT_PATCH_NAME_LEN]; /* identifier */
63 snd_sf_zone_t *zones; /* Font information */
64 snd_sf_sample_t *samples; /* The sample headers */
65} snd_soundfont_t;
66
67/*
68 * Type of the sample access callback
69 */
70typedef int (*snd_sf_sample_new_t)(void *private_data, snd_sf_sample_t *sp,
71 snd_util_memhdr_t *hdr, const void __user *buf, long count);
72typedef int (*snd_sf_sample_free_t)(void *private_data, snd_sf_sample_t *sp,
73 snd_util_memhdr_t *hdr);
74typedef void (*snd_sf_sample_reset_t)(void *private);
75
76typedef struct snd_sf_callback {
77 void *private_data;
78 snd_sf_sample_new_t sample_new;
79 snd_sf_sample_free_t sample_free;
80 snd_sf_sample_reset_t sample_reset;
81} snd_sf_callback_t;
82
83/*
84 * List of soundfonts.
85 */
86typedef struct snd_sf_list {
87 snd_soundfont_t *currsf; /* The currently open soundfont */
88 int open_client; /* client pointer for lock */
89 int mem_used; /* used memory size */
90 snd_sf_zone_t *presets[SF_MAX_PRESETS];
91 snd_soundfont_t *fonts; /* The list of soundfonts */
92 int fonts_size; /* number of fonts allocated */
93 int zone_counter; /* last allocated time for zone */
94 int sample_counter; /* last allocated time for sample */
95 int zone_locked; /* locked time for zone */
96 int sample_locked; /* locked time for sample */
97 snd_sf_callback_t callback; /* callback functions */
98 int presets_locked;
99 struct semaphore presets_mutex;
100 spinlock_t lock;
101 snd_util_memhdr_t *memhdr;
102} snd_sf_list_t;
103
104/* Prototypes for soundfont.c */
105int snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, int client);
106int snd_soundfont_load_guspatch(snd_sf_list_t *sflist, const char __user *data,
107 long count, int client);
108int snd_soundfont_close_check(snd_sf_list_t *sflist, int client);
109
110snd_sf_list_t *snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr);
111void snd_sf_free(snd_sf_list_t *sflist);
112
113int snd_soundfont_remove_samples(snd_sf_list_t *sflist);
114int snd_soundfont_remove_unlocked(snd_sf_list_t *sflist);
115
116int snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel,
117 int preset, int bank,
118 int def_preset, int def_bank,
119 snd_sf_zone_t **table, int max_layers);
120
121/* Parameter conversions */
122int snd_sf_calc_parm_hold(int msec);
123int snd_sf_calc_parm_attack(int msec);
124int snd_sf_calc_parm_decay(int msec);
125#define snd_sf_calc_parm_delay(msec) (0x8000 - (msec) * 1000 / 725);
126extern int snd_sf_vol_table[128];
127int snd_sf_linear_to_log(unsigned int amount, int offset, int ratio);
128
129
130#endif /* __SOUND_SOUNDFONT_H */