Mercurial > repos > blastem
annotate render_audio.h @ 2013:dcdad92f84a4
Multiplying by zero and shifting by zero are very different. Fixes regression in Overdrive 2
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 Nov 2020 13:28:31 -0800 |
parents | 4c322abd9fa5 |
children | cfd53c94fffb |
rev | line source |
---|---|
1865
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef RENDER_AUDIO_H_ |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define RENDER_AUDIO_H_ |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdint.h> |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 typedef enum { |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 RENDER_AUDIO_S16, |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 RENDER_AUDIO_FLOAT, |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 RENDER_AUDIO_UNKNOWN |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 } render_audio_format; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 typedef struct { |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 void *opaque; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 int16_t *front; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 int16_t *back; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 double dt; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 uint64_t buffer_fraction; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 uint64_t buffer_inc; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 float gain_mult; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 uint32_t buffer_pos; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 uint32_t read_start; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 uint32_t read_end; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 uint32_t lowpass_alpha; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 uint32_t mask; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 int16_t last_left; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 int16_t last_right; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 uint8_t num_channels; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 uint8_t front_populated; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 } audio_source; |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 //public interface |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 audio_source *render_audio_source(uint64_t master_clock, uint64_t sample_divider, uint8_t channels); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 void render_audio_source_gaindb(audio_source *src, float gain); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 void render_audio_adjust_clock(audio_source *src, uint64_t master_clock, uint64_t sample_divider); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 void render_put_mono_sample(audio_source *src, int16_t value); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 void render_put_stereo_sample(audio_source *src, int16_t left, int16_t right); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 void render_pause_source(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 void render_resume_source(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 void render_free_source(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 //interface for render backends |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 void render_audio_initialized(render_audio_format format, uint32_t rate, uint8_t channels, uint32_t buffer_size, int sample_size); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 int mix_and_convert(unsigned char *byte_stream, int len, int *min_remaining_out); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 uint8_t all_sources_ready(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 void render_audio_adjust_speed(float adjust_ratio); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 //to be implemented by render backend |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 uint8_t render_is_audio_sync(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 void render_buffer_consumed(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 void *render_new_audio_opaque(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 void render_free_audio_opaque(void *opaque); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 void render_lock_audio(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 void render_unlock_audio(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 uint32_t render_min_buffered(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 uint32_t render_audio_syncs_per_sec(void); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 void render_audio_created(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 void render_do_audio_ready(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 void render_source_paused(audio_source *src, uint8_t remaining_sources); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 void render_source_resumed(audio_source *src); |
4c322abd9fa5
Split generic part of audio code into a separate file so it can be used in other targets besides SDL
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 #endif //RENDER_AUDIO_H_ |