Author Topic: reading mp3 files?  (Read 19315 times)

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
reading mp3 files?
« on: March 09, 2009, 14:51:10 »
Hi all,
I just started using Vamp plugins for my project, and following the code in vamp-plugin-sdk-2.0/host/vamp-simple-host.cpp, I've managed to create a program to read in the plugins and run them. However, in my project, I'm extensively using mp3 files. (I read and process them with Marsyas compiled with madlib). From vamp-simple-host's code, it seems libsndfile is used to read in the file. This results in it only being able to read in wav files. Is there any (hopefully simple) way I can get Vamp plugins to read in mp3 files?

Thank you very much!

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: reading mp3 files?
« Reply #1 on: March 11, 2009, 14:30:21 »

Nothing about Vamp plugins themselves has any bearing on the file types your host can support -- you just have to be able to decode the audio file and pass the decoded data to the plugin.  The plugin neither knows nor cares what file type the data came from, and it certainly cannot decode mp3 or any other compressed format itself.

So, I'm afraid, your question really comes down to "how do I read and decode an mp3 file in my program?"

I imagine your choice really is to use an mp3 decoder library such as madlib (if license and so on permit), or to run the plugin host in some sort of scripting environment in which the mp3 file is decoded by a separate decoder program run in a script or batch process (e.g. mpg321) and the resulting wav file is fed to the host.

If it's any help, Sonic Annotator (http://omras2.org/SonicAnnotator) can run Vamp plugins on mp3 files, but it pulls in an awful lot of code to do so because it pulls in (GPL-licensed) libraries from Sonic Visualiser in order to save development time.  I wouldn't necessarily advise that approach if all you want is to read an mp3, but it might be worth taking a look at it.


Chris

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: reading mp3 files?
« Reply #2 on: March 11, 2009, 14:56:01 »
Ah, ok thanks! :) will look into it :)

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
0 tempo?
« Reply #3 on: March 11, 2009, 15:52:56 »
oh! another question:

I tried running the example plugins and several of the other downloadable plugins' tempo extractors but I keep getting 0 results. any ideas? I'm running them on wavs, and can see it being processed (i.e., i see a loooooong list of timestamps) but everything is 0. :(

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: 0 tempo?
« Reply #4 on: March 11, 2009, 17:25:12 »
I tried running the example plugins and several of the other downloadable plugins' tempo extractors but I keep getting 0 results. any ideas? I'm running them on wavs, and can see it being processed (i.e., i see a loooooong list of timestamps) but everything is 0. :(

Does this happen if you run them with vamp-simple-host, or only with the code that you're working on?

It certainly doesn't sound (on first reading) like a problem I know about or would expect to see.


Chris

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: 0 tempo?
« Reply #5 on: March 12, 2009, 07:02:15 »
it happens with vamp-simple-host as well.. :/ unless there's a problem with the wav files I'm using.. But I've tried using many different wav files from various different sources and it's all 0... :(

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: reading mp3 files?
« Reply #6 on: March 12, 2009, 10:29:22 »
it happens with vamp-simple-host as well.. :/

Can you describe exactly what you are running and what the output is, please?  Perhaps cut-and-paste a terminal session into a post here, including the full vamp-simple-host command line and at least some representative part of its output.

Thanks,


Chris

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: reading mp3 files?
« Reply #7 on: March 12, 2009, 11:26:01 »
arguments:

vamp-example-plugins:fixedtempo 0rW4y2QB5AA.wav

output (from netbeans):

application_1: Running...
Reading file: "0rW4y2QB5AA.wav", writing to standard output
22050
Running plugin: "fixedtempo"...
Using block size = 256, step size = 64
Plugin accepts 1 -> 1 channel(s)
Sound file has 1 (will mix/augment if necessary)
Output is: "tempo"
PluginChannelAdapter::initialise: accepting given number of channels (1)
No tempo candidates!
[Press Enter to close window]



cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: reading mp3 files?
« Reply #8 on: March 12, 2009, 11:38:07 »
Thanks.  That is rather odd.  Any chance you could attach one of your test WAV files, or email it to me at cannam (at) all-day-breakfast (dot) com, so I can see whether I can reproduce the problem?

What platform is this, by the way?


Chris

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: reading mp3 files?
« Reply #9 on: March 12, 2009, 12:26:27 »
I'm running it on Ubuntu.. and here's a link to the file:
https://www.yousendit.com/download/U0d3eUNQYWJFc0t4dnc9PQ

I thought of sending it to you by email but it's 11MB o.o

Here's a smaller one but has the same problem:
https://www.yousendit.com/download/U0d3eUNLU1A0b0JjR0E9PQ

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: reading mp3 files?
« Reply #10 on: March 12, 2009, 12:52:09 »
Ah.  I think the problem here is kind of simple -- the FixedTempoEstimator, being a stupid soul, only looks at the start of the audio file and assumes that the remainder is the same in terms of tempo.  However, this file (not unusually) has silence at the start, so it's quite lost.

The host would have to feed it a different section of the file in order to get any result -- and this is not something vamp-simple-host can do, though you can do it in Sonic Visualiser with a selection and the "restrict to selection extents" option in the plugin parameters dialog.

This shouldn't be a problem for other plugins, though -- for example, qm-vamp-plugins.so:qm-tempotracker:tempo (as argument to vamp-simple-host) should give you a list of tempo estimates, with a new value each time the tempo tracker thinks the tempo has changed.

It may be worth noting that none of the published tempo trackers is likely to work very well with this particular recording.  (Nice recording, by the way.)


Chris

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: reading mp3 files?
« Reply #11 on: March 12, 2009, 12:55:57 »
haha thanks :) I've tried with the qm one too and got nothing too though.. :x

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: reading mp3 files?
« Reply #12 on: March 14, 2009, 04:03:55 »
bump?

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: reading mp3 files?
« Reply #13 on: March 17, 2009, 13:25:20 »
Sorry, what output does vamp-simple-host give with the QM tempo tracker, then?  I have tried it with your example file, and I see a list of 584 beat locations printed to stdout (one per line, just the beat time followed by a colon because there is no other data associated with each beat).


Chris

no0b

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: reading mp3 files?
« Reply #14 on: March 18, 2009, 02:54:06 »
Hi! Oh so that's the beats? oh! ok thanks! I was looking for information after the semicolon cos I was under the impression that each timestamp was like 1 frame.

Thanks!! :D:D:D