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)

[((883, 905), 'soundfile.read', 'sf.read', (['fn_wav_source'], {}), '(fn_wav_source)\n', (890, 905), True, 'import soundfile as sf\n'), ((958, 981), 'pedalboard.Pedalboard', 'Pedalboard', (['settings[s]'], {}), '(settings[s])\n', (968, 981), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((1151, 1193), 'soundfile.write', 'sf.write', (['fn_target', 'effected', 'sample_rate'], {}), '(fn_target, effected, sample_rate)\n', (1159, 1193), True, 'import soundfile as sf\n'), ((310, 331), 'pedalboard.Reverb', 'Reverb', ([], {'room_size': '(0.4)'}), '(room_size=0.4)\n', (316, 331), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((358, 379), 'pedalboard.Reverb', 'Reverb', ([], {'room_size': '(0.8)'}), '(room_size=0.8)\n', (364, 379), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((407, 445), 'pedalboard.Compressor', 'Compressor', ([], {'threshold_db': '(-15)', 'ratio': '(20)'}), '(threshold_db=-15, ratio=20)\n', (417, 445), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((474, 512), 'pedalboard.Compressor', 'Compressor', ([], {'threshold_db': '(-10)', 'ratio': '(10)'}), '(threshold_db=-10, ratio=10)\n', (484, 512), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((541, 557), 'pedalboard.Gain', 'Gain', ([], {'gain_db': '(15)'}), '(gain_db=15)\n', (545, 557), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((598, 613), 'pedalboard.Gain', 'Gain', ([], {'gain_db': '(5)'}), '(gain_db=5)\n', (602, 613), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((641, 678), 'pedalboard.LowpassFilter', 'LowpassFilter', ([], {'cutoff_frequency_hz': '(50)'}), '(cutoff_frequency_hz=50)\n', (654, 678), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n'), ((706, 744), 'pedalboard.LowpassFilter', 'LowpassFilter', ([], {'cutoff_frequency_hz': '(250)'}), '(cutoff_frequency_hz=250)\n', (719, 744), False, 'from pedalboard import Reverb, Compressor, Gain, LowpassFilter, Pedalboard\n')]