Shop OBEX P1 Docs P2 Docs Learn Events
MP3 decoder works! — Parallax Forums

MP3 decoder works!

RaymanRayman Posts: 13,851
edited 2013-05-17 03:29 in Propeller 1
Just played with libmad, an mp3 decoding software...

Only took a few minutes to get this going with PropGCC, now that I have xmm going with Rampage2.

It's nowhere near real time, but it actually works!

Maybe with Prop2 it could be used for real time playback.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-05-15 11:06
    Cool. Congratulations!

    ... another impossible one bites the dust?
  • PublisonPublison Posts: 12,366
    edited 2013-05-15 11:11
    Nice Ray,

    I always thought MP3 Decoding require a license.
  • RaymanRayman Posts: 13,851
    edited 2013-05-15 11:13
    My understanding is that software decoding doesn't require a license...
    But, I'm no lawyer...
  • RaymanRayman Posts: 13,851
    edited 2013-05-15 11:17
    Here's my quick hack of minimad.c that made this work...

    minimad is a tiny top level program that you can use to work with the libmad decoder.

    What I did here is copy a whole mp3 file from Rampage2's uSD to memory.
    test4b.mp3 is only a few kb, so there's plenty of room for it.

    Then, I opened the wav version of test4b (test4b.wav) so that I could steal it's 44 byte header.

    Then, I opened the output file, test.wav, and wrote that header.

    Then, I called libmad and gave it the address of the mp3 file in memory.

    Here's the output file (test.wav) too. There's a small glitch at the end for some reason, probably because the header has the wrong file length...
  • jazzedjazzed Posts: 11,803
    edited 2013-05-15 11:21
    Publison wrote: »
    I always thought MP3 Decoding require a license.

    Just curious. Who owns the licensing rights?
  • Heater.Heater. Posts: 21,230
    edited 2013-05-15 11:37
    Well, google tells me these people at least claim to:
    http://mp3licensing.com/royalty/

    looks like most of patents are expiring soon:

    http://mp3licensing.com/patents/index.html

    I say f'em. Around here software is not patentable anyway.

    If you want to see how confusing this all is see:

    http://en.wikipedia.org/wiki/MP3
  • PublisonPublison Posts: 12,366
    edited 2013-05-15 16:22
    Looks like Heater did all the grunt work for me. Thanks Heater.

    I have always been under the impression that you had to buy a hardware MP3 decoder solution. That's why I bought hardware like the VMUSIC2 . My thinking was that they had bought the license and I could just use it and be done with it.

    My have to read more about this now.

    EDIT Sorry... it's Heater. now. I forgot :)
  • RaymanRayman Posts: 13,851
    edited 2013-05-15 16:41
    I don't know if Wikipedia would hold up in court, but they say this:
    Additionally, patent holders have declined to enforce license fees on free and open source decoders, which has allowed many free MP3 decoders to be developed.

    libmad is both free and open source (GNU license), so I think it qualifies...


    I'd love to try this out on a P2...
    Should be very much faster with the multiply instruction...
  • PublisonPublison Posts: 12,366
    edited 2013-05-15 17:19
    Rayman wrote: »
    I don't know if Wikipedia would hold up in court, but they say this:
    Additionally, patent holders have declined to enforce license fees on free and open source decoders, which has allowed many free MP3 decoders to be developed.

    libmad is both free and open source (GNU license), so I think it qualifies...


    I'd love to try this out on a P2...
    Should be very much faster with the multiply instruction...

    Maybe it was my understanding may moons ago when I first looked into MP3 players, (maybe 10 years ago?). At that time it was just hardware you could buy and it was license free.

    So good that we now have a software option. Thanks for trying that out Ray!
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-05-15 17:24
    So does this mean we can now play MP3's using a Prop? If so this is perfect for my Micro Medic project!!!
  • RaymanRayman Posts: 13,851
    edited 2013-05-15 17:27
    You can... If you're willing to wait...
    I haven't timed it, but I'd say it decodes at a rate of 1 minute per 1 second of playback, or 1/60th of real time...

    This is really more about P2 than P1.

    But, perhaps in mono and at a very, very low bitrate you could make it work at 10 seconds per 1 second of playback.
    Still not very exciting.

    Lossless .wav playback is a much better solution for P1...
  • jac_goudsmitjac_goudsmit Posts: 418
    edited 2013-05-16 07:01
    Rayman wrote: »
    You can... If you're willing to wait...
    I haven't timed it, but I'd say it decodes at a rate of 1 minute per 1 second of playback, or 1/60th of real time...

    This is really more about P2 than P1.

    But, perhaps in mono and at a very, very low bitrate you could make it work at 10 seconds per 1 second of playback.
    Still not very exciting.

    Lossless .wav playback is a much better solution for P1...

    I suspect that MPEG1 layer 1 or ADPCM would be within the realms of decoding realtime by the Prop1. They don't provide as much compression (think 4:1 instead of 10:1) but with 8 cogs at 80MHz... I'm thinking doable.

    ===Jac
  • RaymanRayman Posts: 13,851
    edited 2013-05-16 07:41
    This code can also do MP1 and MP2 decoding...
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-05-16 08:25
    Some references that I've seen state that layer 3 decoding requires about 40 MIPS. I don't know what portion of that is multiplies and accumulates, but it's probably a significant portion. P1 is capable of 20 MIPS per cog, but since multiplications are implemented in software it would be difficult to implement a real-time MP3 decoder. However, with P2's hardware multiplier it's conceivable that an MP3 decoder could be implemented in one cog.
  • RaymanRayman Posts: 13,851
    edited 2013-05-16 08:35
    yes, the lack of a 16-bit multiply instruction on P1 is why it will never be real time on P1.
    But, P2 has this, so I think it will easy run in 1 cog...
  • BaggersBaggers Posts: 3,019
    edited 2013-05-17 03:29
    Congrats Rayman :)
Sign In or Register to comment.