spotify / pedalboard

🎛 🔊 A Python library for audio.
https://spotify.github.io/pedalboard
GNU General Public License v3.0
5.15k stars 260 forks source link

Release the GIL when calling .read() on a ResampledReadableAudioFile. #283

Closed psobot closed 9 months ago

psobot commented 9 months ago

Prior to this PR, calling .read() on a ResampledReadableAudioFile would not release Python's GIL when doing its (potentially very expensive) resampling calculations. This PR releases the GIL as much as possible to allow multiple threads to resample audio simultaneously. (The GIL could be released even further by refactoring the ReadableAudioFile interface to avoid copies through the py::array_t type; but that's not quite in scope for this PR.)

psobot commented 9 months ago

🍐 with @gilles.