double SNM_GetProjectLength(bool _items, bool _inclRgnsMkrs) { double prjlen = 0.0, pos, end; if (_inclRgnsMkrs) { int x=0; bool isRgn; while (x = EnumProjectMarkers2(NULL, x, &isRgn, &pos, &end, NULL, NULL)) { if (isRgn) { if (end > prjlen) prjlen = end; } else { if (pos > prjlen) prjlen = pos; } } } if (_items) { double len; for (int i=1; i <= GetNumTracks(); i++) // skip master if (MediaTrack* tr = CSurf_TrackFromID(i, false)) for (int j=0; j < GetTrackNumMediaItems(tr); j++) if (MediaItem* item = GetTrackMediaItem(tr,j)) { pos = *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL); len = *(double*)GetSetMediaItemInfo(item, "D_LENGTH", NULL); if ((pos+len)>prjlen) prjlen = pos+len; } } return prjlen; }
int GetMarkerRegionIdFromIndex(ReaProject* _proj, int _idx) { if (_idx >= 0) { int num; bool isrgn; if (EnumProjectMarkers2(_proj, _idx, &isrgn, NULL, NULL, NULL, &num)) return MakeMarkerRegionId(num, isrgn); } return -1; }
// enumerates by index, see remarks above int EnumMarkerRegionDesc(ReaProject* _proj, int _idx, char* _descOut, int _outSz, int _flags, bool _wantNum, bool _wantName, bool _wantTime) { if (_descOut && _outSz && _idx >= 0) { *_descOut = '\0'; double pos, end; int num; bool isrgn; const char* name; int nextIdx = EnumProjectMarkers2(_proj, _idx, &isrgn, &pos, &end, &name, &num); if (nextIdx>0) GetMarkerRegionDesc(name, isrgn, num, pos, end, _flags, _wantNum, _wantName, _wantTime, _descOut, _outSz); return nextIdx; } return 0; }
// flags&1=incl. items, &2=incl. markers/regions, &4=incl. envelopes double SNM_GetProjectLength(int _flags) { double prjlen = 0.0, pos, end; if (_flags&2) { int x=0; bool isRgn; while ((x = EnumProjectMarkers2(NULL, x, &isRgn, &pos, &end, NULL, NULL))) { if (isRgn) { if (end > prjlen) prjlen = end; } else { if (pos > prjlen) prjlen = pos; } } } if ((_flags&1) || (_flags&4)) { double len; for (int i=0; i <= GetNumTracks(); i++) { if (MediaTrack* tr = CSurf_TrackFromID(i, false)) { int cnt= i>0 ? GetTrackNumMediaItems(tr) : 0; // skip master if (_flags&1) for (int j=0; j<cnt; j++) { if (MediaItem* item = GetTrackMediaItem(tr,j)) { pos = *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL); len = *(double*)GetSetMediaItemInfo(item, "D_LENGTH", NULL); if ((pos+len)>prjlen) prjlen = pos+len; } } cnt=CountTrackEnvelopes(tr); if (_flags&4) for (int j=0; j<cnt; j++) { if (TrackEnvelope* env = GetTrackEnvelope(tr,j)) { if (int ptcnt=CountEnvelopePoints(env)) { pos=prjlen; GetEnvelopePoint(env, ptcnt-1, &pos, NULL, NULL, NULL, NULL); if (pos>prjlen) prjlen = pos; } } } } } } return prjlen; }
bool FindWnd::FindMarkerRegion(int _dir) { if (!_dir) return false; bool update = false, found = false; if (g_searchStr && *g_searchStr) { double startPos = GetCursorPositionEx(NULL); int id, x = 0; bool bR; double dPos, dRend, dMinMaxPos = _dir < 0 ? -DBL_MAX : DBL_MAX; const char *cName; while ((x=EnumProjectMarkers2(NULL, x, &bR, &dPos, &dRend, &cName, &id))) { if (_dir == 1 && dPos > startPos) { if (stristr(cName, g_searchStr)) { found = true; dMinMaxPos = min(dPos, dMinMaxPos); } } else if (_dir == -1 && dPos < startPos) { if (stristr(cName, g_searchStr)) { found = true; dMinMaxPos = max(dPos, dMinMaxPos); } } } UpdateNotFoundMsg(found); if (found) { SetEditCurPos2(NULL, dMinMaxPos, true, false); update = true; } } if (update) Undo_OnStateChangeEx2(NULL, __LOCALIZE("Find: change edit cursor position","sws_undo"), UNDO_STATE_ALL, -1); // in case the pref "undo pt for edit cursor positions" is enabled.. return update; }