RPR GetSetMediaItemInfo

From CockosWiki

Jump to: navigation, search

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

Contents

GetSetMediaItemInfo()

void * GetSetMediaItemInfo(MediaItem *item, const char *parmname, void *setNewValue)

get (or set) different media item parameters:

  • "P_TRACK" : MediaTrack * (read only)
  • "B_MUTE" : bool * to "muted" state
  • "B_LOOPSRC" : bool * to "loop source"
  • "B_ALLTAKESPLAY" : bool * to "all takes play"
  • "B_UISEL" : bool * to "ui selected"
  • "C_BEATATTACHMODE" : char * to one char of "beat attached mode", -1=def, 0=time, 1=allbeats, 2=beatsposonly
  • "C_LOCK" : char * to one char of "lock flags" (&1 is locked, currently)
  • "D_VOL" : double * of item volume (volume bar)
  • "D_POSITION" : double * of item position (seconds)
  • "D_LENGTH" : double * of item length (seconds)
  • "D_SNAPOFFSET" : double * of item snap offset (seconds)
  • "D_FADEINLEN" : double * of item fade in length (manual, seconds)
  • "D_FADEOUTLEN" : double * of item fade out length (manual, seconds)
  • "D_FADEINLEN_AUTO" : double * of item autofade in length (seconds, -1 for "no autofade set")
  • "D_FADEOUTLEN_AUTO" : double * of item autofade out length (seconds, -1 for "no autofade set")
  • "C_FADEINSHAPE" : int * to fadein shape, 0=linear, ...
  • "C_FADEOUTSHAPE" : int * to fadeout shape
  • "I_GROUPID" : int * to group ID (0 = no group)
  • "I_LASTY" : int * to last y position in track (readonly)
  • "I_LASTH" : int * to last height in track (readonly)
  • "I_CUSTOMCOLOR" : int * : custom color, windows standard color order (i.e. RGB(r,g,b)|0x100000). if you do not |0x100000, then it will not be used (though will store the color anyway)
  • "I_CURTAKE" : int * to active take
  • "F_FREEMODE_Y" : float * to free mode y position (0..1)
  • "F_FREEMODE_H" : float * to free mode height (0..1)

Parameters

MediaItem *item,
const char *parmname,
void *setNewValue

Returns

void *

Example

C++

void DoInsRndFileEx(bool RndLen,bool RndOffset,bool UseTimeSel)
{
	if (g_filenames->GetSize()>0)
	{
		int filenameindex=rand() % g_filenames->GetSize();
 
		t_vect_of_Reaper_tracks TheTracks;
		XenGetProjectTracks(TheTracks,true);
		if (TheTracks.size()>0)
		{
		PCM_source *NewPCM=PCM_Source_CreateFromFile(g_filenames->Get(filenameindex));
		MediaItem *NewItem=AddMediaItemToTrack(TheTracks[0]);
		MediaItem_Take *NewTake=AddTakeToMediaItem(NewItem);
		double TimeSelStart=0.0;
		double TimeSelEnd=NewPCM->GetLength();
		GetSet_LoopTimeRange(false,false,&TimeSelStart,&TimeSelEnd,false);
		double ItemPos=TimeSelStart;
		double ItemLen=NewPCM->GetLength();
		double MediaOffset=0.0;
		if (RndOffset) 
		{
			MediaOffset=(NewPCM->GetLength()/RAND_MAX)*rand();
			ItemLen-=MediaOffset;
		}
		if (RndLen) ItemLen=((NewPCM->GetLength()-MediaOffset)/RAND_MAX)*rand();
		if (UseTimeSel) ItemLen=TimeSelEnd-TimeSelStart;
		if (!UseTimeSel) ItemPos=GetCursorPosition();
		GetSetMediaItemTakeInfo(NewTake,"P_SOURCE",NewPCM);
		GetSetMediaItemTakeInfo(NewTake,"D_STARTOFFS",&MediaOffset);
 
		GetSetMediaItemInfo(NewItem,"D_POSITION",&ItemPos);		GetSetMediaItemInfo(NewItem,"D_LENGTH",&ItemLen);		Main_OnCommand(40047,0); // build any missing peaks
		SetEditCurPos(ItemPos+ItemLen,false,false);
		Undo_OnStateChangeEx("Insert random file (Extended)",4,-1);
 
		UpdateTimeline();
		}
	}	
}

See Also


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

Personal tools