annotate render_audio.h @ 2496:187bc857a76a default tip

Fix bug in MED mapper protection bit implementation
author Michael Pavone <pavone@retrodev.com>
date Sun, 28 Apr 2024 23:33:11 -0700
parents b3832f73444f
children
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);
2304
b3832f73444f Save audio to a wave file when saving video to APNG
Michael Pavone <pavone@retrodev.com>
parents: 2081
diff changeset
40 void render_end_audio(void);
b3832f73444f Save audio to a wave file when saving video to APNG
Michael Pavone <pavone@retrodev.com>
parents: 2081
diff changeset
41 void render_save_audio(char *path);
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
42 //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
43 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
44 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
45 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
46 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
47 //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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 #endif //RENDER_AUDIO_H_