1 /* 2 * Advanced Linux Sound Architecture 3 * 4 * Simple (MOD player) Instrument Format 5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex (at) perex.cz> 6 * 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 */ 23 24 #ifndef __SOUND_AINSTR_SIMPLE_H 25 #define __SOUND_AINSTR_SIMPLE_H 26 27 #include "type_compat.h" 28 29 /* 30 * share types (share ID 1) 31 */ 32 33 #define SIMPLE_SHARE_FILE 0 34 35 /* 36 * wave formats 37 */ 38 39 #define SIMPLE_WAVE_16BIT 0x0001 /* 16-bit wave */ 40 #define SIMPLE_WAVE_UNSIGNED 0x0002 /* unsigned wave */ 41 #define SIMPLE_WAVE_INVERT 0x0002 /* same as unsigned wave */ 42 #define SIMPLE_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */ 43 #define SIMPLE_WAVE_LOOP 0x0008 /* loop mode */ 44 #define SIMPLE_WAVE_BIDIR 0x0010 /* bidirectional mode */ 45 #define SIMPLE_WAVE_STEREO 0x0100 /* stereo wave */ 46 #define SIMPLE_WAVE_ULAW 0x0200 /* uLaw compression mode */ 47 48 /* 49 * instrument effects 50 */ 51 52 #define SIMPLE_EFFECT_NONE 0 53 #define SIMPLE_EFFECT_REVERB 1 54 #define SIMPLE_EFFECT_CHORUS 2 55 #define SIMPLE_EFFECT_ECHO 3 56 57 /* 58 * instrument info 59 */ 60 61 typedef struct simple_instrument_info { 62 unsigned int format; /* supported format bits */ 63 unsigned int effects; /* supported effects (1 << SIMPLE_EFFECT_*) */ 64 unsigned int max8_len; /* maximum 8-bit wave length */ 65 unsigned int max16_len; /* maximum 16-bit wave length */ 66 } simple_instrument_info_t; 67 68 /* 69 * Instrument 70 */ 71 72 typedef struct { 73 unsigned int share_id[4]; /* share id - zero = no sharing */ 74 unsigned int format; /* wave format */ 75 76 struct { 77 unsigned int number; /* some other ID for this instrument */ 78 unsigned int memory; /* begin of waveform in onboard memory */ 79 unsigned char *ptr; /* pointer to waveform in system memory */ 80 } address; 81 82 unsigned int size; /* size of waveform in samples */ 83 unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */ 84 unsigned int loop_start; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */ 85 unsigned int loop_end; /* loop end offset in samples * 16 (lowest 4 bits - fraction) */ 86 unsigned short loop_repeat; /* loop repeat - 0 = forever */ 87 88 unsigned char effect1; /* effect 1 */ 89 unsigned char effect1_depth; /* 0-127 */ 90 unsigned char effect2; /* effect 2 */ 91 unsigned char effect2_depth; /* 0-127 */ 92 } simple_instrument_t; 93 94 /* 95 * 96 * Kernel <-> user space 97 * Hardware (CPU) independent section 98 * 99 * * = zero or more 100 * + = one or more 101 * 102 * simple_xinstrument SIMPLE_STRU_INSTR 103 * 104 */ 105 106 #define SIMPLE_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T') 107 108 /* 109 * Instrument 110 */ 111 112 typedef struct simple_xinstrument { 113 __u32 stype; 114 115 __u32 share_id[4]; /* share id - zero = no sharing */ 116 __u32 format; /* wave format */ 117 118 __u32 size; /* size of waveform in samples */ 119 __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */ 120 __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */ 121 __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */ 122 __u16 loop_repeat; /* loop repeat - 0 = forever */ 123 124 __u8 effect1; /* effect 1 */ 125 __u8 effect1_depth; /* 0-127 */ 126 __u8 effect2; /* effect 2 */ 127 __u8 effect2_depth; /* 0-127 */ 128 } simple_xinstrument_t; 129 130 #ifdef __KERNEL__ 131 132 #include "seq_instr.h" 133 134 extern char *snd_seq_simple_id; 135 136 typedef struct { 137 void *private_data; 138 int (*info)(void *private_data, simple_instrument_info_t *info); 139 int (*put_sample)(void *private_data, simple_instrument_t *instr, 140 char *data, long len, int atomic); 141 int (*get_sample)(void *private_data, simple_instrument_t *instr, 142 char *data, long len, int atomic); 143 int (*remove_sample)(void *private_data, simple_instrument_t *instr, 144 int atomic); 145 void (*notify)(void *private_data, snd_seq_kinstr_t *instr, int what); 146 snd_seq_kinstr_ops_t kops; 147 } snd_simple_ops_t; 148 149 int snd_seq_simple_init(snd_simple_ops_t *ops, 150 void *private_data, 151 snd_seq_kinstr_ops_t *next); 152 153 #endif 154 155 #endif /* __SOUND_AINSTR_SIMPLE_H */ 156