Skip to content

Conversation

@psobot
Copy link
Member

@psobot psobot commented Mar 7, 2022

This PR adds:

  • pedalboard.io, a new submodule containing audio input/output classes
  • pedalboard.io.AudioFile, a base class for interfacing with audio files
  • pedalboard.io.ReadableAudioFile, a concrete class for reading audio files
  • pedalboard.io.WriteableAudioFile, a concrete class for writing audio files
  • Tests for the above
  • Examples in the README.

Questions that may arise from this change:

  • Why are these useful or necessary?
    • Most Python audio reading/writing libraries are single-format (pymad, pyogg, etc), require DLLs to be installed (PySoundFile), or sometimes shell out to FFMPEG (audioread, librosa). Pedalboard (by virtue of JUCE) has the ability to provide high-performance audio reading and writing functionality out-of-the-box without much code, removing the need for third-party dependencies. In tests, this code is up to 20x faster than librosa.load in certain cases (without resampling).
  • Should this be part of Pedalboard, or a separate library?
    • Given that Pedalboard already includes JUCE under the hood, and that adding these classes inflates the binary size by only kilobytes, it seems pragmatic to include these classes here rather than creating a separate library that would itself be a couple MB in size.
  • Why are not all formats supported?
    • This PR wraps JUCE's AudioFormatReader and AudioFormatWriter interfaces, which only support reading and writing a certain set of audio formats out-of-the-box. Notably, Pedalboard already includes libmp3lame, which could be used to create a custom AudioFormatWriter subclass to allow for MP3 file writing out-of-the-box.

@psobot psobot linked an issue Mar 8, 2022 that may be closed by this pull request
@psobot psobot changed the title Add pedalboard.io submodule containing audio file reading and writing code. Add pedalboard.io.AudioFile. Mar 9, 2022
@psobot psobot merged commit 84ae18b into master Mar 13, 2022
@psobot psobot deleted the psobot/io branch March 13, 2022 15:12
@faroit
Copy link

faroit commented Mar 23, 2022

@psobot nice PR!

@psobot
Copy link
Member Author

psobot commented Mar 23, 2022

Thanks @faroit!

did you test seeking performance against ...e.g. soundfile?

Not extensively, but a quick test (reading a WAV file backwards, sample-by-sample, by seeking to each sample first) seems to show Pedalboard is more than 6x faster than PySoundFile when seeking. (Pedalboard was able to seek at 224,671 seeks/sec, while SoundFile seeked at 34,691 seeks/sec.)

would you be able to create PR for https://github.com/faroit/python_audio_loading_benchmark/ ?

Done!

@keunwoochoi
Copy link

this is great!

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

Successfully merging this pull request may close these issues.

OSError: sndfile library not found

4 participants