// native assumption: only 1 env selected at a time (v4.13) MediaTrack* GetTrackWithSelEnv() { if (TrackEnvelope* env = GetSelectedTrackEnvelope(NULL)) for (int i=0; i <= GetNumTracks(); i++) // incl. master if (MediaTrack* tr = CSurf_TrackFromID(i, false)) for (int j=0; j < CountTrackEnvelopes(tr); j++) if (env == GetTrackEnvelope(tr, j)) return tr; return NULL; }
/////////////////////////////////////////////////////////////////////////////////////////////////// /// Envelope /////////////////////////////////////////////////////////////////////////////////////////////////// int CountVisibleTrackEnvelopesInTrackLane(MediaTrack* track) { int count = 0; for (int i = 0; i < CountTrackEnvelopes(track); i++) { bool visible, lane; visible = EnvVis(GetTrackEnvelope(track, i), &lane); if (visible && !lane) count++; } return count; }
// 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; }