Git Product home page Git Product logo

Comments (4)

cdi-ableton avatar cdi-ableton commented on August 23, 2024

Yes. The duration of a beat corresponds to the one of a quarter note. If you're dealing with different signatures check out the section about Phase Synchronisation in Link's documentation.

from linkkit.

BlipGit avatar BlipGit commented on August 23, 2024

Thanks, although that does bring me to my next question ...

I'm using the current time signature's 'beats per bar' to determine the quantum. However, when the 'beats per bar' changes (as a result of a user interaction, or due to an event in the sequence), the beat time returned by LinkKit becomes discontinuous, and the timeline jumps to a different position. I've worked around this by adding a compensation offset when a quantum change occurs, as follows:


	// Has the quantum changed since the last call?
	if (mQuantum != zQuantum)
	{
		// Calculate the beat time using both the old and the new quantum
		f64 OldQuantumBeat = ABLLinkBeatAtTime(mpCapturedTimeline, HostTime, mQuantum);
		f64 NewQuantumBeat = ABLLinkBeatAtTime(mpCapturedTimeline, HostTime, zQuantum);

		// The difference between the two returned beat times must be added as an offset in all future calls
		// to prevent a timeline discontinuity
		mBeatOffset += (OldQuantumBeat - NewQuantumBeat);
		
		// This is now the new quantum
		mQuantum = zQuantum;
	}

	// Return the beat time, adding our offset to prevent discontinuities when the quantum changes
	return ABLLinkBeatAtTime(mpCapturedTimeline, HostTime, mQuantum) + mBeatOffset;

This seems to work, and the app's bar start (phase) still seems to align with the connected peers when the quanta are a multiple of each other but it still feels like a workaround. Have I handled this correctly?

from linkkit.

cdi-ableton avatar cdi-ableton commented on August 23, 2024

Yes. The beat time will be discontinuous when changing the quantum. For Ableton Live we're taking an alternative approach on handling this. We're saving the quantum when starting transport and use this for alignment with Link until transport is stopped. When transport is started again we update the quantum.

from linkkit.

BlipGit avatar BlipGit commented on August 23, 2024

OK. This is the same alternative approach I thought of last night, so I think I might change it!

Thanks once again for your help.

from linkkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.