Trying to implement basic audio lookahead via latency reporting -- am lost
Hi all,
I'm trying to implement a "beat shuffler" that can permute the beats within a given measure. That might mean that beat 3 is re-arranged to happen on beat 1, such that audio "from the future" plays "in the present".
Given the shuffling happens within measures, I can implement this by just aligning everything to the /next/ measure, delaying all incoming beats by some positive amount of time and causing the entire device to have a single measure latency. But I imagine -- because devices like limiters use a lookahead -- that there should be a way to report the 1 measure latency and properly align the output of my device (for audio that is already recorded, of course, because time travel is not possible!).
So I'm trying to start by creating a basic Max4Live device that simply negative-delays the audio input, and I've had no luck. I found other forums posts about the device's reported latency. I tried both manually entering a large number in the Defined Latency field of the patcher inspector, and also doing loadbang -> latency 10000 -> live.thisdevice
for a latency of 10000 samples. These don't seem to work. It seems like at one point I did get some amount of negative latency to occur because I bounced an audio track and it seemed to shift back, but I don't remember what series of actions I took to do this.
There has to be a simple way to do this, right? Can anyone help?
Similar post from a few years ago, without a clear answer: https://cycling74.com/forums/lookahead-function
latency > thispatcher

Thanks!
I think it had been working before, but I was confused because latency is not handled the way I expected.
When I create a dummy plug-in with a high latency (e.g. 40k samples) and hit play, the Ableton playback GUI begins to start, but the sound (and metronome) doesn't start until the latency time has elapsed. So, it instructs all of Ableton to wait that long before playing the sound, and the audio is really far off from the visual. I was expecting it to "compute [latency time] into the future and align things for playback" -- wishful thinking I suppose.
For the use case of the 1-measure beat shuffler, I think I will just set up the audio effect so it produces the output 1 measure later (without explicitly telling ableton anything about latency compensation), and trust the user to understand this and shift things back accordingly. If the "latency" is just a fixed amount of delay, it's easy to handle it manually.
set the plug-in to the possible maximum delay (say like 4/4 at 60 BPM) as its latency flag to the host, and then internally, if less latency is caused, add some artificial extra delay to the music signal to match up with the setting.
or... or do not compensate the latency at all i.e. set the plug-in to 0 samples. then it is always 1 bar, but the user has to care about that by predelaying the track for 1 bar (which is not difficult to do)