Tony Miller | 4 Apr 2010 10:03
Picon
Gravatar

[PATCH] GameMusicEmu decoder

I've written a patch for a decoder that uses the Game Music Emulation
library. This library suports many video game music formats. The patch
is available in the latest commit in my repository:

git <at> github.com:mcfiredrill/mpd.git

More information on this library is available here:
http://www.fly.net/~ant/libs/audio.html

Don't download it from there though, get the latest svn from here:
http://code.google.com/p/game-music-emu/source/checkout

If you need some sample music to try it out, get some super nintendo
.spc files from here:
http://snesmusic.org/

Hopefully I can help get this library into some distros soon.

Thanks!
-Tony

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Avuton Olrich | 5 Apr 2010 05:12
Picon
Gravatar

Re: [PATCH] GameMusicEmu decoder

On Sun, Apr 4, 2010 at 1:03 AM, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> I've written a patch for a decoder that uses the Game Music Emulation
> library. This library suports many video game music formats. The patch
> is available in the latest commit in my repository:
>
> git <at> github.com:mcfiredrill/mpd.git

Read-only git access:
git://github.com/mcfiredrill/mpd.git
--

-- 
avuton
--
If someone nearby has an iphone and leaves it near you, be aware they
may be spying on you.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Avuton Olrich | 5 Apr 2010 05:16
Picon
Gravatar

Re: [PATCH] GameMusicEmu decoder

On Sun, Apr 4, 2010 at 1:03 AM, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> I've written a patch for a decoder that uses the Game Music Emulation
> library. This library suports many video game music formats. The patch
> is available in the latest commit in my repository:
>
> git <at> github.com:mcfiredrill/mpd.git
>
> More information on this library is available here:
> http://www.fly.net/~ant/libs/audio.html
>
> Don't download it from there though, get the latest svn from here:
> http://code.google.com/p/game-music-emu/source/checkout
>
> If you need some sample music to try it out, get some super nintendo
> .spc files from here:
> http://snesmusic.org/
>
> Hopefully I can help get this library into some distros soon.
>
> Thanks!
> -Tony

Small detail:
diff --git a/src/decoder/gme_decoder_plugin.c b/src/decoder/gme_decoder_plugin.c
index 88afcd8..f75cb64 100644
--- a/src/decoder/gme_decoder_plugin.c
+++ b/src/decoder/gme_decoder_plugin.c
 <at>  <at>  -32,7 +32,7  <at>  <at>  gme_file_decode(struct decoder *decoder, const char *path_fs)
                song_len = ti->length / 1000.0;
        else song_len = -1;
(Continue reading)

Max Kellermann | 5 Apr 2010 11:20

Re: [PATCH] GameMusicEmu decoder

On 2010/04/04 10:03, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> I've written a patch for a decoder that uses the Game Music Emulation
> library. This library suports many video game music formats. The patch
> is available in the latest commit in my repository:
> 
> git <at> github.com:mcfiredrill/mpd.git
> 
> More information on this library is available here:
> http://www.fly.net/~ant/libs/audio.html
> 
> Don't download it from there though, get the latest svn from here:
> http://code.google.com/p/game-music-emu/source/checkout

Ok, finally got this "cmake" tool to work - cmake throws very obscure
error messages when you try to run it a second time with different
parameters (install prefix).

I havn't tried to run your plugin yet, though, but supporting more
codecs is always a good idea, so I will merge your patch, after some
formal changes:

- See Avuton's mail on the typo.

- Correct the number of dots:

  +       echo " GME support ....................enabled"
  +       echo " GME support ...................disabled"

- Correct indentation:

(Continue reading)

Tony Miller | 6 Apr 2010 08:52
Picon
Gravatar

Re: [PATCH] GameMusicEmu decoder



---------- Forwarded message ----------
From: Tony Miller <mcfiredrill <at> gmail.com>
Date: Mon, Apr 5, 2010 at 11:42 PM
Subject: Re: [Musicpd-dev-team] [PATCH] GameMusicEmu decoder
To: Max Kellermann <max <at> duempel.org>


On Mon, Apr 05, 2010 at 11:20:18AM +0200, Max Kellermann wrote:
> On 2010/04/04 10:03, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> > I've written a patch for a decoder that uses the Game Music Emulation
> > library. This library suports many video game music formats. The patch
> > is available in the latest commit in my repository:
> >
> > git <at> github.com:mcfiredrill/mpd.git
> >
> > More information on this library is available here:
> > http://www.fly.net/~ant/libs/audio.html
> >
> > Don't download it from there though, get the latest svn from here:
> > http://code.google.com/p/game-music-emu/source/checkout
>
> Ok, finally got this "cmake" tool to work - cmake throws very obscure
> error messages when you try to run it a second time with different
> parameters (install prefix).
>
> I havn't tried to run your plugin yet, though, but supporting more
> codecs is always a good idea, so I will merge your patch, after some
> formal changes:
>
> - See Avuton's mail on the typo.
>
> - Correct the number of dots:
>
>   +       echo " GME support ....................enabled"
>   +       echo " GME support ...................disabled"
>
Fixed.
> - Correct indentation:
>
>   +               cmd = decoder_data(decoder, NULL,
>   +                                       buf, GME_BUF_SIZE,
>
>   Should be:
>
>   +               cmd = decoder_data(decoder, NULL,
>   +                                  buf, GME_BUF_SIZE,
>
Can i just put it all on the same line, since its under 80 chars? I see
other sources in src/decoder that do that.
> - Why not set enable_gme=auto by default?  If this is a library with
>   an unstable API, we should of course only enable it if the user
>   explicitly wants it, so we don't break the build for others just in
>   case GME changes its API.
>

My thinking exactly, I thought enable_gme=no would accomplish this.
I noticed the other plugins use enable_*=auto however.

> - I don't think your error handling is correct:
>
>   +       if((gme_err = gme_open_file(path_fs, &emu, sample_rate)) != NULL)
>   +               g_warning("%s\n", gme_err);
>
>   I guess if gme_open_file() fails, you shouldn't be using the "emu"
>   variable because it wasn't initialized -> you should bail out of the
>   function.
>
>   Same for other error handlers.  Have you tried these code paths?

You're right, I definitely shouldn't try decoding the file if I can't even
open it! How about this in gme_file_decode():

+    if((gme_err = gme_open_file(path_fs, &emu, sample_rate)) != NULL){
+        g_warning("%s\n", gme_err);
+        gme_delete(emu);
+                return;
+    }
+    if((gme_err = gme_track_info(emu, &ti, 0)) != NULL){
+        g_warning("%s\n", gme_err);
+        gme_delete(emu);
+        return;
+    }
+    if((gme_err = gme_play(emu, GME_BUF_SIZE>>1, buf)) != NULL){
+        g_warning("%s\n", gme_err);
+        return;
+    }


And in tag dup:
+    if((gme_err = gme_open_file(path_fs, &emu, sample_rate)) != NULL){
+        g_warning("%s\n", gme_err);
+        gme_delete(emu);
+                return NULL;
+    }
+    if((gme_err = gme_track_info(emu, &ti, 0)) != NULL){
+        g_warning("%s\n", gme_err);
+        gme_delete(emu);
+        return NULL;
+    }

>
> - Use audio_format_init() or audio_format_init_checked() instead of
>   manually initializing the audio_format.  If we ever add another
>   attribute to that type, we don't need to change all initializers in
>   all plugins.

+#include "audio_check.h"

-    //audio_format.sample_rate = sample_rate;
-    //audio_format.format = SAMPLE_FORMAT_S16;
-    //audio_format.channels = 2;
-    //audio_format.reverse_endian = 0;
-    //assert(audio_format_valid(&audio_format));

+    GError *error = NULL;
+    if(!audio_format_init_checked(&audio_format, sample_rate, SAMPLE_FORMAT_S16,
+                      2, &error)){
+        g_warning("%s\n", error->message);
+        g_error_free(error);
+        gme_delete(emu);
+        gme_free_info(ti);
+        return;
+    }

>
> - Did you really implement seeking?  Your seeking code looks like a
>   no-op.
>
Yes, I forgot to add these lines in the commit(also made it a bit simpler):

               if(cmd == DECODE_COMMAND_SEEK) {
                       float where = decoder_seek_where(decoder);
-                       int s = (int)(where*1000);
-                       s += gme_tell(emu);
+                       if((gme_err = gme_seek(emu, (int)where*1000)) != NULL)
+                               g_warning("%s\n", gme_err);
                       decoder_command_finished(decoder);
               }



> - Remove the NULL struct initializers:
>
>   +       NULL, /* container scan */
>
>   If you don't implement a method, don't mention it.  If we ever
>   remove a method (which you didn't implement anyway), or if we change
>   their order, your plugin might break the build.
Done.

Will it work for you if I just push another commit with the changes, or
should I squash another commit with the fixes on top of the previous one?

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team
Max Kellermann | 6 Apr 2010 08:54

Re: [PATCH] GameMusicEmu decoder

On 2010/04/06 08:42, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> Can i just put it all on the same line, since its under 80 chars? I see
> other sources in src/decoder that do that.

Yes.  80 columns is always ok.

> +    if((gme_err = gme_open_file(path_fs, &emu, sample_rate)) != NULL){
> +        g_warning("%s\n", gme_err);
> +        gme_delete(emu);

Is that correct?  Does gme_open_file() allocate the second parameter
even if it returns with an error?

> +        g_warning("%s\n", error->message);

You don't need "\n" in GLib logging calls.

> +        gme_delete(emu);
> +        gme_free_info(ti);

Usually, it's a good idea to deallocate in reverse order, because a
"ti" may hold a reference to "emu".  Don't know about GME.

> Will it work for you if I just push another commit with the changes,
> or should I squash another commit with the fixes on top of the
> previous one?

I'd prefer to merge a single fixed commit.  stgit is a nice tool for
that!

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Tony Miller | 6 Apr 2010 10:01
Picon
Gravatar

Re: [PATCH] GameMusicEmu decoder

On Tue, Apr 06, 2010 at 08:54:59AM +0200, Max Kellermann wrote:
> On 2010/04/06 08:42, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> > +    if((gme_err = gme_open_file(path_fs, &emu, sample_rate)) != NULL){
> > +        g_warning("%s\n", gme_err);
> > +        gme_delete(emu);
> 
> Is that correct?  Does gme_open_file() allocate the second parameter
> even if it returns with an error?
> 
Upon further inspection of the GME source, gme_open_file appears to take
care of deleting "emu" for you if it returns an error, so gme_delete will be
unnecessary.

I'll try to get it to actually throw an error just to make sure.

> > +        gme_delete(emu);
> > +        gme_free_info(ti);
> 
> Usually, it's a good idea to deallocate in reverse order, because a
> "ti" may hold a reference to "emu".  Don't know about GME.
> 

Wouldn't I do this order then, to be in reverse:
+        gme_free_info(ti);
+        gme_delete(emu);

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Avuton Olrich | 6 Apr 2010 15:48
Picon
Gravatar

Re: [PATCH] GameMusicEmu decoder

On Sun, Apr 4, 2010 at 1:03 AM, Tony Miller <mcfiredrill <at> gmail.com> wrote:
> I've written a patch for a decoder that uses the Game Music Emulation
> library. This library suports many video game music formats. The patch
> is available in the latest commit in my repository:

One more typo:
diff --git a/configure.ac b/configure.ac
index ae00d14..d1cd0c9 100644
--- a/configure.ac
+++ b/configure.ac
 <at>  <at>  -533,7 +533,7  <at>  <at>  AC_ARG_ENABLE(gme,
        enable_gme=no)

 MPD_AUTO_PKG(gme, GME, [libgme],
-       [gme deocder plugin], [libgme not found])
+       [gme decoder plugin], [libgme not found])
 AM_CONDITIONAL(HAVE_GME, test x$enable_gme = xyes)
 if test x$enable_gme = xyes; then
        AC_DEFINE(HAVE_GME, 1, [Define for gme support])
--

-- 
avuton
--
If someone nearby has an iphone and leaves it near you, be aware they
may be spying on you.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

Gmane