From acb0917556fc33681c1df5a530cf754193e67705 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Sun, 7 Aug 2011 20:01:04 +0000 Subject: Submit initial patch from FS#12176. Adds support for several new game music formats (AY, GBS, HES, KSS, SGC, VGM and VGZ) and replaces the current NSF and NSFE with a new implementation based on a port of the Game Music Emu library 'GME'. This first submit does not cover the full functionality provided by the author's original patch: Coleco-SGV is not supported, some GME-specific m3u-support has been removed and IRAM is not used yet. Further changes are very likely to follow this submit. Thanks to Mauricio Garrido. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30264 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libgme/multi_buffer.h | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 apps/codecs/libgme/multi_buffer.h (limited to 'apps/codecs/libgme/multi_buffer.h') 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 @@ +// Multi-channel sound buffer interface, and basic mono and stereo buffers + +// Blip_Buffer 0.4.1 +#ifndef MULTI_BUFFER_H +#define MULTI_BUFFER_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +// Get indexed channel, from 0 to channel count - 1 +struct channel_t { + struct Blip_Buffer* center; + struct Blip_Buffer* left; + struct Blip_Buffer* right; +}; + +enum { type_index_mask = 0xFF }; +enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; +enum { buf_count = 3 }; + +struct Stereo_Buffer { + struct Blip_Buffer bufs [buf_count]; + struct channel_t chan; + int stereo_added; + int was_stereo; + + unsigned channels_changed_count_; + long sample_rate_; + int length_; + int samples_per_frame_; +}; + +// Initializes Stereo_Buffer structure +void Buffer_init( struct Stereo_Buffer* this ); + +blargg_err_t Buffer_set_sample_rate( struct Stereo_Buffer* this, long, int msec ); +void Buffer_clock_rate( struct Stereo_Buffer* this, long ); +void Buffer_bass_freq( struct Stereo_Buffer* this, int ); +void Buffer_clear( struct Stereo_Buffer* this ); +struct channel_t Buffer_channel( struct Stereo_Buffer* this ); +void Buffer_end_frame( struct Stereo_Buffer* this, blip_time_t ) ICODE_ATTR; + +long Buffer_read_samples( struct Stereo_Buffer* this, blip_sample_t*, long ) ICODE_ATTR; + +// Count of changes to channel configuration. Incremented whenever +// a change is made to any of the Blip_Buffers for any channel. +unsigned Buffer_channels_changed_count( struct Stereo_Buffer* this ) ICODE_ATTR; +void Buffer_channels_changed( struct Stereo_Buffer* this ) ICODE_ATTR; + +void Buffer_mix_stereo_no_center( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ) ICODE_ATTR; +void Buffer_mix_stereo( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ) ICODE_ATTR; +void Buffer_mix_mono( struct Stereo_Buffer* this, blip_sample_t*, blargg_long ) ICODE_ATTR; + +// Number of samples per output frame (1 = mono, 2 = stereo) +static inline int Buffer_samples_per_frame( struct Stereo_Buffer* this ) +{ + return this->samples_per_frame_; +} + +// See Blip_Buffer.h +static inline long Buffer_sample_rate( struct Stereo_Buffer* this ) +{ + return this->sample_rate_; +} + +// Length of buffer, in milliseconds +static inline int Buffer_length( struct Stereo_Buffer* this ) +{ + return this->length_; +} + +#endif -- cgit v1.2.3