from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard
import soundfile as sf


if __name__ == '__main__':

    # replace by path of unprocessed piano file if necessar
    fn_wav_source = 'live_grand_piano.wav'

    # augmentation settings using Pedalboard library
    settings = {'rev-': [Reverb(room_size=.4)],
                'rev+': [Reverb(room_size=.8)],
                'comp+': [Compressor(threshold_db=-15, ratio=20)],
                'comp-': [Compressor(threshold_db=-10, ratio=10)],
                'gain+': [Gain(gain_db=15)],  # clipping
                'gain-': [Gain(gain_db=5)],
                'lpf-': [LowpassFilter(cutoff_frequency_hz=50)],
                'lpf+': [LowpassFilter(cutoff_frequency_hz=250)]}

    # create augmented versions
    for s in settings.keys():

        # load unprocessed piano recording
        audio, sample_rate = sf.read(fn_wav_source)

        # create Pedalboard object
        board = Pedalboard(settings[s])

        # create augmented audio
        effected = board(audio, sample_rate)

        # save it
        fn_target = fn_wav_source.replace('.wav', f'_{s}.wav')
        sf.write(fn_target, effected, sample_rate)

[((24, 29, 24, 51), 'soundfile.read', 'sf.read', ({(24, 37, 24, 50): 'fn_wav_source'}, {}), '(fn_wav_source)', True, 'import soundfile as sf\n'), ((27, 16, 27, 39), 'pedalboard.Pedalboard', 'Pedalboard', ({(27, 27, 27, 38): 'settings[s]'}, {}), '(settings[s])', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((34, 8, 34, 50), 'soundfile.write', 'sf.write', ({(34, 17, 34, 26): 'fn_target', (34, 28, 34, 36): 'effected', (34, 38, 34, 49): 'sample_rate'}, {}), '(fn_target, effected, sample_rate)', True, 'import soundfile as sf\n'), ((11, 25, 11, 45), 'pedalboard.Reverb', 'Reverb', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((12, 25, 12, 45), 'pedalboard.Reverb', 'Reverb', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((13, 26, 13, 64), 'pedalboard.Compressor', 'Compressor', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((14, 26, 14, 64), 'pedalboard.Compressor', 'Compressor', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((15, 26, 15, 42), 'pedalboard.Gain', 'Gain', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((16, 26, 16, 41), 'pedalboard.Gain', 'Gain', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((17, 25, 17, 62), 'pedalboard.LowpassFilter', 'LowpassFilter', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((18, 25, 18, 63), 'pedalboard.LowpassFilter', 'LowpassFilter', (), '', False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n')]