fix error in framepos_{plus,minus}_bbt() which miscounted beats while stepping through bars - stops dragged MIDI notes from ending up in the wrong place, and more
git-svn-id: svn://localhost/ardour2/branches/3.0@11159 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2858b0474e
commit
f61a0d892c
@ -1498,7 +1498,6 @@ void
|
|||||||
MidiRegionView::update_note (CanvasNote* ev, bool update_ghost_regions)
|
MidiRegionView::update_note (CanvasNote* ev, bool update_ghost_regions)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NoteType> note = ev->note();
|
boost::shared_ptr<NoteType> note = ev->note();
|
||||||
|
|
||||||
const double x = trackview.editor().frame_to_pixel (source_beats_to_region_frames (note->time()));
|
const double x = trackview.editor().frame_to_pixel (source_beats_to_region_frames (note->time()));
|
||||||
const double y1 = midi_stream_view()->note_to_y(note->note());
|
const double y1 = midi_stream_view()->note_to_y(note->note());
|
||||||
|
|
||||||
@ -2303,12 +2302,8 @@ MidiRegionView::note_dropped(CanvasNoteEvent *, frameoffset_t dt, int8_t dnote)
|
|||||||
|
|
||||||
for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) {
|
for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) {
|
||||||
|
|
||||||
cerr << "Note dropped, was at " << (*i)->note()->time() << " now + " << dt << endl;
|
framepos_t new_frames = source_beats_to_absolute_frames ((*i)->note()->time()) + dt;
|
||||||
cerr << "original pos as frames " << source_beats_to_absolute_frames ((*i)->note()->time()) << endl;
|
Evoral::MusicalTime new_time = absolute_frames_to_source_beats (new_frames);
|
||||||
|
|
||||||
Evoral::MusicalTime new_time = absolute_frames_to_source_beats (source_beats_to_absolute_frames ((*i)->note()->time()) + dt);
|
|
||||||
|
|
||||||
cerr << "new time in beats = " << new_time << endl;
|
|
||||||
|
|
||||||
if (new_time < 0) {
|
if (new_time < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
|
||||||
/** Takes a duration in beats and considers it as a distance from the origin
|
/** Takes a positive duration in beats and considers it as a distance from the origin
|
||||||
* supplied to the constructor. Returns the equivalent number of frames,
|
* supplied to the constructor. Returns the equivalent number of frames,
|
||||||
* taking tempo changes into account.
|
* taking tempo changes into account.
|
||||||
*/
|
*/
|
||||||
@ -32,7 +32,6 @@ framecnt_t
|
|||||||
BeatsFramesConverter::to (double beats) const
|
BeatsFramesConverter::to (double beats) const
|
||||||
{
|
{
|
||||||
assert (beats >= 0);
|
assert (beats >= 0);
|
||||||
|
|
||||||
return _tempo_map.framepos_plus_beats (_origin_b, beats) - _origin_b;
|
return _tempo_map.framepos_plus_beats (_origin_b, beats) - _origin_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1655,6 +1655,7 @@ TempoMap::framepos_minus_bbt (framepos_t pos, BBT_Time op)
|
|||||||
Glib::RWLock::ReaderLock lm (map_lock);
|
Glib::RWLock::ReaderLock lm (map_lock);
|
||||||
BBTPointList::const_iterator i;
|
BBTPointList::const_iterator i;
|
||||||
framecnt_t extra_frames = 0;
|
framecnt_t extra_frames = 0;
|
||||||
|
bool had_bars = (op.bars != 0);
|
||||||
|
|
||||||
/* start from the bar|beat right before (or at) pos */
|
/* start from the bar|beat right before (or at) pos */
|
||||||
|
|
||||||
@ -1667,11 +1668,19 @@ TempoMap::framepos_minus_bbt (framepos_t pos, BBT_Time op)
|
|||||||
|
|
||||||
while (i != _map->begin() && (op.bars || op.beats)) {
|
while (i != _map->begin() && (op.bars || op.beats)) {
|
||||||
--i;
|
--i;
|
||||||
if ((*i).is_bar()) {
|
|
||||||
if (op.bars) {
|
if (had_bars) {
|
||||||
op.bars--;
|
if ((*i).is_bar()) {
|
||||||
|
if (op.bars) {
|
||||||
|
op.bars--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if ((had_bars && op.bars == 0) || !had_bars) {
|
||||||
|
/* finished counting bars, or none to count,
|
||||||
|
so decrement beat count
|
||||||
|
*/
|
||||||
if (op.beats) {
|
if (op.beats) {
|
||||||
op.beats--;
|
op.beats--;
|
||||||
}
|
}
|
||||||
@ -1703,6 +1712,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op)
|
|||||||
int additional_minutes = 1;
|
int additional_minutes = 1;
|
||||||
BBTPointList::const_iterator i;
|
BBTPointList::const_iterator i;
|
||||||
framecnt_t backup_frames = 0;
|
framecnt_t backup_frames = 0;
|
||||||
|
bool had_bars = (op.bars != 0);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
@ -1714,12 +1724,22 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op)
|
|||||||
backup_frames = pos - (*i).frame;
|
backup_frames = pos - (*i).frame;
|
||||||
|
|
||||||
while (i != _map->end() && (op.bars || op.beats)) {
|
while (i != _map->end() && (op.bars || op.beats)) {
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
if ((*i).is_bar()) {
|
|
||||||
if (op.bars) {
|
if (had_bars) {
|
||||||
op.bars--;
|
if ((*i).is_bar()) {
|
||||||
|
if (op.bars) {
|
||||||
|
op.bars--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if ((had_bars && op.bars == 0) || !had_bars) {
|
||||||
|
/* finished counting bars, or none to count,
|
||||||
|
so decrement beat count
|
||||||
|
*/
|
||||||
|
|
||||||
if (op.beats) {
|
if (op.beats) {
|
||||||
op.beats--;
|
op.beats--;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user