bmcfee / muda

A library for augmenting annotated audio data
ISC License
230 stars 33 forks source link

Allow PitchShift deformer to take list for n_semitones #41

Closed justinsalamon closed 7 years ago

justinsalamon commented 7 years ago

The PitchShift deformer only takes a single semitone parameter (n_semitones), which makes it a little awkward to work with when you want to perform multiple pitch shifts. LinearPitchShift can perform multiple shifts, but they have to be linearly spaced, which might not be the desired functionality (e.g. I may want n_semitones = [ -2, -1, 1, 2]).

It would be nice if PitchShift would accept (in addition to a single value) a list for the n_semitones parameter, in which case it would generate an output audio/jams for every pitch shift value in the list (times n_samples). This would make the behavior more consistent with other deformers (e.g. DynamicRangeCompression), and would allow (what I'm really after) writing more generic code that can apply a deformer agnostically of which deformer it actually is because the deformer is fully defined during initialization.

bmcfee commented 7 years ago

This would be pretty easy to do if we just tweak PitchShift to accept a float-or-array instead of a single float. Should be a minor hack, if you want to take a crack at it.

justinsalamon commented 7 years ago

Cool, I'll try and squeeze in a PR sometime before the end of this week

bmcfee commented 7 years ago

Check background for an example of this kind of logic. All you need to do is then make this part iterate over the list of pitch values, instead of yielding a single value.

bmcfee commented 7 years ago

Cool, I'll try and squeeze in a PR sometime before the end of this week

Actually, I wound up on a spree of muda hacking last night, so I don't mind taking this one over today.