RPR GetTrackNumMediaItems

From CockosWiki

(Difference between revisions)
Jump to: navigation, search
(See Also)
(C++)
 
(5 intermediate revisions not shown)
Line 1: Line 1:
{{API_Doc_Header}}
{{API_Doc_Header}}
-
= =
+
=GetTrackNumMediaItems()=
 +
'''int GetTrackNumMediaItems(MediaTrack* tr)'''
 +
 
==Parameters==
==Parameters==
 +
MediaTrack* tr
==Returns==
==Returns==
 +
int
==Examples==
==Examples==
 +
===C++===
 +
<source lang=cpp highlight=16>
 +
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>
 +
===Perl===
===Perl===
-
<pre>
+
<source lang=perl>
-
</pre>
+
# Example - Show number of items on selected track.pl
 +
 
 +
use strict;
 +
use warnings;
 +
 
 +
use constant CURR_PROJ => 0;
 +
 
 +
# Get pointer to first track in selection
 +
my $Track_ID = RPR_GetSelectedTrack(CURR_PROJ, 0);
 +
 
 +
# Get numer of items on track
 +
my $Item_Count = RPR_GetTrackNumMediaItems($Track_ID);
 +
 
 +
# Display summary message
 +
if (! $Item_Count) {
 +
RPR_ShowConsoleMsg("Selected track has no items.\n");
 +
} elsif ($Item_Count == 1) {
 +
RPR_ShowConsoleMsg("Selected track has 1 item.\n");
 +
} else {
 +
RPR_ShowConsoleMsg("Selected track has $Item_Count items.\n");
 +
}
 +
</source>
 +
 
 +
 
===Python===
===Python===
-
<pre>
+
<source lang=python>
-
</pre>
+
</source>
 +
 
==See Also==
==See Also==
-
{{SeeAlsoMediaItemFunctions}}
+
{{SeeAlso_track}}
 +
 
 +
{{SeeAlso_item}}
-
{{SeeAlsoTrackFunctions}}
+
''(Section automatically generated, edits may be overwritten.)''
==Stuff==
==Stuff==

Latest revision as of 20:13, 29 January 2010

Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetTrackNumMediaItems
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetTrackNumMediaItems

Contents

GetTrackNumMediaItems()

int GetTrackNumMediaItems(MediaTrack* tr)

Parameters

MediaTrack* tr

Returns

int 

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

# Example - Show number of items on selected track.pl
 
use strict;
use warnings;
 
use constant CURR_PROJ => 0;
 
# Get pointer to first track in selection
my $Track_ID = RPR_GetSelectedTrack(CURR_PROJ, 0);
 
# Get numer of items on track
my $Item_Count = RPR_GetTrackNumMediaItems($Track_ID);
 
# Display summary message
if (! $Item_Count) {
	RPR_ShowConsoleMsg("Selected track has no items.\n");
} elsif ($Item_Count == 1) {
	RPR_ShowConsoleMsg("Selected track has 1 item.\n");
} else {
	RPR_ShowConsoleMsg("Selected track has $Item_Count items.\n");
}


Python

 

See Also

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,

item: AddMediaItemToTrack, AddTakeToMediaItem, GetTrackMediaItem, GetTrackNumMediaItems, CountMediaItems, CountSelectedMediaItems, GetItemProjectContext, SetMediaItemInfo_Value, CountTrackMediaItems, SetMediaItemTakeInfo_Value, GetMediaItem, GetMediaItem_Track, GetMediaItemInfo_Value, GetMediaItemNumTakes, GetMediaItemTake, GetMediaItemTake_Item, GetMediaItemTake_Source, GetMediaItemTake_Track, GetMediaItemTakeInfo_Value, SplitMediaItem, MoveMediaItemToTrack, GetSelectedMediaItem, DeleteTrackMediaItem, GetSetItemState, GetSetMediaItemTakeInfo_String, Undo_OnStateChange_Item, UpdateItemInProject,

(Section automatically generated, edits may be overwritten.)

Stuff

Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetTrackNumMediaItems
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetTrackNumMediaItems

Personal tools