sonic-pi icon indicating copy to clipboard operation
sonic-pi copied to clipboard

beatmatching with external tracks/audio sources

Open hopbit opened this issue 8 years ago • 8 comments

Enhancement:

It would be nice to have mechanism, that would allow to beatmatch with external audio source (tune) just the same way, as DJs do it when doing their mix. Something like speeding up/down our live coded music for a while, and next our tune goes back to normal BPM speed.

Here's an example video of what I mean.

hopbit avatar Aug 23 '15 20:08 hopbit

Yep, there are lots of ideas like these that have been discussed. The main issues are:

  1. how to ensure the feature is simple enough to teach a 10 year old
  2. finding someone to implement and support the feature

This sadly means that most ideas stay as ideas. If you have a nice elegant solution to 1) and are happy to do 2) then please let me know.

samaaron avatar Aug 30 '15 00:08 samaaron

  1. This feature is simple enough to learn it 10 years old. I can explain it using 2 little car toys :)
  2. I'll try to implement it, and (and support it of course), but after I finish polish translation :)

Maybe I should create such issue inside my fork, but I have hope that maybe somebody smarter with more experience would be happy to implement it faster than I'll be able to start working on it :)

hopbit avatar Aug 30 '15 09:08 hopbit

  1. yes, explaining it abstractly is one thing - expressing it in code that a 10 year old can understand is another...

It would be great if you would have a go at implementing such a feature - although it might be wise to try and discuss it in more detail here first :-)

samaaron avatar Aug 30 '15 09:08 samaaron

I was on holiday last week so didn't respond to this when I saw it. It's an interesting idea. I've got some thoughts on how you'd go about it and some of the challenges involved...

The obvious candidate for things like beat/tempo matching IMO would be scsynth (SuperCollider) as we are already using it! It has some Analysis UGens which handle this sort of thing e.g. http://doc.sccode.org/Classes/BeatTrack.html

The problem is that our communication with scsynth is all one way traffic at the moment i.e. Ruby -> scsynth. I'm not aware that we have anything set up to return information from the scsynth process to the Ruby server, which is what you would need to be able to set the current bpm. I'm not saying it's impossible, just that there isn't a clear way to set this up at the moment.

That's the easy bit! As Sam points out there's more of a conceptual issue as to how this would be represented in the code. If we were just beat tracking live input what kind of effect would that have on set bpm! commands? What about async loops? etc. etc.

Basically, it's hard to answer these questions without doing a lot of work and even when you get to the end, it might not pass the "10 year old" test. I speak from experience as I've implemented a lot (maybe 10) big features that I've had to park until I can find a nice way to make them work. I've learnt from them every time though so I wouldn't be too discouraged. If you're still keen to start on this feature I'm happy to help out.

xavriley avatar Sep 02 '15 08:09 xavriley

I think a nice next-step in this discussion would be to consider some FX which analysed the audio and generated OSC messages to be sent back to Sonic Pi as cue events which could then be picked up and analysed by the language itself.

SuperCollider already has a mechanism for sending OSC messages and I have already built some rudimentary support for using it, so most of the groundwork has already been done here :-)

samaaron avatar Feb 20 '18 14:02 samaaron

We now have a dynamic timing system based on Ableton Link and a "tap tempo" button to allow manual syncing with external tempos. Is this sufficient to close this?

samaaron avatar Jul 19 '22 11:07 samaaron

Seems to be promising. But let me try to test it first with the latest build :)

hopbit avatar Jul 20 '22 10:07 hopbit

As I understand it, the tap tempo button only adjusts the BPM, not the phase of the beats. So if you're trying to synchronise to an external beat you'll likely end up out of phase with it. It would be nice to also be able to sync the phase of the beat based on the time of the button clicks (you're likely to be clicking on the beat). I've started trying to write a standalone metronome app with tap tempo and Ableton Link support so I can experiment with this. I'm not sure how long it will take me, but would be happy to contribute ideas and/or code back when I get something working.

emlyn avatar Jul 20 '22 10:07 emlyn