RPR AddMediaItemToTrack
From CockosWiki
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR AddMediaItemToTrack
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR AddMediaItemToTrack
Contents |
AddMediaItemToTrack()
MediaItem* AddMediaItemToTrack(MediaTrack* tr) Creates a new media item in the specified track, the new item is created right at the beginning of the track.
Parameters
Parameter type | Name | Description |
---|---|---|
MediaTrack* | track | A pointer to the track that will contain the new item |
Returns
Returns a scalar value because there are no modifiable variables in the parameter list.
Parameter type | Description |
---|---|
MediaItem* | A pointer to the new Media Item |
Caveats
After using AddMediaItemToTrack() and then setting the contents of the new item with GetSetItemState() you might experience some "graphical glitches" - involving Items apparently disappearing after Zooming in or out, Waveforms (Peaks images) not always displaying.
These odd things resolve after saving the project, closing and then reloading it but that's not something you'll want to do in a script. The Item's display will also be corrected if you use another (Non-GetSet*State function) to update the Item, e.g You could use SetMediaItemInfo_Value() to set the position.
Examples
C++
Perl
# # AddMediaItemToTrack.pl # use strict; use warnings; use constant MSGBOX_JUSTOK => 0; use constant CURR_PROJ => 0; # Check to make sure there's a track selected if(RPR_CountSelectedTracks(CURR_PROJ) > 0){ # Get a reference to the selected track my $MediaTrack = RPR_GetSelectedTrack(CURR_PROJ,0); # And then use that reference to add a new, very blank, media item # We get a reference to the new item returned to us, if it went ok if (my $MediaItem = RPR_AddMediaItemToTrack($MediaTrack)){ # so we can use that reference to make the item long enough to see RPR_SetMediaItemInfo_Value($MediaItem, "D_LENGTH", 1.0); } }
Python
# # AddMediaItemToTrack.py # MSGBOX_JUSTOK, CURR_PROJ = 0,0; # Check to make sure there's a track selected if (RPR_CountSelectedTracks(CURR_PROJ) > 0): # Get a reference to the selected track MediaTrack = RPR_GetSelectedTrack(CURR_PROJ,0); # And then use that reference to add a new, very blank, media item # We get a reference to the new item returned to us, if it went ok if (MediaItem = RPR_AddMediaItemToTrack(MediaTrack)): # so we can use that reference to make the item long enough to see RPR_SetMediaItemInfo_Value(MediaItem, "D_LENGTH", 1.0);
See Also
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,
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 AddMediaItemToTrack
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR AddMediaItemToTrack