pedalboard icon indicating copy to clipboard operation
pedalboard copied to clipboard

Limiter doesn't work.

Open MMMMichaelzhang opened this issue 6 months ago • 0 comments

Here is my code, when I add Reverb or any other effector, it works fine, but when I add limiter, no matter what value I set my thresthold_db to, the sound is very low, almost inaudible.

from pedalboard import Pedalboard
from pedalboard_native import Limiter, Gain
import pyaudio
import wave
import time
import numpy as np

board = Pedalboard([
    Limiter(threshold_db=-0.1)
])

path = "/Users/michael/Desktop/test1111.wav"
wf = wave.open(path, "rb")
wav_data = wf.readframes(wf.getnframes())
meta = {"seek": 0}

def callback(in_data, frame_count, time_info, status):
    start = meta["seek"]
    meta["seek"] += frame_count * pyaudio.get_sample_size(pyaudio.paInt16) * wf.getnchannels()
    data = wav_data[start: meta["seek"]]
    data = np.frombuffer(data, dtype=np.int16).astype(np.float32)
    data = board(data, 44100, reset=False)
    data = data.astype(np.int16)
    data = data.tobytes()
    return (data, pyaudio.paContinue)

audio = pyaudio.PyAudio()
stream = audio.open(format=audio.get_format_from_width(wf.getsampwidth()),
                channels=wf.getnchannels(),
                rate=wf.getframerate(),
                output=True,
                stream_callback=callback)

stream.start_stream()

while stream.is_active():
    time.sleep(0.1)

MMMMichaelzhang avatar Aug 21 '24 18:08 MMMMichaelzhang