Skip to content

Commit b1c96a6

Browse files
committed
[skip ci] another corner case
1 parent c5aa567 commit b1c96a6

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

Breeder/BR_EnvelopeUtil.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2961,10 +2961,15 @@ void CalculateSplitMiddlePoints (double* time1, double* time2, double* bpm1, dou
29612961
WritePtr(bpm2, val2);
29622962
}
29632963

2964-
void InitTempoMap ()
2964+
bool InitTempoMap ()
29652965
{
29662966
if (!CountTempoTimeSigMarkers(NULL))
2967+
{
29672968
SetTempoTimeSigMarker(NULL, -1, 0, -1, -1, GetProjectSettingsTempo(NULL, NULL), 0, 0, false);
2969+
return true;
2970+
}
2971+
else
2972+
return false;
29682973
}
29692974

29702975
void RemoveTempoMap ()

Breeder/BR_EnvelopeUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ double CalculateMeasureAtPosition (double startBpm, double endBpm, double timeLe
300300
double CalculatePositionAtMeasure (double startBpm, double endBpm, double timeLen, double targetMeasure);
301301
void CalculateMiddlePoint (double* middleTime, double* middleBpm, double measure, double startTime, double endTime, double startBpm, double endBpm);
302302
void CalculateSplitMiddlePoints (double* time1, double* time2, double* bpm1, double* bpm2, double splitRatio, double measure, double startTime, double middleTime, double endTime, double startBpm, double middleBpm, double endBpm);
303-
void InitTempoMap (); // will make sure there's at least one point in tempo map (we can't manipulate tempo map's chunk (i.e. insert new points) if there isn't at least one point in tempo map)
303+
bool InitTempoMap (); // will make sure there's at least one point in tempo map (we can't manipulate tempo map's chunk (i.e. insert new points) if there isn't at least one point in tempo map)
304304
void RemoveTempoMap ();
305305
void UnselectAllTempoMarkers ();
306306
void UpdateTempoTimeline (); // UpdateTimeline() isn't enough after changing tempo points through chunk - call this instead

Breeder/BR_Tempo.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,21 @@ static HCURSOR MoveGridCursor (COMMAND_T* ct, int window)
344344
*/
345345
static bool EnsureTempoSet(int id)
346346
{
347+
char debugStr[256];
348+
snprintf(debugStr, sizeof(debugStr), "EnsureTempoSet: id: %d\n", id);
349+
OutputDebugString(debugStr);
350+
347351
double timeposOut, beat, bpm;
348352
int measure, num, den;
349353
bool linear;
350-
GetTempoTimeSigMarker(NULL, id, &timeposOut, &measure, &beat, &bpm, &num, &den, &linear);
351-
//TODO is there any way to tell whether bpm has already been explicitly set by this point?
352-
SetTempoTimeSigMarker(NULL, id, timeposOut, measure, beat, bpm, num, den, linear);
353-
return true;
354+
if(GetTempoTimeSigMarker(NULL, id, &timeposOut, &measure, &beat, &bpm, &num, &den, &linear))
355+
{
356+
SetTempoTimeSigMarker(NULL, id, timeposOut, measure, beat, bpm, num, den, linear);
357+
//TODO is there any way to tell whether bpm has already been explicitly set by this point?
358+
return true;
359+
}
360+
else
361+
return false;
354362
}
355363

356364
static void MoveGridToMouse (COMMAND_T* ct)
@@ -367,16 +375,16 @@ static void MoveGridToMouse (COMMAND_T* ct)
367375
s_lastPosition = 0;
368376

369377
// Make sure tempo map already has at least one point created (for some reason it won't work if creating it directly in chunk)
370-
if (cmd != MOVE_CLOSEST_TEMPO_MOUSE)
371-
{
372-
InitTempoMap();
373-
g_didTempoMapInit = true;
374-
}
378+
g_didTempoMapInit = InitTempoMap();
375379

376380
g_moveGridTempoMap = new (nothrow) BR_Envelope(GetTempoEnv());
377381

378382
// Make sure previous point is editable via g_moveGridTempoMap.
379-
if (g_moveGridTempoMap && cmd != MOVE_CLOSEST_TEMPO_MOUSE)
383+
// FIXME in MOVE_CLOSEST_TEMPO_MOUSE, we need the prev point relative to
384+
// the closest point to be matched, not relative to the mouse.
385+
// eg., 4/4 12bpm <cursor>
386+
// ^--this needs tempo
387+
if (g_moveGridTempoMap && g_moveGridTempoMap->CountPoints())
380388
{
381389
// ensure previous point's bpm is explicitly set, otherwise changes won't register in BR_Envelope.
382390
if(EnsureTempoSet(g_moveGridTempoMap->FindPrevious(PositionAtMouseCursor(true))))

0 commit comments

Comments
 (0)