temporal: a guess at how to use BBT markers from within TempoMap::paste()
Basically, if the paste position is not zero and not on a bar line, we will a BBT marker there, using the existing tempo & meter at that position before the paste. If the end of the paste is not on a bar line, we will place a BBT marker there, using the tempo & meter that existed before the paste. TempoMap::paste() now also accepts an optional final argument that if provided is used to name the BBT markers, if they are created
This commit is contained in:
parent
7997c83b01
commit
6c44dbf9d6
@ -971,29 +971,25 @@ TempoMap::cut_copy (timepos_t const & start, timepos_t const & end, bool copy, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool ripple)
|
TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool ripple, std::string suggested_name)
|
||||||
{
|
{
|
||||||
std::cerr << "\n\n PASTE \n\n";
|
|
||||||
|
|
||||||
if (cb.empty()) {
|
if (cb.empty()) {
|
||||||
std::cerr << "nothing to paste\n";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dump (std::cerr);
|
dump (std::cerr);
|
||||||
|
|
||||||
std::cerr << "tm paste, ripple " << ripple << std::endl;
|
|
||||||
if (ripple) {
|
if (ripple) {
|
||||||
shift (position, cb.duration());
|
shift (position, cb.duration());
|
||||||
}
|
}
|
||||||
|
|
||||||
dump (std::cerr);
|
dump (std::cerr);
|
||||||
|
|
||||||
bool replaced_ignored;
|
|
||||||
|
|
||||||
|
/* We need to look these up first, before we change the map */
|
||||||
const timepos_t end_position = position + cb.duration();
|
const timepos_t end_position = position + cb.duration();
|
||||||
Tempo end_tempo = tempo_at (end_position);
|
const Tempo end_tempo = tempo_at (end_position);
|
||||||
Meter end_meter = meter_at (end_position);
|
const Meter end_meter = meter_at (end_position);
|
||||||
|
|
||||||
/* iterate over _points since they are already in sclock order, and we
|
/* iterate over _points since they are already in sclock order, and we
|
||||||
* won't need to post-sort the way we would if we handled tempos,
|
* won't need to post-sort the way we would if we handled tempos,
|
||||||
@ -1004,19 +1000,31 @@ TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool
|
|||||||
Beats pos_beats = quarters_at (position);
|
Beats pos_beats = quarters_at (position);
|
||||||
bool ignored;
|
bool ignored;
|
||||||
bool replaced;
|
bool replaced;
|
||||||
Tempo const * st = cb.start_tempo();
|
MusicTimePoint* mtp;
|
||||||
Meter const * mt = cb.start_meter();
|
superclock_t s;
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
/* Do not try to put a BBT marker at absolute zero or anywhere on a bar */
|
||||||
|
|
||||||
|
if (!position.is_zero() && (pos_bbt.ticks != 0 || pos_bbt.beats != 1)) {
|
||||||
|
|
||||||
|
if (suggested_name.empty()) {
|
||||||
|
name = _("paste>");
|
||||||
|
} else {
|
||||||
|
name = string_compose (X_("%1>"), suggested_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtp = new MusicTimePoint (*this, position.superclocks(), pos_beats, pos_bbt, tempo_at (position), meter_at (position), name);
|
||||||
|
|
||||||
#if 0
|
|
||||||
MusicTimePoint* mtp = new MusicTimePoint (*this, position.superclocks(), pos_beats, pos_bbt, tempo_at (position), meter_at (position), _("paste start"));
|
|
||||||
core_add_bartime (mtp, replaced);
|
core_add_bartime (mtp, replaced);
|
||||||
|
|
||||||
if (!replaced) {
|
if (!replaced) {
|
||||||
core_add_tempo (mtp, ignored);
|
core_add_tempo (mtp, ignored);
|
||||||
core_add_meter (mtp, ignored);
|
core_add_meter (mtp, ignored);
|
||||||
core_add_point (mtp);
|
core_add_point (mtp);
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
superclock_t s;
|
|
||||||
|
|
||||||
for (auto const & p : cb.points()) {
|
for (auto const & p : cb.points()) {
|
||||||
TempoPoint const * tp;
|
TempoPoint const * tp;
|
||||||
@ -1067,15 +1075,22 @@ TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool
|
|||||||
pos_bbt = bbt_at (end_position);
|
pos_bbt = bbt_at (end_position);
|
||||||
pos_beats = quarters_at (end_position);
|
pos_beats = quarters_at (end_position);
|
||||||
|
|
||||||
#if 0
|
if (pos_bbt.ticks != 0 || pos_bbt.beats != 1) {
|
||||||
mtp = new MusicTimePoint (*this, end_position.superclocks(), pos_beats, pos_bbt, end_tempo, end_meter, _("paste end"));
|
|
||||||
|
if (suggested_name.empty()) {
|
||||||
|
name = _("<paste");
|
||||||
|
} else {
|
||||||
|
name = string_compose (X_("<%1"), suggested_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtp = new MusicTimePoint (*this, end_position.superclocks(), pos_beats, pos_bbt, end_tempo, end_meter, name);
|
||||||
core_add_bartime (mtp, replaced);
|
core_add_bartime (mtp, replaced);
|
||||||
if (!replaced) {
|
if (!replaced) {
|
||||||
core_add_tempo (mtp, ignored);
|
core_add_tempo (mtp, ignored);
|
||||||
core_add_meter (mtp, ignored);
|
core_add_meter (mtp, ignored);
|
||||||
core_add_point (mtp);
|
core_add_point (mtp);
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
reset_starting_at (s);
|
reset_starting_at (s);
|
||||||
dump (std::cerr);
|
dump (std::cerr);
|
||||||
|
@ -897,7 +897,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
|
|||||||
|
|
||||||
LIBTEMPORAL_API TempoMapCutBuffer* cut (timepos_t const & start, timepos_t const & end, bool ripple);
|
LIBTEMPORAL_API TempoMapCutBuffer* cut (timepos_t const & start, timepos_t const & end, bool ripple);
|
||||||
LIBTEMPORAL_API TempoMapCutBuffer* copy (timepos_t const & start, timepos_t const & end);
|
LIBTEMPORAL_API TempoMapCutBuffer* copy (timepos_t const & start, timepos_t const & end);
|
||||||
LIBTEMPORAL_API void paste (TempoMapCutBuffer const &, timepos_t const & position, bool ripple);
|
LIBTEMPORAL_API void paste (TempoMapCutBuffer const &, timepos_t const & position, bool ripple, std::string = std::string());
|
||||||
|
|
||||||
LIBTEMPORAL_API void shift (timepos_t const & at, BBT_Offset const & by);
|
LIBTEMPORAL_API void shift (timepos_t const & at, BBT_Offset const & by);
|
||||||
LIBTEMPORAL_API void shift (timepos_t const & at, timecnt_t const & by);
|
LIBTEMPORAL_API void shift (timepos_t const & at, timecnt_t const & by);
|
||||||
|
Loading…
Reference in New Issue
Block a user