summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/multi_buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/multi_buffer.h')
-rw-r--r--apps/codecs/libgme/multi_buffer.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/apps/codecs/libgme/multi_buffer.h b/apps/codecs/libgme/multi_buffer.h
new file mode 100644
index 0000000000..26f302380c
--- /dev/null
+++ b/apps/codecs/libgme/multi_buffer.h
@@ -0,0 +1,72 @@
1// Multi-channel sound buffer interface, and basic mono and stereo buffers
2
3// Blip_Buffer 0.4.1
4#ifndef MULTI_BUFFER_H
5#define MULTI_BUFFER_H
6
7#include "blargg_common.h"
8#include "blip_buffer.h"
9
10// Get indexed channel, from 0 to channel count - 1
11struct channel_t {
12 struct Blip_Buffer* center;
13 struct Blip_Buffer* left;
14 struct Blip_Buffer* right;
15};
16
17enum { type_index_mask = 0xFF };
18enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type };
19enum { buf_count = 3 };
20
21struct Stereo_Buffer {
22 struct Blip_Buffer bufs [buf_count];
23 struct channel_t chan;
24 int stereo_added;
25 int was_stereo;
26
27 unsigned channels_changed_count_;
28 long sample_rate_;
29 int length_;
30 int samples_per_frame_;
31};
32
33// Initializes Stereo_Buffer structure
34void Buffer_init( struct Stereo_Buffer* this );
35
36blargg_err_t Buffer_set_sample_rate( struct Stereo_Buffer* this, long, int msec );
37void Buffer_clock_rate( struct Stereo_Buffer* this, long );
38void Buffer_bass_freq( struct Stereo_Buffer* this, int );
39void Buffer_clear( struct Stereo_Buffer* this );
40struct channel_t Buffer_channel( struct Stereo_Buffer* this );
41void Buffer_end_frame( struct Stereo_Buffer* this, blip_time_t ) ICODE_ATTR;
42
43long Buffer_read_samples( struct Stereo_Buffer* this, blip_sample_t*, long ) ICODE_ATTR;
44
45// Count of changes to channel configuration. Incremented whenever
46// a change is made to any of the Blip_Buffers for any channel.
47unsigned Buffer_channels_changed_count( struct Stereo_Buffer* this ) ICODE_ATTR;
48void Buffer_channels_changed( struct Stereo_Buffer* this ) ICODE_ATTR;
49
50void Buffer_mix_stereo_no_center( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ) ICODE_ATTR;
51void Buffer_mix_stereo( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ) ICODE_ATTR;
52void Buffer_mix_mono( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ) ICODE_ATTR;
53
54// Number of samples per output frame (1 = mono, 2 = stereo)
55static inline int Buffer_samples_per_frame( struct Stereo_Buffer* this )
56{
57 return this->samples_per_frame_;
58}
59
60// See Blip_Buffer.h
61static inline long Buffer_sample_rate( struct Stereo_Buffer* this )
62{
63 return this->sample_rate_;
64}
65
66// Length of buffer, in milliseconds
67static inline int Buffer_length( struct Stereo_Buffer* this )
68{
69 return this->length_;
70}
71
72#endif