Old 07-27-2008, 08:19 PM   #1
drew
Mobile
 
drew's Avatar
 
Join Date: Jan 2006
Location: London & São Paulo. Hardcore commercial REAPERite
Posts: 1,669
Default Code snippets for uber-n00bs

Guessing I'm not alone here... I'd sure appreciate the odd code snippet here & there.

Things like:
cycling through all project media on all tracks and reading the takes & items, so I can make lists of names/durations of items etc
moving selected items
moving cursor backwards & forwards according to project tempo.

Thanks!

drew
__________________
Proudly using REAPER exclusively for...
* Media and event music composition & production, sound design + auto-processing at Qsonics.com
* Broadcast branding, promos, education & training and narration voice-overs at DrewWhite.com
drew is offline   Reply With Quote
Old 07-27-2008, 09:29 PM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I haven't checked if this actually works... But something along these lines would get you the project's items' lengths and active take names...

Code:
void DoDumpItemDurationsandActiveTakeNames()
{
	
	MediaTrack* TheTrack;
	MediaItem* CurItem;
	MediaItem_Take* CurTake;
	int numItems=0;
	char TempString[500];
	for (int i=0;i<GetNumTracks();i++)
	{
		TheTrack= CSurf_TrackFromID(i+1,FALSE); // we get the pointer/handle to track using the CSurf API, i+1 comes from 0 being the master track, we don't expect items there
		numItems=GetTrackNumMediaItems(TheTrack);
		for (int j=0;j<numItems;j++)
		{
			CurItem = GetTrackMediaItem(TheTrack,j);
			if (GetMediaItemNumTakes(CurItem)>0) // empty items don't have any takes, so following code could maybe  crash without checking there are takes
			{
					CurTake=GetMediaItemTake(CurItem,-1); // -1 gets the active take
					double ItemLength=*(double*)GetSetMediaItemInfo(CurItem,"D_LENGTH",NULL);
					char *TakeName=(char*)GetSetMediaItemTakeInfo(CurTake,"P_NAME",NULL);
					// format some kind of text output 
					sprintf(TempString,"Track %d item number %d active take has name %s and length %f",i+1,j+1,TakeName,ItemLength);
					// we are super lazy and just output to the debug viewer
					OutputDebugString(TempString);
			}
				
		} 


	}
}
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 08-06-2008, 10:44 AM   #3
drew
Mobile
 
drew's Avatar
 
Join Date: Jan 2006
Location: London & São Paulo. Hardcore commercial REAPERite
Posts: 1,669
Default

Finally tried this - and success!!! ThanX Xenakios!
__________________
Proudly using REAPER exclusively for...
* Media and event music composition & production, sound design + auto-processing at Qsonics.com
* Broadcast branding, promos, education & training and narration voice-overs at DrewWhite.com
drew is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.