GME: Play SPC and SFM files at 32 kHz
And let the player itself resample them, as necessary. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
d4990de7f3
commit
b40d5eecc5
2 changed files with 12 additions and 6 deletions
|
@ -12,11 +12,12 @@
|
||||||
|
|
||||||
#import "Plugin.h"
|
#import "Plugin.h"
|
||||||
|
|
||||||
extern gme_err_t readCallback( void* data, void* out, long count );
|
extern gme_err_t readCallback( void* data, void* out, int count );
|
||||||
|
|
||||||
@interface GameDecoder : NSObject <CogDecoder> {
|
@interface GameDecoder : NSObject <CogDecoder> {
|
||||||
Music_Emu* emu;
|
Music_Emu* emu;
|
||||||
id<CogSource> source;
|
id<CogSource> source;
|
||||||
|
long sampleRate;
|
||||||
long length;
|
long length;
|
||||||
long fade;
|
long fade;
|
||||||
NSString* codec;
|
NSString* codec;
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
@implementation GameDecoder
|
@implementation GameDecoder
|
||||||
|
|
||||||
gme_err_t readCallback( void* data, void* out, long count )
|
gme_err_t readCallback( void* data, void* out, int count )
|
||||||
{
|
{
|
||||||
id source = (__bridge id)data;
|
id source = (__bridge id)data;
|
||||||
DLog(@"Amount: %li", count);
|
DLog(@"Amount: %i", count);
|
||||||
int n = (int) [source read:out amount:count];
|
int n = (int) [source read:out amount:count];
|
||||||
DLog(@"Read: %i", n);
|
DLog(@"Read: %i", n);
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
|
@ -57,8 +57,13 @@ gme_err_t readCallback( void* data, void* out, long count )
|
||||||
ALog(@"GME: No type!");
|
ALog(@"GME: No type!");
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sampleRate = 44100;
|
||||||
|
|
||||||
|
if (type == gme_spc_type || type == gme_sfm_type)
|
||||||
|
sampleRate = 32000;
|
||||||
|
|
||||||
emu = gme_new_emu(type, 44100);
|
emu = gme_new_emu(type, sampleRate);
|
||||||
if (!emu)
|
if (!emu)
|
||||||
{
|
{
|
||||||
ALog(@"GME: No new emu!");
|
ALog(@"GME: No new emu!");
|
||||||
|
@ -154,8 +159,8 @@ gme_err_t readCallback( void* data, void* out, long count )
|
||||||
{
|
{
|
||||||
return [NSDictionary dictionaryWithObjectsAndKeys:
|
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithInt:0], @"bitrate",
|
[NSNumber numberWithInt:0], @"bitrate",
|
||||||
[NSNumber numberWithFloat:44100], @"sampleRate",
|
[NSNumber numberWithFloat:(float)sampleRate], @"sampleRate",
|
||||||
[NSNumber numberWithLong:length*44.1], @"totalFrames",
|
[NSNumber numberWithLong:length*((float)sampleRate * 0.001)], @"totalFrames",
|
||||||
[NSNumber numberWithInt:sizeof(short)*8], @"bitsPerSample", //Samples are short
|
[NSNumber numberWithInt:sizeof(short)*8], @"bitsPerSample", //Samples are short
|
||||||
[NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo
|
[NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo
|
||||||
[NSNumber numberWithBool:[source seekable]], @"seekable",
|
[NSNumber numberWithBool:[source seekable]], @"seekable",
|
||||||
|
|
Loading…
Reference in a new issue