Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | #ifndef S3_TYPES_H |
| 2 | #define S3_TYPES_H |
||
| 3 | |||
| 4 | #include "s3/s3.h" |
||
| 5 | |||
| 6 | #include <miniaudio/miniaudio.h> |
||
| 7 | #include <stdint.h> |
||
| 8 | |||
| 9 | // extern int PDGetTotalTime(); |
||
| 10 | // extern void dr_dprintf(char* fmt_string, ...); |
||
| 11 | |||
| 12 | #define MIN(a, b) ((a) < (b) ? a : b) |
||
| 13 | #define MAX(a, b) ((a) > (b) ? a : b) |
||
| 14 | |||
| 15 | // Internal typedefs |
||
| 16 | |||
| 17 | typedef float tF32; |
||
| 18 | typedef tS3_sound_source* tS3_sound_source_ptr; |
||
| 19 | typedef int tS3_sound_tag; |
||
| 20 | typedef int tS3_sound_id; |
||
| 21 | typedef int tS3_type; |
||
| 22 | typedef int tS3_repeats; |
||
| 23 | typedef int tS3_volume; |
||
| 24 | typedef int tS3_effect_tag; |
||
| 25 | typedef long tS3_priority; |
||
| 26 | typedef long tS3_pitch; |
||
| 27 | typedef long tS3_speed; |
||
| 28 | typedef struct tS3_outlet tS3_outlet; |
||
| 29 | typedef struct tS3_descriptor tS3_descriptor; |
||
| 30 | typedef struct tS3_channel tS3_channel; |
||
| 31 | typedef struct tS3_sound_source tS3_sound_source; |
||
| 32 | typedef tS3_outlet* tS3_outlet_ptr; |
||
| 33 | |||
| 34 | typedef enum tS3_error_codes { |
||
| 35 | eS3_error_none = 0, |
||
| 36 | eS3_error_digi_init = 1, |
||
| 37 | eS3_error_midi_init = 2, |
||
| 38 | eS3_error_memory = 3, |
||
| 39 | eS3_error_readfile = 4, |
||
| 40 | eS3_error_soundbank = 5, |
||
| 41 | eS3_error_bad_id = 6, |
||
| 42 | eS3_error_bad_stag = 7, |
||
| 43 | eS3_error_load_sound = 8, |
||
| 44 | eS3_error_start_sound = 9, |
||
| 45 | eS3_error_channel_alloc = 10, |
||
| 46 | eS3_error_not_spatial = 11, |
||
| 47 | eS3_error_function_failed = 12, |
||
| 48 | eS3_error_load_song = 13, |
||
| 49 | eS3_error_song_not_loaded = 14, |
||
| 50 | eS3_error_start_song = 15, |
||
| 51 | eS3_error_start_cda = 16, |
||
| 52 | eS3_error_cda_not_init = 17, |
||
| 53 | eS3_error_already_started_cda = 18, |
||
| 54 | eS3_error_nonexistant_source = 19 |
||
| 55 | } tS3_error_codes; |
||
| 56 | |||
| 57 | typedef enum tS3_termination_reason { |
||
| 58 | eS3_tr_natural = 0, |
||
| 59 | eS3_tr_stopped = 1, |
||
| 60 | eS3_tr_overridden = 2 |
||
| 61 | } tS3_termination_reason; |
||
| 62 | |||
| 63 | typedef enum tS3_filter_type { |
||
| 64 | eS3_filter_none = 0, |
||
| 65 | eS3_filter_reversed = 1, |
||
| 66 | eS3_filter_echo = 2 |
||
| 67 | } tS3_filter_type; |
||
| 68 | |||
| 69 | typedef enum tS3_sound_type { |
||
| 70 | eS3_ST_sample = 0, |
||
| 71 | eS3_ST_midi = 1, |
||
| 72 | eS3_ST_cda = 2 |
||
| 73 | } tS3_sound_type; |
||
| 74 | |||
| 75 | typedef void tS3_outlet_callback(tS3_outlet*, tS3_sound_tag, tS3_termination_reason); |
||
| 76 | typedef void tS3_sample_filter(tS3_effect_tag, tS3_sound_tag); |
||
| 77 | |||
| 78 | typedef struct tS3_channel { |
||
| 79 | int active; |
||
| 80 | int termination_reason; |
||
| 81 | int needs_service; |
||
| 82 | int repetitions; |
||
| 83 | int rate; |
||
| 84 | int spatial_sound; |
||
| 85 | unsigned int song_handle; |
||
| 86 | tS3_sound_tag tag; |
||
| 87 | tS3_type type; |
||
| 88 | tS3_volume left_volume; |
||
| 89 | tS3_volume right_volume; |
||
| 90 | float volume_multiplier; |
||
| 91 | tS3_vector3 position; |
||
| 92 | tS3_vector3 velocity; |
||
| 93 | tS3_vector3 lastpos; |
||
| 94 | tS3_volume initial_volume; |
||
| 95 | tS3_pitch initial_pitch; |
||
| 96 | float pMax_distance_squared; |
||
| 97 | tS3_outlet* owner_outlet; |
||
| 98 | tS3_descriptor* descriptor; |
||
| 99 | tS3_channel* next; |
||
| 100 | char* type_struct_sample; |
||
| 101 | char* type_struct_midi; |
||
| 102 | char* type_struct_cda; |
||
| 103 | tS3_sound_source* sound_source_ptr; |
||
| 104 | } tS3_channel; |
||
| 105 | |||
| 106 | typedef struct tS3_outlet { |
||
| 107 | int id; |
||
| 108 | int max_channels; |
||
| 109 | int independent_pitch; |
||
| 110 | tS3_channel* channel_list; |
||
| 111 | tS3_outlet* prev; |
||
| 112 | tS3_outlet* next; |
||
| 113 | tS3_outlet_callback* callback; |
||
| 114 | } tS3_outlet; |
||
| 115 | |||
| 116 | typedef struct tS3_descriptor { |
||
| 117 | tS3_sound_id id; |
||
| 118 | tS3_type type; |
||
| 119 | tS3_priority priority; |
||
| 120 | tS3_repeats repeats; |
||
| 121 | tS3_volume min_volume; |
||
| 122 | tS3_volume max_volume; |
||
| 123 | tS3_pitch min_pitch; |
||
| 124 | tS3_pitch max_pitch; |
||
| 125 | tS3_speed min_speed; |
||
| 126 | tS3_speed max_speed; |
||
| 127 | tS3_descriptor* prev; |
||
| 128 | tS3_descriptor* next; |
||
| 129 | int flags; |
||
| 130 | int midi_song_handle; |
||
| 131 | int special_fx; |
||
| 132 | int memory_proxy; |
||
| 133 | char* sound_data; |
||
| 134 | char* filename; |
||
| 135 | // win95 only |
||
| 136 | // LPDIRECTSOUNDBUFFER sound_buffer; |
||
| 137 | } tS3_descriptor; |
||
| 138 | |||
| 139 | typedef struct tS3_sound_source { |
||
| 140 | tS3_channel* channel; |
||
| 141 | int brender_vector; |
||
| 142 | void* position_ptr; |
||
| 143 | void* velocity_ptr; |
||
| 144 | tS3_outlet* bound_outlet; |
||
| 145 | tS3_sound_source* prev; |
||
| 146 | tS3_sound_source* next; |
||
| 147 | int ambient; |
||
| 148 | tS3_repeats ambient_repeats; |
||
| 149 | int time_since_last_played; |
||
| 150 | tS3_sound_id sound_id; |
||
| 151 | float max_distance_sq; |
||
| 152 | int period; |
||
| 153 | tS3_volume volume; |
||
| 154 | tS3_pitch pitch; |
||
| 155 | tS3_speed speed; |
||
| 156 | tS3_sound_tag tag; |
||
| 157 | } tS3_sound_source; |
||
| 158 | |||
| 159 | typedef struct tS3_sample { |
||
| 160 | int size; |
||
| 161 | int rate; |
||
| 162 | int resolution; |
||
| 163 | int channels; |
||
| 164 | char* dataptr; |
||
| 165 | void* freeptr; |
||
| 166 | } tS3_sample; |
||
| 167 | |||
| 168 | typedef struct tS3_hardware_info { |
||
| 169 | int device_installed; |
||
| 170 | int timer_installed; |
||
| 171 | int num_channels; |
||
| 172 | int max_resolution; |
||
| 173 | int stereo_flag; |
||
| 174 | int max_sample_rate; |
||
| 175 | int min_sample_rate; |
||
| 176 | int independent_pitch; |
||
| 177 | } tS3_hardware_info; |
||
| 178 | |||
| 179 | // Everything below added by dethrace |
||
| 180 | typedef struct tS3_soundbank_read_ctx { |
||
| 181 | int data_len; |
||
| 182 | int unk1; |
||
| 183 | int nlines; |
||
| 184 | char* data; |
||
| 185 | } tS3_soundbank_read_ctx; |
||
| 186 | |||
| 187 | #pragma pack(push, 1) |
||
| 188 | typedef struct tWAVEFORMATEX_ { |
||
| 189 | int16_t wFormatTag; |
||
| 190 | int16_t nChannels; |
||
| 191 | int32_t nSamplesPerSec; |
||
| 192 | int32_t nAvgBytesPerSec; |
||
| 193 | int16_t nBlockAlign; |
||
| 194 | int16_t wBitsPerSample; |
||
| 195 | int16_t cbSize; |
||
| 196 | } tWAVEFORMATEX_; |
||
| 197 | #pragma pack(pop) |
||
| 198 | |||
| 199 | #pragma pack(push, 1) |
||
| 200 | typedef struct wav_header { |
||
| 201 | // RIFF Header |
||
| 202 | char riff_header[4]; // Contains "RIFF" |
||
| 203 | int32_t wav_size; // Size of the wav portion of the file, which follows the first 8 bytes. File size - 8 |
||
| 204 | char wave_header[4]; // Contains "WAVE" |
||
| 205 | |||
| 206 | // Format Header |
||
| 207 | char fmt_header[4]; // Contains "fmt " (includes trailing space) |
||
| 208 | int32_t fmt_chunk_size; // Should be 16 for PCM |
||
| 209 | int16_t audio_format; // Should be 1 for PCM. 3 for IEEE Float |
||
| 210 | int16_t num_channels; |
||
| 211 | int32_t sample_rate; |
||
| 212 | int32_t byte_rate; // Number of bytes per second. sample_rate * num_channels * Bytes Per Sample |
||
| 213 | int16_t sample_alignment; // num_channels * Bytes Per Sample |
||
| 214 | int16_t bit_depth; // Number of bits per sample |
||
| 215 | |||
| 216 | // Data |
||
| 217 | char data_header[4]; // Contains "data" |
||
| 218 | int32_t data_bytes; // Number of bytes in data. Number of samples * num_channels * sample byte size |
||
| 219 | } wav_header; |
||
| 220 | #pragma pack(pop) |
||
| 221 | |||
| 222 | #endif |