Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP3 support #12

Closed
nomeata opened this issue Jul 14, 2023 · 5 comments
Closed

MP3 support #12

nomeata opened this issue Jul 14, 2023 · 5 comments

Comments

@nomeata
Copy link

nomeata commented Jul 14, 2023

I’m considering using proteaaudio in one of my projects where I currently shell out to sox. One feature I’ll probably miss is support for MP3 in addition to WAV and OGG. Is that by any chance on your road map and I can just wait for that, or would I have to work around it anyways?

@csabahruska
Copy link
Owner

IMO I could add MP3 support. This lib looks promising: https://github.com/lieff/minimp3
I prefer single file solutions without external dependencies.

@nomeata
Copy link
Author

nomeata commented Jul 15, 2023

That would be great!

@csabahruska
Copy link
Owner

I've added MP3 support. Please check it and if it works for you then I'll make a new release on Hackage.
aa48206

nomeata added a commit to entropia/tip-toi-reveng that referenced this issue Jul 22, 2023
@nomeata
Copy link
Author

nomeata commented Jul 22, 2023

Works flawlessly!

In my application I need to handle different formats without knowing their filename, and will use logic like this

sampleFromMemory :: B.ByteString -> Float -> IO Sample
sampleFromMemory bs
  | B.take 4 bs == B.pack "RIFF" = sampleFromMemoryWav (B.toStrict bs)
  | B.take 4 bs == B.pack "OggS" = sampleFromMemoryOgg (B.toStrict bs)
  | B.take 3 bs == B.pack "ID3" || B.take 2 bs `elem`
      [B.pack "\xFF\xFB", B.pack "\xFF\xF3", B.pack "\xFF\xF2"]
  = sampleFromMemoryMp3 (B.toStrict bs)
  | otherwise = error "Could not detect audio format"
 where magic = B.take 4 bs

If you think that logic would actually be good to have in proteaaudio itself, I’ll of course prefer that :-)

Besides that I think I’m good for now, thanks!

@csabahruska
Copy link
Owner

Released proteaaudio-0.10.1 with mp3 support and sampleFromMemory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants