Jump to conversation
Unresolved conversations (15)
@cfillion cfillion Oct 17, 2022
Envelope 0 is not always the tempo envelope if there are other envelopes on the master track. ```cpp GetTrackEnvelopeByName(masterTrack, __LOCALIZE("Tempo map", "env")) ```
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
Off-by-one error: `GetTempoTimeSigMarker(count)` does not exist.
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
Could probably write the new tempo envelope only once after (or before?) processing all regions instead of once for every region.
SnM/SnM_RegionPlaylist.cpp
@cfillion cfillion Oct 17, 2022
Since this function overwrites the entire envelope state chunk later on, couldn't it just insert the new markers into it and skip everything else?
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
These `TempoMarker` are leaking. Could use a `WDL_PtrList_DeleteOnDestroy`, but in any case there's no point in allocating this small data structure on the heap and making a list of their pointers. This `TempoMarker` could be on the stack then copied into a `std::vector<TempoMap>` (whose data is stored in the heap anyway).
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
Most of these are unused. Since it's just a simple POD struct, direct member access is OK. (Also `protected` instead of `private` implies this class is meant to be inherited.) ```cpp struct TempoMarker { double m_dTimePos; int m_measurePos; double m_dBeatPos, m_dBpm; int m_timesig_num, m_timesig_denom; bool m_bLinearTempo; RawTempoMarkerData m_rawData; // why a separate struct? most of the data overlap }; ```
SnM/SnM_Marker.h
@cfillion cfillion Oct 17, 2022
Why copy the list?
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
Since it being nullable has no purpose (would be a bug anyway), it could be a reference. ```suggestion bool IsTempoMarkerInInterval(const TempoMarker &tempoMarker, const double rangeStart, const double rangeEnd) { const double pos = tempoMarker.GetTimePosition(); return pos >= rangeStart && pos <= rangeEnd; } ```
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
`tempoMarker` leaks if false. (Well, it's never freed anyway even if true... as mentioned above) ```cpp else delete tempoMarker; ```
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
Lots of duplicate code here. Should be extracted & reused.
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
`quantizationSettings[10]` can overflow here! Better to use `LineParser` (the official parser from Cockos) for reading chunk lines.
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
These are pretty far from their use and in a wider scope. And since these are most of `TempoMarker` members duplicated, it could just be a `TempoMarker` instead.
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
The caller code would be completely broken if it passed a null `tempoMarkers`. It should crash instead of silently failing. In this case though it would better to just build a local list and return it: ```cpp WDL_PtrList<TempoMarker> GetAllTempoMarkers(ReaProject* _proj); ``` At the very least, an indentation level could be saved with ```cpp if (!_tempoMarkers) return; ```
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
A map is overkill for contiguous 0-based integer keys. A simple vector would suffice (and be more efficient, especially if pre-reserving space for `CountTempoTimeSigMarkers` items).
SnM/SnM_Marker.cpp
@cfillion cfillion Oct 17, 2022
Why `void*`? `WDL_PtrList<TempoMarker>` would be clearer and safer by not requiring a cast on access.
SnM/SnM_Marker.cpp
Resolved conversations (0)