Add method to send a song position pointer message
This commit is contained in:
committed by
Robin Gareus
parent
79d134ca78
commit
3538fa8442
@@ -813,6 +813,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
|
||||
void send_mmc_locate (framepos_t);
|
||||
int send_full_time_code (framepos_t);
|
||||
void send_song_position_pointer (framepos_t);
|
||||
|
||||
bool step_editing() const { return (_step_editors > 0); }
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "ardour/midi_ui.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/slave.h"
|
||||
#include "ardour/tempo.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
@@ -581,6 +582,44 @@ Session::mmc_step_timeout ()
|
||||
return true;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
OUTBOUND SYSTEM COMMON STUFF
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
void
|
||||
Session::send_song_position_pointer (framepos_t t)
|
||||
{
|
||||
/* This doesn't account for the Meter's note divisor */
|
||||
if (!_engine.freewheeling()) {
|
||||
|
||||
Timecode::BBT_Time time;
|
||||
bbt_time (t, time);
|
||||
|
||||
const double beats_per_bar = tempo_map().meter_at(t).divisions_per_bar();
|
||||
|
||||
/* Midi Beats in terms of Song Position Pointer is equivalent to total
|
||||
sixteenth notes at 'time' */
|
||||
const uint32_t midi_beats = 4 * (((time.bars - 1) * beats_per_bar) + time.beats - 1);
|
||||
|
||||
/* can only use 14bits worth */
|
||||
if (midi_beats > 0x3fff) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* split midi beats into a 14bit value */
|
||||
MIDI::byte msg[3] = {
|
||||
0xf2, /* MIDI System Common - Song Position Pointer status */
|
||||
midi_beats & 0x7f,
|
||||
midi_beats & 0x3f80
|
||||
};
|
||||
|
||||
if (MIDI::Port* port = MIDI::Manager::instance()->midi_clock_output_port()) {
|
||||
port->midimsg (msg, sizeof (msg), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Session::start_midi_thread ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user