0001
0002 #ifndef __SOUND_SOUNDFONT_H
0003 #define __SOUND_SOUNDFONT_H
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <sound/sfnt_info.h>
0013 #include <sound/util_mem.h>
0014
0015 #define SF_MAX_INSTRUMENTS 128
0016 #define SF_MAX_PRESETS 256
0017 #define SF_IS_DRUM_BANK(z) ((z) == 128)
0018
0019 struct snd_sf_zone {
0020 struct snd_sf_zone *next;
0021 unsigned char bank;
0022 unsigned char instr;
0023 unsigned char mapped;
0024
0025 struct soundfont_voice_info v;
0026 int counter;
0027 struct snd_sf_sample *sample;
0028
0029
0030 struct snd_sf_zone *next_instr;
0031 struct snd_sf_zone *next_zone;
0032 };
0033
0034 struct snd_sf_sample {
0035 struct soundfont_sample_info v;
0036 int counter;
0037 struct snd_util_memblk *block;
0038 struct snd_sf_sample *next;
0039 };
0040
0041
0042
0043
0044 struct snd_soundfont {
0045 struct snd_soundfont *next;
0046
0047 short id;
0048 short type;
0049 unsigned char name[SNDRV_SFNT_PATCH_NAME_LEN];
0050 struct snd_sf_zone *zones;
0051 struct snd_sf_sample *samples;
0052 };
0053
0054
0055
0056
0057 struct snd_sf_callback {
0058 void *private_data;
0059 int (*sample_new)(void *private_data, struct snd_sf_sample *sp,
0060 struct snd_util_memhdr *hdr,
0061 const void __user *buf, long count);
0062 int (*sample_free)(void *private_data, struct snd_sf_sample *sp,
0063 struct snd_util_memhdr *hdr);
0064 void (*sample_reset)(void *private);
0065 };
0066
0067
0068
0069
0070 struct snd_sf_list {
0071 struct snd_soundfont *currsf;
0072 int open_client;
0073 int mem_used;
0074 struct snd_sf_zone *presets[SF_MAX_PRESETS];
0075 struct snd_soundfont *fonts;
0076 int fonts_size;
0077 int zone_counter;
0078 int sample_counter;
0079 int zone_locked;
0080 int sample_locked;
0081 struct snd_sf_callback callback;
0082 int presets_locked;
0083 struct mutex presets_mutex;
0084 spinlock_t lock;
0085 struct snd_util_memhdr *memhdr;
0086 };
0087
0088
0089 int snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
0090 long count, int client);
0091 int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data,
0092 long count, int client);
0093 int snd_soundfont_close_check(struct snd_sf_list *sflist, int client);
0094
0095 struct snd_sf_list *snd_sf_new(struct snd_sf_callback *callback,
0096 struct snd_util_memhdr *hdr);
0097 void snd_sf_free(struct snd_sf_list *sflist);
0098
0099 int snd_soundfont_remove_samples(struct snd_sf_list *sflist);
0100 int snd_soundfont_remove_unlocked(struct snd_sf_list *sflist);
0101
0102 int snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel,
0103 int preset, int bank,
0104 int def_preset, int def_bank,
0105 struct snd_sf_zone **table, int max_layers);
0106
0107
0108 int snd_sf_calc_parm_hold(int msec);
0109 int snd_sf_calc_parm_attack(int msec);
0110 int snd_sf_calc_parm_decay(int msec);
0111 #define snd_sf_calc_parm_delay(msec) (0x8000 - (msec) * 1000 / 725)
0112 extern int snd_sf_vol_table[128];
0113 int snd_sf_linear_to_log(unsigned int amount, int offset, int ratio);
0114
0115
0116 #endif