craffel / pretty-midi

Utility functions for handling MIDI data in a nice/intuitive way.
MIT License
856 stars 151 forks source link

Add normalize parameter to synthesize and fluidsynth methods #243

Closed yawjalik closed 6 months ago

yawjalik commented 6 months ago

Added normalize parameter such that when set to True, hard-normalizes the synthesized output wave to [-1, 1]. Otherwise, divide the wave by len(self.instruments) * 2^15 to prevent clipping, and lets the user handle accordingly. It is set to False by default. This serves as a starting point for tackling #151 and #158.

yawjalik commented 6 months ago

This is probably my first ever contribution. Any comments or advice will be greatly appreciated!

craffel commented 6 months ago

Thanks for this. Since the original behavior was equivalent to normalize=True, that should probably be the default to avoid breaking existing code.

yawjalik commented 6 months ago

Got it, I've changed them to True by default.

craffel commented 6 months ago

Thanks!