From c73894213d7f1c53eac7ea3d08ce9dbe0187aa33 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 6 Mar 2013 19:36:24 -0500 Subject: VGM Codec: Improve time and fade behavior. Tweak minor misc. Prevents cutoff of tracks, especially short ones: * Extend looped tracks by fade length to fade at start of loop repeat. * No fade occurs for non-repeating track only having an intro. * Uses id3.tail_trim field to store fade duration. Use libGME built-in elapsed time reporting instead of custom calculation: * libGME already reports in milliseconds. * Don't advance time counter when Repeat == One. It just runs the progress over the length limit. Fix a comment about sample rate and set the reported bitrate to be accurate for 44.1 kHz stereo. Change-Id: I3ede22bda0f9a941a3fef751f4d678eb0027344c --- lib/rbcodec/metadata/vgm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/rbcodec/metadata') diff --git a/lib/rbcodec/metadata/vgm.c b/lib/rbcodec/metadata/vgm.c index 7d3f45e204..03afb15a92 100644 --- a/lib/rbcodec/metadata/vgm.c +++ b/lib/rbcodec/metadata/vgm.c @@ -113,6 +113,8 @@ static long check_gd3_header( byte* h, long remain ) static void get_vgm_length( struct header_t* h, struct mp3entry* id3 ) { long length = get_long_le( h->track_duration ) * 10 / 441; + id3->tail_trim = 4 * 1000; /* assume fade */ + if ( length > 0 ) { long loop_length = 0, intro_length = 0; @@ -126,13 +128,15 @@ static void get_vgm_length( struct header_t* h, struct mp3entry* id3 ) { intro_length = length; /* make it clear that track is no longer than length */ loop_length = 0; + id3->tail_trim = 0; } - id3->length = intro_length + 2 * loop_length; /* intro + 2 loops */ - return; + /* intro + 2 loops + fade */ + id3->length = intro_length + 2 * loop_length + id3->tail_trim; + return; } - id3->length = 150 * 1000; /* 2.5 minutes */ + id3->length = 150 * 1000 + id3->tail_trim; /* 2.5 minutes + fade */ } bool get_vgm_metadata(int fd, struct mp3entry* id3) @@ -151,7 +155,7 @@ bool get_vgm_metadata(int fd, struct mp3entry* id3) id3->vbr = false; id3->filesize = filesize(fd); - id3->bitrate = 706; + id3->bitrate = 1411; id3->frequency = 44100; /* If file is gzipped, will get metadata later */ -- cgit v1.2.3