diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-31 19:19:49 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-31 19:19:49 +0000 |
commit | 13cbade08a07296d92e7a7d3e20475de0032cba1 (patch) | |
tree | 731a1a4a99d86632a719ae49e3b3d2a12e764a3a /apps/codecs/libgme/multi_buffer.h | |
parent | d089e104034fdf5562bea125d2cacf4ee486782a (diff) | |
download | rockbox-13cbade08a07296d92e7a7d3e20475de0032cba1.tar.gz rockbox-13cbade08a07296d92e7a7d3e20475de0032cba1.zip |
Update libgme to Blargg's Game_Music_Emu 0.6-pre.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30397 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libgme/multi_buffer.h')
-rw-r--r-- | apps/codecs/libgme/multi_buffer.h | 108 |
1 files changed, 75 insertions, 33 deletions
diff --git a/apps/codecs/libgme/multi_buffer.h b/apps/codecs/libgme/multi_buffer.h index cfdae4f077..e5efa5a230 100644 --- a/apps/codecs/libgme/multi_buffer.h +++ b/apps/codecs/libgme/multi_buffer.h | |||
@@ -1,4 +1,4 @@ | |||
1 | // Multi-channel sound buffer interface, and basic mono and stereo buffers | 1 | // Multi-channel sound buffer interface, stereo and effects buffers |
2 | 2 | ||
3 | // Blip_Buffer 0.4.1 | 3 | // Blip_Buffer 0.4.1 |
4 | #ifndef MULTI_BUFFER_H | 4 | #ifndef MULTI_BUFFER_H |
@@ -16,57 +16,99 @@ struct channel_t { | |||
16 | 16 | ||
17 | enum { type_index_mask = 0xFF }; | 17 | enum { type_index_mask = 0xFF }; |
18 | enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; | 18 | enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; |
19 | enum { buf_count = 3 }; | 19 | enum { stereo = 2 }; |
20 | 20 | enum { bufs_size = 3 }; | |
21 | struct Stereo_Buffer { | 21 | |
22 | struct Blip_Buffer bufs [buf_count]; | 22 | // Tracked_Blip_Buffer |
23 | struct channel_t chan; | 23 | struct Tracked_Blip_Buffer { |
24 | int stereo_added; | 24 | struct Blip_Buffer blip; |
25 | int was_stereo; | 25 | int last_non_silence; |
26 | 26 | }; | |
27 | |||
28 | void Tracked_init( struct Tracked_Blip_Buffer* this ); | ||
29 | unsigned Tracked_non_silent( struct Tracked_Blip_Buffer* this ); | ||
30 | void Tracked_remove_all_samples( struct Tracked_Blip_Buffer * this ); | ||
31 | int Tracked_read_samples( struct Tracked_Blip_Buffer* this, blip_sample_t [], int ); | ||
32 | void Tracked_remove_silence( struct Tracked_Blip_Buffer* this, int ); | ||
33 | void Tracked_remove_samples( struct Tracked_Blip_Buffer* this, int ); | ||
34 | void Tracked_clear( struct Tracked_Blip_Buffer* this ); | ||
35 | void Tracked_end_frame( struct Tracked_Blip_Buffer* this, blip_time_t ); | ||
36 | |||
37 | static inline delta_t unsettled( struct Blip_Buffer* this ) | ||
38 | { | ||
39 | return this->reader_accum_ >> delta_bits; | ||
40 | } | ||
41 | |||
42 | // Stereo Mixer | ||
43 | struct Stereo_Mixer { | ||
44 | struct Tracked_Blip_Buffer* bufs [3]; | ||
45 | int samples_read; | ||
46 | }; | ||
47 | |||
48 | void Mixer_init( struct Stereo_Mixer* this ); | ||
49 | void Mixer_read_pairs( struct Stereo_Mixer* this, blip_sample_t out [], int count ); | ||
50 | |||
51 | typedef struct Tracked_Blip_Buffer buf_t; | ||
52 | |||
53 | // Multi_Buffer | ||
54 | struct Multi_Buffer { | ||
27 | unsigned channels_changed_count_; | 55 | unsigned channels_changed_count_; |
28 | long sample_rate_; | 56 | int sample_rate_; |
29 | int length_; | 57 | int length_; |
58 | int channel_count_; | ||
30 | int samples_per_frame_; | 59 | int samples_per_frame_; |
60 | int const *channel_types_; | ||
61 | bool immediate_removal_; | ||
62 | |||
63 | buf_t bufs [bufs_size]; | ||
64 | struct Stereo_Mixer mixer; | ||
65 | struct channel_t chan; | ||
31 | }; | 66 | }; |
32 | 67 | ||
33 | // Initializes Stereo_Buffer structure | 68 | blargg_err_t Buffer_set_channel_count( struct Multi_Buffer* this, int n, int const* types ); |
34 | void Buffer_init( struct Stereo_Buffer* this ); | 69 | |
70 | // Buffers used for all channels | ||
71 | static inline struct Blip_Buffer* center( struct Multi_Buffer* this ) { return &this->bufs [2].blip; } | ||
72 | static inline struct Blip_Buffer* left( struct Multi_Buffer* this ) { return &this->bufs [0].blip; } | ||
73 | static inline struct Blip_Buffer* right( struct Multi_Buffer* this ) { return &this->bufs [1].blip; } | ||
35 | 74 | ||
36 | blargg_err_t Buffer_set_sample_rate( struct Stereo_Buffer* this, long, int msec ); | 75 | // Initializes Multi_Buffer structure |
37 | void Buffer_clock_rate( struct Stereo_Buffer* this, long ); | 76 | void Buffer_init( struct Multi_Buffer* this ); |
38 | void Buffer_bass_freq( struct Stereo_Buffer* this, int ); | ||
39 | void Buffer_clear( struct Stereo_Buffer* this ); | ||
40 | struct channel_t Buffer_channel( struct Stereo_Buffer* this ); | ||
41 | void Buffer_end_frame( struct Stereo_Buffer* this, blip_time_t ); | ||
42 | 77 | ||
43 | long Buffer_read_samples( struct Stereo_Buffer* this, blip_sample_t*, long ); | 78 | blargg_err_t Buffer_set_sample_rate( struct Multi_Buffer* this, int, int msec ); |
79 | void Buffer_clock_rate( struct Multi_Buffer* this, int ); | ||
80 | void Buffer_bass_freq( struct Multi_Buffer* this, int ); | ||
81 | void Buffer_clear( struct Multi_Buffer* this ); | ||
82 | void Buffer_end_frame( struct Multi_Buffer* this, blip_time_t ) ICODE_ATTR; | ||
83 | |||
84 | static inline int Buffer_length( struct Multi_Buffer* this ) | ||
85 | { | ||
86 | return this->length_; | ||
87 | } | ||
44 | 88 | ||
45 | // Count of changes to channel configuration. Incremented whenever | 89 | // Count of changes to channel configuration. Incremented whenever |
46 | // a change is made to any of the Blip_Buffers for any channel. | 90 | // a change is made to any of the Blip_Buffers for any channel. |
47 | unsigned Buffer_channels_changed_count( struct Stereo_Buffer* this ); | 91 | static inline unsigned Buffer_channels_changed_count( struct Multi_Buffer* this ) |
48 | void Buffer_channels_changed( struct Stereo_Buffer* this ); | 92 | { |
49 | 93 | return this->channels_changed_count_; | |
50 | void Buffer_mix_stereo_no_center( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ); | 94 | } |
51 | void Buffer_mix_stereo( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ); | ||
52 | void Buffer_mix_mono( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ); | ||
53 | 95 | ||
54 | // Number of samples per output frame (1 = mono, 2 = stereo) | 96 | static inline void Buffer_disable_immediate_removal( struct Multi_Buffer* this ) |
55 | static inline int Buffer_samples_per_frame( struct Stereo_Buffer* this ) | ||
56 | { | 97 | { |
57 | return this->samples_per_frame_; | 98 | this->immediate_removal_ = false; |
58 | } | 99 | } |
59 | 100 | ||
60 | // See Blip_Buffer.h | 101 | static inline int Buffer_sample_rate( struct Multi_Buffer* this ) |
61 | static inline long Buffer_sample_rate( struct Stereo_Buffer* this ) | ||
62 | { | 102 | { |
63 | return this->sample_rate_; | 103 | return this->sample_rate_; |
64 | } | 104 | } |
65 | 105 | ||
66 | // Length of buffer, in milliseconds | 106 | static inline int Buffer_samples_avail( struct Multi_Buffer* this ) |
67 | static inline int Buffer_length( struct Stereo_Buffer* this ) | ||
68 | { | 107 | { |
69 | return this->length_; | 108 | return (Blip_samples_avail(&this->bufs [0].blip) - this->mixer.samples_read) * 2; |
70 | } | 109 | } |
71 | 110 | ||
111 | int Buffer_read_samples( struct Multi_Buffer* this, blip_sample_t*, int ) ICODE_ATTR; | ||
112 | struct channel_t Buffer_channel( struct Multi_Buffer* this, int i ); | ||
113 | |||
72 | #endif | 114 | #endif |