spotify / pedalboard

🎛 🔊 A Python library for audio.

Home Page:https://spotify.github.io/pedalboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Limiter Plugin seems also to normalize?

Franky1 opened this issue · comments

The internal plugin Limiter seems also to normalize the output.
If i put in the Limiter in a board and examine the output, it is always scaled to [-1.0; +1.0] after the Limiter.
I would not expect this behaviour, is it intended?
Example code to reproduce:

pedalboard = Pedalboard(
    [
        Limiter(),
    ],
)

# Open input file:
with ReadableAudioFile(filename="input.wav") as f:
    # Open an audio file to write to:
    with WriteableAudioFile(filename="output.wav", samplerate=f.samplerate, num_channels=f.num_channels, bit_depth=16) as outfile:
        # Read all the frames from the file:
        chunk = f.read(f.frames).flatten()
        print(f"type chunk: {type(chunk)}")
        print(f"size chunk: {chunk.shape}")
        print(f"max chunk: {chunk.max()}")
        print(f"min chunk: {chunk.min()}")
        # Run the audio through our pedalboard:
        effected = pedalboard(chunk, f.samplerate, reset=False)
        print(f"type effected: {type(effected)}")
        print(f"size effected: {effected.shape}")
        print(f"max effected: {effected.max()}")
        print(f"min effected: {effected.min()}")
        # Write the output to our output file:
        outfile.write(effected)

For example i get this output:

type chunk: <class 'numpy.ndarray'>
size chunk: (109656,)
max chunk: 0.6926786303520203
min chunk: -0.5552842617034912
type effected: <class 'numpy.ndarray'>
size effected: (109656,)
max effected: 1.0
min effected: -1.0
commented

First, pedalboard is really awesome open source lib, Thanks!

I too discovered that the Limiter() is not just limiting after finding out that the output files look like maxed out bricks.
I hoped to pass the audio through Limiter() to ensure there is no hard clipping.

The documentation is a bit lacking, just mentioning that there are two compressors inside and one can set threshold_db. Without knowing compressor ratio etc its hard to tell what the threshold_db exactly does.

Could you add an optional argument to bypass the internal compression part to have just pure Limiter?