annotate render_audio.h @ 2283:6f6f21d0c396

Fix missing address masks on some VRAM reads
author Michael Pavone <pavone@retrodev.com>
date Mon, 09 Jan 2023 00:15:26 -0800
parents cfd53c94fffb
children b3832f73444f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 {
2081
cfd53c94fffb Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents: 1865
diff changeset
12 const char *name;
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
13 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
14 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
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22 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
23 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
24 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
25 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
26 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
27 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
28 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
29 } 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
30
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 //public interface
2081
cfd53c94fffb Initial stab at RF5C164 emulation
Michael Pavone <pavone@retrodev.com>
parents: 1865
diff changeset
32 audio_source *render_audio_source(const char *name, uint64_t master_clock, uint64_t sample_divider, uint8_t channels);
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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 //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
41 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
42 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
43 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
44 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
45 //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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 #endif //RENDER_AUDIO_H_