1#ifndef __SOUND_SOUNDFONT_H
2#define __SOUND_SOUNDFONT_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <sound/sfnt_info.h>
26#include <sound/util_mem.h>
27
28#define SF_MAX_INSTRUMENTS 128
29#define SF_MAX_PRESETS 256
30#define SF_IS_DRUM_BANK(z) ((z) == 128)
31
32struct snd_sf_zone {
33 struct snd_sf_zone *next;
34 unsigned char bank;
35 unsigned char instr;
36 unsigned char mapped;
37
38 struct soundfont_voice_info v;
39 int counter;
40 struct snd_sf_sample *sample;
41
42
43 struct snd_sf_zone *next_instr;
44 struct snd_sf_zone *next_zone;
45};
46
47struct snd_sf_sample {
48 struct soundfont_sample_info v;
49 int counter;
50 struct snd_util_memblk *block;
51 struct snd_sf_sample *next;
52};
53
54
55
56
57struct snd_soundfont {
58 struct snd_soundfont *next;
59
60 short id;
61 short type;
62 unsigned char name[SNDRV_SFNT_PATCH_NAME_LEN];
63 struct snd_sf_zone *zones;
64 struct snd_sf_sample *samples;
65};
66
67
68
69
70struct snd_sf_callback {
71 void *private_data;
72 int (*sample_new)(void *private_data, struct snd_sf_sample *sp,
73 struct snd_util_memhdr *hdr,
74 const void __user *buf, long count);
75 int (*sample_free)(void *private_data, struct snd_sf_sample *sp,
76 struct snd_util_memhdr *hdr);
77 void (*sample_reset)(void *private);
78};
79
80
81
82
83struct snd_sf_list {
84 struct snd_soundfont *currsf;
85 int open_client;
86 int mem_used;
87 struct snd_sf_zone *presets[SF_MAX_PRESETS];
88 struct snd_soundfont *fonts;
89 int fonts_size;
90 int zone_counter;
91 int sample_counter;
92 int zone_locked;
93 int sample_locked;
94 struct snd_sf_callback callback;
95 int presets_locked;
96 struct mutex presets_mutex;
97 spinlock_t lock;
98 struct snd_util_memhdr *memhdr;
99};
100
101
102int snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
103 long count, int client);
104int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data,
105 long count, int client);
106int snd_soundfont_close_check(struct snd_sf_list *sflist, int client);
107
108struct snd_sf_list *snd_sf_new(struct snd_sf_callback *callback,
109 struct snd_util_memhdr *hdr);
110void snd_sf_free(struct snd_sf_list *sflist);
111
112int snd_soundfont_remove_samples(struct snd_sf_list *sflist);
113int snd_soundfont_remove_unlocked(struct snd_sf_list *sflist);
114
115int snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel,
116 int preset, int bank,
117 int def_preset, int def_bank,
118 struct snd_sf_zone **table, int max_layers);
119
120
121int snd_sf_calc_parm_hold(int msec);
122int snd_sf_calc_parm_attack(int msec);
123int snd_sf_calc_parm_decay(int msec);
124#define snd_sf_calc_parm_delay(msec) (0x8000 - (msec) * 1000 / 725)
125extern int snd_sf_vol_table[128];
126int snd_sf_linear_to_log(unsigned int amount, int offset, int ratio);
127
128
129#endif
130