Add a MixxxControl (ControlObject) that fires on each beat

Bug #604384 reported by Sean M. Pappalardo
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Wishlist
vininim

Bug Description

Some MIDI script authors would like to flash an LED (or do other things) in time with the beat of a particular deck. Please add a "[ChannelN],beat" ControlObject that changes to 1 only while immediately on a beat (and is 0 all other times.)
Bonus points if you can also add a beatClock or similar CO that fires at a rate of 24 (equally-spaced) ticks per beat (quarter-note,) so as to send a MIDI clock signal for synchronization with external instruments.

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

Here's a workaround for now. Albert said:
"The beat ticks always start right at the start of the track, and you know the BPM, so based on the playback position and the BPM, you should be able to trigger something."

So you have duration in seconds, and doing 60/bpm = seconds per beat. So when (visual_playposition * duration) modulus (60/bpm[/24 for MIDI clock pulses]) == 0, you're on a beat and should light your LED. Be sure to use engine.connectControl() to connect the "[ChannelN],rate" MixxxControl to a script function that stops & restarts the timer with the new BPM value (obtained with "[ChannelN],rate" x "[ChannelN],bpm",) so it's updated when the pitch control is moved.

This functionality should be added to the common script functions file so script writers don't need to worry about these gory details, but there's currently no way for a slot function to find out what group the changed MixxxControl was (it can't find out which deck fired the signal at the moment) so it's impossible to make a generic function set.

Changed in mixxx:
status: Confirmed → Triaged
summary: - Add a MixxxControl that fires on each beat
+ Add a MixxxControl (ControlObject) that fires on each beat
RJ Skerry-Ryan (rryan)
tags: added: easy weekend
Phillip Whelan (pwhelan)
Changed in mixxx:
assignee: nobody → vininim (vininim)
Revision history for this message
vininim (vininim) wrote :

New CO ([ChannelN], beat_on) added on my branch. Midi clock needs a more involved design, something related to master BPM(fire events at known rate lower than latency, if that is even possible, and such)

Revision history for this message
vininim (vininim) wrote :
Changed in mixxx:
status: Triaged → In Progress
RJ Skerry-Ryan (rryan)
Changed in mixxx:
milestone: none → 1.10.0
Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Thanks for the patch, vininim -- just a few quick things to fix:

- As I mentioned in the channel, I think CachingReader shouldn't be passed into EngineControl's via their constructor. Rather, I think that EngineControl should get an onTrackLoaded method added to its interface, and the EngineBuffer should call that whenever a track is loaded for every EngineControl.

- In slotTrackLoaded, check that tio is not null, (for example, an eject will trigger that call with a null track). You should also clear the on_beat control when a track is loaded.

- In slotTrackLoaded, check whether a previous track is loaded, and if so, disconnect its beatsUpdated signal from your slotBeatsUpdated slot, that way changes to the beats of previously loaded tracks won't fire your slot.

- Don't include cmath or use std::fabs, just call fabs() -- you may need to #include "defs.h"

- Since the ClockControl isn't used anywhere in EngineBuffer, please don't add a member variable to EngineBuffer. Just call addControl on it when you create it.

Thanks,
RJ

Revision history for this message
vininim (vininim) wrote :

Diff against main branch with fixes

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Thanks for the patch vininim -- I committed it to trunk w/ some modifications. What name should I put you under in the credits?

Changed in mixxx:
status: In Progress → Fix Committed
Revision history for this message
vininim (vininim) wrote :

Vinícius Dias dos Santos (can drop the acute accent)

Revision history for this message
RJ Skerry-Ryan (rryan) wrote : Re: [Bug 604384] Re: Add a MixxxControl (ControlObject) that fires on each beat

Added, thanks!

On Tue, Mar 29, 2011 at 5:26 AM, vininim <email address hidden> wrote:

> Vinícius Dias dos Santos (can drop the acute accent)
>
> --
> You received this bug notification because you are subscribed to Mixxx.
> https://bugs.launchpad.net/bugs/604384
>
> Title:
> Add a MixxxControl (ControlObject) that fires on each beat
>

RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/5454

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.