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