Comments (3)
Adding to this:
import numpy as np
from pedalboard import AudioFile
with AudioFile("test.wav", "w", 48000, 1) as f:
f.write(np.random.rand(1, 1))
Also fails for the same ChannelLayout detection. Of course this is an unrealistic minimal example, one has to consider instead a process loop where a chunk gets written to file: in that scenario, this bug can happen if the processing/stream size combination causes an iteration with a chunk of only one sample.
While in the 2x2 scenario the workaround would be to write one sample at a time (i.e. two buffers of shape (2, 1)), in the 1x1 no workaround is possible (writing an additional sample may not be acceptable if client code requires invariance of number of samples between pre-process and post-process).
from pedalboard.
Thanks for the super-detailed and well written bug report @mttbernardini!
You're totally right: the auto-detection of channel layout is a bit of a pain. I see a couple fixes that could be made, like you suggest:
-
For the
(1, n)
or(n, 1)
cases, auto-detection of layout could be more informed by the channel count of theAudioFile
object being used. This is a bug. -
For the square input case (i.e.:
(x, x)
) things are a little more tricky. While we could add an explicitChannelLayout
parameter as you suggest, I pretty strongly want to avoid adding additional parameters if possible.I totally forgot that I'd done this, but there's an example of how we can handle this in the Pedalboard codebase already:
StreamResampler
caches the last-detected channel layout and uses the last-provided layout if layout detection fails for a provided input. I think this approach would handle most real-world use cases, although it would still not solve the case in which the first buffer is square in shape.
from pedalboard.
Thank you for your reply @psobot.
I like the solution you proposed on point (2) and I believe having a scenario in which a Plugin
or WritableAudioFile
ever processes/writes just 1 or 2 samples is quite unlikely (it's more likely to process/writes 1 or 2 samples as a remainder after several big chunks). To be sure, we may want to specify this behaviour in the documentation and possibly make the raised RuntimeError
more detailed (or with a link to the docs if the description is too long).
I'm not sure I follow you for point (1) though. The behaviour of WritableAudioFile.write()
seems to match the behaviour of Plugin.process()
, i.e. raises a RuntimeError
when the input buffer is shaped (n, n)
. How would the channel count of the WritableAudioFile
help in detecting the channel layout? A stereo WritableAudioFile
that receives a (2, 2)
buffer would still fail. Rather, I believe your solution in point (2) can be adopted for WritableAudioFile
as well.
Let me know your thoughts and if you'd like me to implement this.
from pedalboard.
Related Issues (20)
- VST3 effect not getting applied
- Can I load a PyDub Audio Segment and pass it through pedalboard? HOT 3
- Question: AUv3 Support HOT 8
- Bug on Thread Example for `show_editor()`
- Question: Is it possible save and load Chunks for Plug-Ins ? HOT 2
- Question: Is it possible to write the output of an AudioStream to a .wav file as it's streaming? HOT 3
- Can we connect a VST instrument to an AudioStream?
- Type checking fails on any symbol exported by `pedalboard`
- Having an issue with Pitchshift, Distortion, Compression, being used with Azure TTS
- Changes in VST parameters reset to defaults when generating audio from MIDI HOT 2
- Segfault in time_stretch HOT 3
- Question: On demand file playback with effects HOT 2
- Seems the added information about AUv3 in the Documentation is not formatted correctly
- Segmentation fault (usually) when loading Spectrasonics VST3 plugins
- Very High Latency when using AudioStream with PitchShift on the PedalBoard
- SegmentationFault on Windows trying to user AudioFile or AudioStream HOT 1
- Stutering sound and high latency on Windows11 with ASIO driver (Scarlett Solo 3rd gen) HOT 1
- Crash when Appending Effects to Pedalboard Object on Windows 11 HOT 1
- Is there a way to make pedalboard work for 32bits systems ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pedalboard.