bmcfee / pyrubberband

python wrapper for rubberband
ISC License
154 stars 20 forks source link

add feature for parsing ableton ASD file #26

Closed DBraun closed 3 years ago

DBraun commented 3 years ago

Reference Issue

N/A

What does this implement/fix? Explain your changes.

This adds a function ableton_asd_to_time_map for parsing Ableton .asd warp files into a time_map list to be used with pyrb.timemap_stretch.

Any other comments?

Example usage:

import pyrb
import librosa

sr = 44100
bpm = 120.

y = librosa.load('song.wav', sr=sr)[0]
time_map = pyrb.ableton_asd_to_time_map('song.wav.asd', y, sr, bpm)
new_song = pyrb.timemap_stretch(y, sr, time_map)

from scipy import io
import scipy.io.wavfile
io.wavfile.write('new_song.wav', sr, new_song )

I wrote the code after reading https://github.com/jtxx000/extract-warp-markers. That project showed how to extract the BPM. I did some extra probing to find out how to get other fields such as loop_start, loop_end, start_marker, end_marker, loop_on. I think having that information could be really useful for other developers. Perhaps pyrubberband could handle looping one day.

It's possible that this function could break if Ableton changes their ASD format... But I still think it's worth sharing. I'm using Ableton 10.1.30.

bmcfee commented 3 years ago

Thanks for this -- it's certainly an interesting feature!

That said, I think it might be better handled as a stand-alone tool or package that produces time-maps we can feed into pyrb.time_stretch (or use outside of pyrb entirely). This will make it easier in the future to decouple updates in case the ASD format does change.

I also don't have ableton, or a machine capable of running it, so it's impossible for me to test this.

If you want feedback on the code in the PR, I'm happy to provide it, but I don't think we'll merge this.

DBraun commented 3 years ago

That's a good call. Thanks for your feedback. I'll try to put it in a separate repo soon.

DBraun commented 3 years ago

https://github.com/DBraun/AbletonParsing Here it is. It's been a long time since I tried to package up a real python module for distribution/peer review, so all feedback is welcome.