mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
rename Timecode::BBT_Time::ticks_per_beat to Timecode::BBT_Time::ticks_per_bar_division which is a more accurate and informative name. The number doesn't describe the smallest division of a "beat" (which is only defined contextually anyway), but rather the smallest division of the the divisions of a bar. If using a meter of 4/8, there are 4 divisions per bar, and we can divide each one into ticks_per_bar_division pieces; in a separate meter (section) of 3/8, there are 3 divisions per bar, each of which can be divided into ticks_per_bar_division_pieces.
git-svn-id: svn://localhost/ardour2/branches/3.0@11022 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ca9a444aa9
commit
e9b4f14668
12 changed files with 60 additions and 47 deletions
|
|
@ -1779,7 +1779,7 @@ AudioClock::bbt_validate_edit (const string& str)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (any.bbt.ticks > Timecode::BBT_Time::ticks_per_beat) {
|
||||
if (any.bbt.ticks > Timecode::BBT_Time::ticks_per_bar_division) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1262,7 +1262,7 @@ Editor::compute_bbt_ruler_scale (framepos_t lower, framepos_t upper)
|
|||
bbt_ruler_scale = bbt_show_ticks_detail;
|
||||
}
|
||||
|
||||
if ((bbt_ruler_scale == bbt_show_ticks_detail) && (lower_beat.beats == upper_beat.beats) && (upper_beat.ticks - lower_beat.ticks <= Timecode::BBT_Time::ticks_per_beat / 4)) {
|
||||
if ((bbt_ruler_scale == bbt_show_ticks_detail) && (lower_beat.beats == upper_beat.beats) && (upper_beat.ticks - lower_beat.ticks <= Timecode::BBT_Time::ticks_per_bar_division / 4)) {
|
||||
bbt_ruler_scale = bbt_show_ticks_super_detail;
|
||||
}
|
||||
}
|
||||
|
|
@ -1391,14 +1391,14 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp
|
|||
|
||||
frame_skip = (framepos_t) floor (frame_skip_error = (_session->frame_rate() * 60) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute()));
|
||||
frame_skip_error -= frame_skip;
|
||||
skip = (uint32_t) (Timecode::BBT_Time::ticks_per_beat / bbt_beat_subdivision);
|
||||
skip = (uint32_t) (Timecode::BBT_Time::ticks_per_bar_division / bbt_beat_subdivision);
|
||||
|
||||
pos = (*i).frame + frame_skip;
|
||||
accumulated_error = frame_skip_error;
|
||||
|
||||
tick = skip;
|
||||
|
||||
for (t = 0; (tick < Timecode::BBT_Time::ticks_per_beat) && (n < bbt_nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||
for (t = 0; (tick < Timecode::BBT_Time::ticks_per_bar_division) && (n < bbt_nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||
|
||||
if (t % bbt_accent_modulo == (bbt_accent_modulo - 1)) {
|
||||
i_am_accented = true;
|
||||
|
|
@ -1483,14 +1483,14 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp
|
|||
|
||||
frame_skip = (framepos_t) floor (frame_skip_error = (_session->frame_rate() * 60) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute()));
|
||||
frame_skip_error -= frame_skip;
|
||||
skip = (uint32_t) (Timecode::BBT_Time::ticks_per_beat / bbt_beat_subdivision);
|
||||
skip = (uint32_t) (Timecode::BBT_Time::ticks_per_bar_division / bbt_beat_subdivision);
|
||||
|
||||
pos = (*i).frame + frame_skip;
|
||||
accumulated_error = frame_skip_error;
|
||||
|
||||
tick = skip;
|
||||
|
||||
for (t = 0; (tick < Timecode::BBT_Time::ticks_per_beat) && (n < bbt_nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||
for (t = 0; (tick < Timecode::BBT_Time::ticks_per_bar_division) && (n < bbt_nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||
|
||||
if (t % bbt_accent_modulo == (bbt_accent_modulo - 1)) {
|
||||
i_am_accented = true;
|
||||
|
|
@ -1580,14 +1580,14 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble /*upp
|
|||
|
||||
frame_skip = (framepos_t) floor (frame_skip_error = (_session->frame_rate() * 60) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute()));
|
||||
frame_skip_error -= frame_skip;
|
||||
skip = (uint32_t) (Timecode::BBT_Time::ticks_per_beat / bbt_beat_subdivision);
|
||||
skip = (uint32_t) (Timecode::BBT_Time::ticks_per_bar_division / bbt_beat_subdivision);
|
||||
|
||||
pos = (*i).frame + frame_skip;
|
||||
accumulated_error = frame_skip_error;
|
||||
|
||||
tick = skip;
|
||||
|
||||
for (t = 0; (tick < Timecode::BBT_Time::ticks_per_beat) && (n < bbt_nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||
for (t = 0; (tick < Timecode::BBT_Time::ticks_per_bar_division) && (n < bbt_nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||
|
||||
if (t % bbt_accent_modulo == (bbt_accent_modulo - 1)) {
|
||||
i_am_accented = true;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ MidiListEditor::redisplay_model ()
|
|||
bbt.bars = 0;
|
||||
dur = (*i)->end_time() - (*i)->time();
|
||||
bbt.beats = floor (dur);
|
||||
bbt.ticks = (uint32_t) lrint (fmod (dur, 1.0) * Timecode::BBT_Time::ticks_per_beat);
|
||||
bbt.ticks = (uint32_t) lrint (fmod (dur, 1.0) * Timecode::BBT_Time::ticks_per_bar_division);
|
||||
|
||||
_session->tempo_map().bbt_duration_at (region->position(), bbt, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -812,7 +812,7 @@ MidiRegionView::create_note_at (framepos_t t, double y, double length, bool sh,
|
|||
|
||||
length = region_frames_to_region_beats (region_beats_to_region_frames (length) - 1);
|
||||
*/
|
||||
length -= 1.0/Timecode::BBT_Time::ticks_per_beat;
|
||||
length -= 1.0/Timecode::BBT_Time::ticks_per_bar_division;
|
||||
}
|
||||
|
||||
const boost::shared_ptr<NoteType> new_note (new NoteType (mtv->get_channel_for_add (),
|
||||
|
|
|
|||
|
|
@ -272,8 +272,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
|
|||
up by 1 tick from where the last note ended
|
||||
*/
|
||||
|
||||
at += 1.0/Timecode::BBT_Time::ticks_per_beat;
|
||||
len -= 1.0/Timecode::BBT_Time::ticks_per_beat;
|
||||
at += 1.0/Timecode::BBT_Time::ticks_per_bar_division;
|
||||
len -= 1.0/Timecode::BBT_Time::ticks_per_bar_division;
|
||||
}
|
||||
|
||||
step_edit_region_view->step_add_note (channel, pitch, velocity, at, len);
|
||||
|
|
@ -293,7 +293,7 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
|
|||
step_edit_beat_pos += beat_duration;
|
||||
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
||||
} else {
|
||||
step_edit_beat_pos += 1.0/Timecode::BBT_Time::ticks_per_beat; // tiny, but no longer overlapping
|
||||
step_edit_beat_pos += 1.0/Timecode::BBT_Time::ticks_per_bar_division; // tiny, but no longer overlapping
|
||||
_step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double
|
|||
|
||||
ticks -= sbbt.ticks;
|
||||
if (ticks < 0) {
|
||||
ticks += int (Timecode::BBT_Time::ticks_per_beat);
|
||||
ticks += int (Timecode::BBT_Time::ticks_per_bar_division);
|
||||
--beats;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1420,7 +1420,7 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat,
|
|||
float beat;
|
||||
beat = metric.meter().beats_per_bar() * bbt.bars;
|
||||
beat += bbt.beats;
|
||||
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
|
||||
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_bar_division;
|
||||
*outCurrentBeat = beat;
|
||||
}
|
||||
|
||||
|
|
@ -1461,7 +1461,7 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
|
|||
*outDeltaSampleOffsetToNextBeat = 0;
|
||||
} else {
|
||||
*outDeltaSampleOffsetToNextBeat = (UInt32)
|
||||
floor (((Timecode::BBT_Time::ticks_per_beat - bbt.ticks)/Timecode::BBT_Time::ticks_per_beat) * // fraction of a beat to next beat
|
||||
floor (((Timecode::BBT_Time::ticks_per_bar_division - bbt.ticks)/Timecode::BBT_Time::ticks_per_bar_division) * // fraction of a beat to next beat
|
||||
metric.tempo().frames_per_beat(_session.frame_rate(), metric.meter())); // frames per beat
|
||||
}
|
||||
}
|
||||
|
|
@ -1553,7 +1553,7 @@ AUPlugin::get_transport_state_callback (Boolean* outIsPlaying,
|
|||
float beat;
|
||||
beat = metric.meter().beats_per_bar() * bbt.bars;
|
||||
beat += bbt.beats;
|
||||
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
|
||||
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_bar_division;
|
||||
|
||||
*outCycleStartBeat = beat;
|
||||
}
|
||||
|
|
@ -1565,7 +1565,7 @@ AUPlugin::get_transport_state_callback (Boolean* outIsPlaying,
|
|||
float beat;
|
||||
beat = metric.meter().beats_per_bar() * bbt.bars;
|
||||
beat += bbt.beats;
|
||||
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
|
||||
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_bar_division;
|
||||
|
||||
*outCycleEndBeat = beat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/,
|
|||
|
||||
pos->beats_per_bar = metric.meter().divisions_per_bar();
|
||||
pos->beat_type = metric.meter().note_divisor();
|
||||
pos->ticks_per_beat = Timecode::BBT_Time::ticks_per_beat;
|
||||
pos->ticks_per_beat = Timecode::BBT_Time::ticks_per_bar_division;
|
||||
pos->beats_per_minute = metric.tempo().beats_per_minute();
|
||||
|
||||
pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT);
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ TempoMap::timestamp_metrics (bool use_bbt)
|
|||
first = false;
|
||||
} else {
|
||||
|
||||
if (bbt.ticks > BBT_Time::ticks_per_beat/2) {
|
||||
if (bbt.ticks > BBT_Time::ticks_per_bar_division/2) {
|
||||
/* round up to next beat */
|
||||
bbt.beats += 1;
|
||||
}
|
||||
|
|
@ -863,7 +863,7 @@ void
|
|||
TempoMap::bbt_time_with_metric (framepos_t frame, BBT_Time& bbt, const TempoMetric& metric) const
|
||||
{
|
||||
const double divisions_per_bar = metric.meter().divisions_per_bar();
|
||||
const double frames_per_tick = metric.meter().frames_per_division (metric.tempo(),_frame_rate) / BBT_Time::ticks_per_beat;
|
||||
const double frames_per_tick = metric.meter().frames_per_division (metric.tempo(),_frame_rate) / BBT_Time::ticks_per_bar_division;
|
||||
|
||||
/* now compute how far beyond the metric we actually are, and add the
|
||||
* relevant number of ticks to the metric's BBT time
|
||||
|
|
@ -873,8 +873,8 @@ TempoMap::bbt_time_with_metric (framepos_t frame, BBT_Time& bbt, const TempoMetr
|
|||
uint32_t tick_diff = (uint32_t) lrint ((double) frame_diff / frames_per_tick);
|
||||
|
||||
bbt.ticks = metric.start().ticks + tick_diff;
|
||||
uint32_t beat_overflow = bbt.ticks / (uint32_t) BBT_Time::ticks_per_beat;
|
||||
bbt.ticks = bbt.ticks % (uint32_t) BBT_Time::ticks_per_beat;
|
||||
uint32_t beat_overflow = bbt.ticks / (uint32_t) BBT_Time::ticks_per_bar_division;
|
||||
bbt.ticks = bbt.ticks % (uint32_t) BBT_Time::ticks_per_bar_division;
|
||||
bbt.beats = metric.start().beats + beat_overflow;
|
||||
/* bbt.beats uses 1-based counting, so adjust to get the right answer */
|
||||
uint32_t bar_overflow = (bbt.beats - 1) / (uint32_t) divisions_per_bar;
|
||||
|
|
@ -929,7 +929,7 @@ TempoMap::count_frames_between (const BBT_Time& start, const BBT_Time& end) cons
|
|||
uint32_t bar_offset = start.bars - m.start().bars;
|
||||
|
||||
double beat_offset = bar_offset*m.meter().divisions_per_bar() - (m.start().beats-1) + (start.beats -1)
|
||||
+ start.ticks/BBT_Time::ticks_per_beat;
|
||||
+ start.ticks/BBT_Time::ticks_per_bar_division;
|
||||
|
||||
start_frame = m.frame() + (framepos_t) rint(beat_offset * m.meter().frames_per_division(m.tempo(),_frame_rate));
|
||||
|
||||
|
|
@ -943,7 +943,7 @@ TempoMap::count_frames_between (const BBT_Time& start, const BBT_Time& end) cons
|
|||
bar_offset = end.bars - m.start().bars;
|
||||
|
||||
beat_offset = bar_offset * m.meter().divisions_per_bar() - (m.start().beats -1) + (end.beats - 1)
|
||||
+ end.ticks/BBT_Time::ticks_per_beat;
|
||||
+ end.ticks/BBT_Time::ticks_per_bar_division;
|
||||
|
||||
end_frame = m.frame() + (framepos_t) rint(beat_offset * m.meter().frames_per_division(m.tempo(),_frame_rate));
|
||||
|
||||
|
|
@ -1076,8 +1076,8 @@ TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, i
|
|||
*/
|
||||
|
||||
uint32_t ticks_at_beat = (uint32_t) (result.beats == ceil(divisions_per_bar) ?
|
||||
(1 - (ceil(divisions_per_bar) - divisions_per_bar))* BBT_Time::ticks_per_beat
|
||||
: BBT_Time::ticks_per_beat );
|
||||
(1 - (ceil(divisions_per_bar) - divisions_per_bar))* BBT_Time::ticks_per_bar_division
|
||||
: BBT_Time::ticks_per_bar_division );
|
||||
|
||||
while (result.ticks >= ticks_at_beat) {
|
||||
result.beats++;
|
||||
|
|
@ -1089,8 +1089,8 @@ TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, i
|
|||
divisions_per_bar = metric.meter().divisions_per_bar();
|
||||
}
|
||||
ticks_at_beat= (uint32_t) (result.beats == ceil(divisions_per_bar) ?
|
||||
(1 - (ceil(divisions_per_bar) - divisions_per_bar) ) * BBT_Time::ticks_per_beat
|
||||
: BBT_Time::ticks_per_beat);
|
||||
(1 - (ceil(divisions_per_bar) - divisions_per_bar) ) * BBT_Time::ticks_per_bar_division
|
||||
: BBT_Time::ticks_per_bar_division);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1117,7 +1117,7 @@ TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, i
|
|||
result.ticks = when.ticks - bbt.ticks;
|
||||
} else {
|
||||
|
||||
uint32_t ticks_at_beat= (uint32_t) BBT_Time::ticks_per_beat;
|
||||
uint32_t ticks_at_beat= (uint32_t) BBT_Time::ticks_per_bar_division;
|
||||
uint32_t t = bbt.ticks - when.ticks;
|
||||
|
||||
do {
|
||||
|
|
@ -1128,10 +1128,10 @@ TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, i
|
|||
metric = metric_at(result); // maybe there is a meter change
|
||||
divisions_per_bar = metric.meter().divisions_per_bar();
|
||||
result.beats = (uint32_t) ceil(divisions_per_bar);
|
||||
ticks_at_beat = (uint32_t) ((1 - (ceil(divisions_per_bar) - divisions_per_bar)) * BBT_Time::ticks_per_beat) ;
|
||||
ticks_at_beat = (uint32_t) ((1 - (ceil(divisions_per_bar) - divisions_per_bar)) * BBT_Time::ticks_per_bar_division) ;
|
||||
} else {
|
||||
--result.beats;
|
||||
ticks_at_beat = (uint32_t) BBT_Time::ticks_per_beat;
|
||||
ticks_at_beat = (uint32_t) BBT_Time::ticks_per_bar_division;
|
||||
}
|
||||
|
||||
if (t <= ticks_at_beat) {
|
||||
|
|
@ -1186,7 +1186,7 @@ TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, int dir)
|
|||
|
||||
bbt_time(fr, the_beat);
|
||||
|
||||
ticks_one_subdivisions_worth = (uint32_t)BBT_Time::ticks_per_beat / sub_num;
|
||||
ticks_one_subdivisions_worth = (uint32_t)BBT_Time::ticks_per_bar_division / sub_num;
|
||||
ticks_one_half_subdivisions_worth = ticks_one_subdivisions_worth / 2;
|
||||
|
||||
if (dir > 0) {
|
||||
|
|
@ -1293,7 +1293,7 @@ TempoMap::round_to_type (framepos_t frame, int dir, BBTPointType type)
|
|||
float midbar_ticks;
|
||||
|
||||
midbar_beats = metric.meter().divisions_per_bar() / 2 + 1;
|
||||
midbar_ticks = BBT_Time::ticks_per_beat * fmod (midbar_beats, 1.0f);
|
||||
midbar_ticks = BBT_Time::ticks_per_bar_division * fmod (midbar_beats, 1.0f);
|
||||
midbar_beats = floor (midbar_beats);
|
||||
|
||||
BBT_Time midbar (bbt.bars, lrintf (midbar_beats), lrintf (midbar_ticks));
|
||||
|
|
@ -1346,7 +1346,7 @@ TempoMap::round_to_type (framepos_t frame, int dir, BBTPointType type)
|
|||
/* "true" rounding */
|
||||
|
||||
/* round to nearest beat */
|
||||
if (bbt.ticks >= (BBT_Time::ticks_per_beat/2)) {
|
||||
if (bbt.ticks >= (BBT_Time::ticks_per_bar_division/2)) {
|
||||
|
||||
try {
|
||||
bbt = bbt_add (bbt, one_beat, metric);
|
||||
|
|
@ -1752,9 +1752,9 @@ TempoMap::bbt_add (const BBT_Time& start, const BBT_Time& increment, const Tempo
|
|||
BBT_Time op = increment; /* argument is const, but we need to modify it */
|
||||
uint32_t ticks = result.ticks + op.ticks;
|
||||
|
||||
if (ticks >= BBT_Time::ticks_per_beat) {
|
||||
if (ticks >= BBT_Time::ticks_per_bar_division) {
|
||||
op.beats++;
|
||||
result.ticks = ticks % (uint32_t) BBT_Time::ticks_per_beat;
|
||||
result.ticks = ticks % (uint32_t) BBT_Time::ticks_per_bar_division;
|
||||
} else {
|
||||
result.ticks += op.ticks;
|
||||
}
|
||||
|
|
@ -1855,7 +1855,7 @@ TempoMap::bbt_subtract (const BBT_Time& start, const BBT_Time& decrement) const
|
|||
if (op.ticks > result.ticks) {
|
||||
/* subtract an extra beat later; meanwhile set ticks to the right "carry" value */
|
||||
op.beats++;
|
||||
result.ticks = BBT_Time::ticks_per_beat - (op.ticks - result.ticks);
|
||||
result.ticks = BBT_Time::ticks_per_bar_division - (op.ticks - result.ticks);
|
||||
} else {
|
||||
result.ticks -= op.ticks;
|
||||
}
|
||||
|
|
@ -2228,12 +2228,12 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const
|
|||
pos += llrint (beats * frames_per_beat);
|
||||
|
||||
if (op.ticks) {
|
||||
if (op.ticks >= BBT_Time::ticks_per_beat) {
|
||||
if (op.ticks >= BBT_Time::ticks_per_bar_division) {
|
||||
pos += llrint (frames_per_beat + /* extra beat */
|
||||
(frames_per_beat * ((op.ticks % (uint32_t) BBT_Time::ticks_per_beat) /
|
||||
(double) BBT_Time::ticks_per_beat)));
|
||||
(frames_per_beat * ((op.ticks % (uint32_t) BBT_Time::ticks_per_bar_division) /
|
||||
(double) BBT_Time::ticks_per_bar_division)));
|
||||
} else {
|
||||
pos += llrint (frames_per_beat * (op.ticks / (double) BBT_Time::ticks_per_beat));
|
||||
pos += llrint (frames_per_beat * (op.ticks / (double) BBT_Time::ticks_per_bar_division));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1025,8 +1025,8 @@ MackieControlProtocol::format_bbt_timecode (framepos_t now_frame)
|
|||
subdiv = 3;
|
||||
}
|
||||
|
||||
uint32_t subdivisions = bbt_time.ticks / uint32_t (Timecode::BBT_Time::ticks_per_beat / subdiv);
|
||||
uint32_t ticks = bbt_time.ticks % uint32_t (Timecode::BBT_Time::ticks_per_beat / subdiv);
|
||||
uint32_t subdivisions = bbt_time.ticks / uint32_t (Timecode::BBT_Time::ticks_per_bar_division / subdiv);
|
||||
uint32_t ticks = bbt_time.ticks % uint32_t (Timecode::BBT_Time::ticks_per_bar_division / subdiv);
|
||||
|
||||
os << setw(2) << setfill('0') << subdivisions + 1;
|
||||
os << setw(3) << setfill('0') << ticks;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,20 @@
|
|||
|
||||
using namespace Timecode;
|
||||
|
||||
const double BBT_Time::ticks_per_beat = 1920.0;
|
||||
/* This number doesn't describe the smallest division of a "beat" (which is
|
||||
only defined contextually anyway), but rather the smallest division of the the
|
||||
divisions of a bar. If using a meter of 4/8, there are 4 divisions per bar, and
|
||||
we can divide each one into ticks_per_bar_division pieces; in a separate meter
|
||||
(section) of 3/8, there are 3 divisions per bar, each of which can be divided
|
||||
into ticks_per_bar_division pieces.
|
||||
|
||||
The number is intended to have as many integer factors as possible so that
|
||||
1/Nth divisions are integer numbers of ticks.
|
||||
|
||||
1920 is the largest legal value that be used inside an SMF file, and has many factors.
|
||||
*/
|
||||
|
||||
const double BBT_Time::ticks_per_bar_division = 1920.0;
|
||||
|
||||
BBT_Time::BBT_Time (double dbeats)
|
||||
{
|
||||
|
|
@ -36,5 +49,5 @@ BBT_Time::BBT_Time (double dbeats)
|
|||
|
||||
bars = 0;
|
||||
beats = rint (floor (dbeats));
|
||||
ticks = rint (floor (BBT_Time::ticks_per_beat * fmod (dbeats, 1.0)));
|
||||
ticks = rint (floor (BBT_Time::ticks_per_bar_division * fmod (dbeats, 1.0)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Timecode {
|
|||
|
||||
/** Bar, Beat, Tick Time (i.e. Tempo-Based Time) */
|
||||
struct BBT_Time {
|
||||
static const double ticks_per_beat;
|
||||
static const double ticks_per_bar_division;
|
||||
|
||||
uint32_t bars;
|
||||
uint32_t beats;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue