RPR CSurf TrackFromID
From CockosWiki
(→Examples) |
(→C++) |
||
Line 15: | Line 15: | ||
==Examples== | ==Examples== | ||
===C++=== | ===C++=== | ||
- | <source lang=cpp> | + | <source lang=cpp highlight=14> |
+ | void HorizZoomSelItems() | ||
+ | { | ||
+ | HWND hTrackView = GetTrackWnd(); | ||
+ | if (!hTrackView) | ||
+ | return; | ||
+ | |||
+ | RECT r; | ||
+ | GetClientRect(hTrackView, &r); | ||
+ | |||
+ | // Find the coordinates of the first and last selected item | ||
+ | double x1 = 1.0e300, x2 = -1.0e300; | ||
+ | for (int i = 1; i <= GetNumTracks(); i++) | ||
+ | { | ||
+ | MediaTrack* tr = CSurf_TrackFromID(i, false); | ||
+ | if (GetTrackVis(tr) & 2) | ||
+ | for (int j = 0; j < GetTrackNumMediaItems(tr); j++) | ||
+ | { | ||
+ | MediaItem* mi = GetTrackMediaItem(tr, j); | ||
+ | if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL)) | ||
+ | { | ||
+ | double d = *(double*)GetSetMediaItemInfo(mi, "D_POSITION", NULL); | ||
+ | if (d < x1) | ||
+ | x1 = d; | ||
+ | d += *(double*)GetSetMediaItemInfo(mi, "D_LENGTH", NULL); | ||
+ | if (d > x2) | ||
+ | x2 = d; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if (x1 >= 1.0e300) | ||
+ | return; | ||
+ | |||
+ | adjustZoom(0.94 * r.right / (x2 - x1), 1, false, -1); | ||
+ | SetHorizPos(hTrackView, x1, 0.03); | ||
+ | } | ||
</source> | </source> | ||
+ | |||
===Perl=== | ===Perl=== | ||
<source lang=perl> | <source lang=perl> |
Latest revision as of 20:12, 29 January 2010
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR CSurf TrackFromID
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR CSurf TrackFromID
Contents |
CSurf_TrackFromID()
MediaTrack* CSurf_TrackFromID(int idx, bool mcpView)
track index 0 always = master track note these indices in mcpView can be tracks in any order (mixer view), if !mcpView, 1->n = tracks (note the 1-based which differs from "GetTrackInfo"'s indices which are 0 based
This is a short summary of the available Control Surface functions, it is included in each CSurf function page.
Function Type | Example(s) | Description |
---|---|---|
“On” | CSurf_OnPlay, CSurf_OnStop | Called from the plugin in response to a h/w event. e.g. The user presses the physical Play button on the control surface and CSurf_OnPlay() is called by the plugin to set REAPER playing the current project |
“Set”, “Get” | CSurf_SetSurfaceRecArm | Called by the plugin to to set the state of a track inside reaper (mute it, solo it etc.) |
Utility | CSurf_TrackFromID, CSurf_TrackToID, | Not triggered by a h/w or REAPER event but used within the plugin. e.g. To translate between REAPER and h/w track indexes. |
Other | ||
MIDI | CreateMIDIInput, CreateMIDIOutput | Functions to create objects which control MIDI devices, including control surfaces. |
REAPER calls a control surface through the IReaperControlSurface interface (defined in reaper_plugin.h) which a plugin has to register on startup. The function names of this interface are very similar to the CSurf_* functions, they just work the other way round (from REAPER to the plugin).
Parameters
int idx, bool mcpView
Returns
MediaTrack*
Examples
C++
void HorizZoomSelItems() { HWND hTrackView = GetTrackWnd(); if (!hTrackView) return; RECT r; GetClientRect(hTrackView, &r); // Find the coordinates of the first and last selected item double x1 = 1.0e300, x2 = -1.0e300; for (int i = 1; i <= GetNumTracks(); i++) { MediaTrack* tr = CSurf_TrackFromID(i, false); if (GetTrackVis(tr) & 2) for (int j = 0; j < GetTrackNumMediaItems(tr); j++) { MediaItem* mi = GetTrackMediaItem(tr, j); if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL)) { double d = *(double*)GetSetMediaItemInfo(mi, "D_POSITION", NULL); if (d < x1) x1 = d; d += *(double*)GetSetMediaItemInfo(mi, "D_LENGTH", NULL); if (d > x2) x2 = d; } } } if (x1 >= 1.0e300) return; adjustZoom(0.94 * r.right / (x2 - x1), 1, false, -1); SetHorizPos(hTrackView, x1, 0.03); }
Perl
Python
See Also
csurf: CSurf_FlushUndo, CSurf_GetTouchState, CSurf_GoEnd, CSurf_GoStart, CSurf_NumTracks, CSurf_OnArrow, CSurf_OnFXChange, CSurf_OnFwd, CSurf_OnMuteChange, CSurf_OnPanChange, CSurf_OnPanChangeEx, CSurf_OnPlay, CSurf_OnRecArmChange, CSurf_OnRecord, CSurf_OnRew, CSurf_OnSelectedChange, CSurf_OnSoloChange, CSurf_OnStop, CSurf_OnTrackSelection, CSurf_OnVolumeChange, CSurf_OnVolumeChangeEx, CSurf_ResetAllCachedVolPanStates, CSurf_ScrubAmt, CSurf_SetAutoMode, CSurf_SetPlayState, CSurf_SetRepeatState, CSurf_SetSurfaceMute, CSurf_SetSurfacePan, CSurf_SetSurfaceRecArm, CSurf_SetSurfaceSelected, CSurf_SetSurfaceSolo, CSurf_SetSurfaceVolume, CSurf_SetTrackListChange, CSurf_TrackFromID, CSurf_TrackToID,
track: GetLastTouchedTrack, GetMediaItemTake_Track, GetMediaItem_Track, GetMediaTrackInfo_Value, GetNumTracks, GetSelectedTrack, GetSelectedTrackEnvelope, GetSetMediaTrackInfo_String, GetSetTrackState, GetTrack, GetTrackAutomationMode, GetTrackEnvelope, GetTrackEnvelopeByName, GetTrackGUID, GetTrackMIDINoteName, GetTrackMIDINoteNameEx, GetTrackMediaItem, GetTrackNumMediaItems, GetTrackState, GetTrackUIVolPan, HasTrackMIDIPrograms, HasTrackMIDIProgramsEx, InsertTrackAtIndex, MoveMediaItemToTrack, MuteAllTracks, PlayTrackPreview, PlayTrackPreview2, SetMediaTrackInfo_Value, SetTrackAutomationMode, SetTrackMIDINoteName, SetTrackMIDINoteNameEx, SetTrackSelected, SoloAllTracks, StopTrackPreview, StopTrackPreview2, TrackFX_FormatParamValue, TrackFX_GetCount, TrackFX_GetFXName, TrackFX_GetNumParams, TrackFX_GetParam, TrackFX_GetParamName, TrackFX_SetParam, TrackList_AdjustWindows, TrackList_UpdateAllExternalSurfaces, Track_GetPeakInfo, AddMediaItemToTrack, BypassFxAllTracks, CSurf_NumTracks, CSurf_OnTrackSelection, CSurf_SetTrackListChange, CSurf_TrackFromID, CSurf_TrackToID, CountSelectedTracks, CountTrackEnvelopes, CountTrackMediaItems, CountTracks, DeleteTrack, DeleteTrackMediaItem, EnumTrackMIDIProgramNames, EnumTrackMIDIProgramNamesEx,
(Section automatically generated, edits may be overwritten.)
Stuff
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR CSurf TrackFromID
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR CSurf TrackFromID