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

Change channel limit from 2 to 32. #228

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

kleblackford
Copy link

Implementation of the changes recommended in #97 to enable the use of plug-ins with more than 2 channels.

A limit of 32 channels is chosen as for plug-ins with more than 36 input/output channels, the bus sizes are recognised incorrectly. The JUCE projects used to create the effects plug-ins used to test these changes can be provided if needed.

A 32 channel unity gain effect plug-in was created and added to the test effect plug-ins folder.

A basic test for the unity gain plug-in is also implemented.

@psobot
Copy link
Member

psobot commented Jul 11, 2023

Hi @kleblackford!

Thanks for this - especially including a JUCE plugin to test with!

I have one architectural concern here: Pedalboard allows users to to pass any shape of input buffer ([num_channels, num_samples] or [num_samples, num_channels]). This works for most cases because the maximum channel count (of 2) makes it hard to mis-identify buffer shapes. Increasing the maximum channel count to 32 also effectively forces users to pass at least 32 samples in each buffer, as passing a smaller number of samples (i.e.: [32, 2]) would make the auto-detection ambiguous.

I think the way around this would be to modify the detectChannelLayout function to accept an additional parameter, indicating the maximum number of channels supported by the plugin being rendered. We can then use that to help guide the auto-detection of input buffer shape.

Let me know if you're comfortable attempting to make this change - I'm happy to give it a try over the next week or two if it helps.

(And please do share the JUCE projects used to generate this test plugin; I'd love to compile versions for macOS and Linux as well, and would help avoid including a 12MB un-auditable binary blob in the repo.)

@kleblackford
Copy link
Author

Hi @psobot,

I see what you mean there. So what would need implementing is a check that for a maximum channel count n and an input array shape [i, j] that i > n | j > n? I can give this a go although I am quite inexperienced with JUCE/c++...

In the latest commits, I added a JUCE project which can be used to create simple unity gain plug-ins. The two lines here can be changed to modify number the channels. I could also create some simple multiplexer plugin projects which would be useful for testing solutions for #138.

In the last commits, I also made some modifications for the tests to pass. In these, some of the tests which are not relevant in the case of the unity gain plugin are skipped. The 32 channel unity gain plugin test has also been refactored/corrected.

@psobot
Copy link
Member

psobot commented Jul 12, 2023

I see what you mean there. So what would need implementing is a check that for a maximum channel count n and an input array shape [i, j] that i > n | j > n? I can give this a go although I am quite inexperienced with JUCE/c++...

Correct, yes! The maximum channel count should come from the first plugin being used for rendering.

@adrianSRoman
Copy link

@kleblackford — would you expect this branch to work on array2sh from SPARTA? https://leomccormack.github.io/sparta-site/

I have tried using this branch to encode raw eigenmike32 data into FOA format using the array2sh VST3. For some reason I am running into issues:

[logging] inp_audio shape: (32, 720000), fs:24000.0
Traceback (most recent call last):
  File "array2sh.py", line 95, in <module>
    process(inp_path=args.input_filepath,
  File "array2sh.py", line 73, in process
    out_audio = array_2_sh_vst(inp_audio, sr, num_channels=32)
TypeError: __call__(): incompatible function arguments. The following argument types are supported:
    1. (self: pedalboard_native.Plugin, input_array: numpy.ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) -> numpy.ndarray[numpy.float32]
    2. (self: pedalboard_native.VST3Plugin, midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) -> numpy.ndarray[numpy.float32]

Invoked with: <pedalboard.VST3Plugin "sparta_array2sh" at 0x600003d2ca18>, array([[0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ..., 1.7395550e-03,
        2.1668142e-03, 2.5330363e-03],
       [0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ..., 2.4719993e-03,
        2.8077029e-03, 3.1739250e-03],
       [0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ..., 2.1057772e-03,
        2.5330363e-03, 2.9602954e-03],
       ...,
       [0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ..., 3.0518509e-05,
        5.1881466e-04, 1.0681478e-03],
       [0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ..., 3.6622211e-04,
        8.5451826e-04, 1.4038514e-03],
       [0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ..., 1.1597034e-03,
        1.5564440e-03, 2.0447401e-03]], dtype=float32), 24000.0; kwargs: num_channels=32

@kleblackford
Copy link
Author

kleblackford commented Aug 15, 2023

@adrianSRoman - call the plugin without the num_channels argument (this is determined automatically from the input signal) - eg. out_audio = array_2_sh_vst(inp_audio, sr)

See the test here for an example of how to call a 32 channel in/out plugin.

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.

None yet

3 participants