RPR GetMediaItemInfo Value
From CockosWiki
(→See Also) |
(→Examples) |
||
(7 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
{{API_Doc_Header}} | {{API_Doc_Header}} | ||
=GetMediaItemInfo_Value()= | =GetMediaItemInfo_Value()= | ||
- | double GetMediaItemInfo_Value(MediaItem* item, const char* parmname) | + | '''double GetMediaItemInfo_Value(MediaItem* item, const char* parmname)''' |
Gets a named parameter from a specifed media item. All of these parameters are numeric. | Gets a named parameter from a specifed media item. All of these parameters are numeric. | ||
- | + | *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=beatsosonly | |
- | + | *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 : char * fadein shape, 0=linear, ... | |
- | + | *C_FADEOUTSHAPE : char * 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== | ==Parameters== | ||
Line 41: | Line 39: | ||
==Returns== | ==Returns== | ||
- | double - the value of the requested parameter | + | An array, containing |
+ | double - the value of the requested parameter | ||
+ | MediaItem* item, | ||
+ | const char* parmname | ||
==Examples== | ==Examples== | ||
+ | ===C++=== | ||
+ | <source lang=cpp> | ||
+ | </source> | ||
===Perl=== | ===Perl=== | ||
- | < | + | <source lang=perl> |
# | # | ||
# GetMediaItemInfo_Value.pl | # GetMediaItemInfo_Value.pl | ||
Line 105: | Line 109: | ||
RPR_ShowConsoleMsg("F_FREEMODE_Y = $F_FREEMODE_Y\n"); | RPR_ShowConsoleMsg("F_FREEMODE_Y = $F_FREEMODE_Y\n"); | ||
RPR_ShowConsoleMsg("F_FREEMODE_H = $F_FREEMODE_H\n"); | RPR_ShowConsoleMsg("F_FREEMODE_H = $F_FREEMODE_H\n"); | ||
- | </ | + | </source> |
+ | |||
===Python=== | ===Python=== | ||
- | < | + | <source lang=python> |
- | </ | + | # clean_take_names.py |
+ | # use at your own risk etc etc | ||
+ | |||
+ | # Modify these to suit your needs | ||
+ | suffix_list = [".aif", ".aiff", ".bwf", ".flac", ".kar", ".mid", ".mp2", ".mp3", ".ogg", ".wav", ".w64"] | ||
+ | prefix_list = ["*"] | ||
+ | clean_white_space = True | ||
+ | Verbose = True | ||
+ | |||
+ | def clean_name(name, check_list, suffix = True): | ||
+ | New_Name = "" | ||
+ | lower_name = name.lower() # handle all cases | ||
+ | for item in check_list: | ||
+ | if suffix: | ||
+ | if lower_name.endswith(item): | ||
+ | New_Name = name[:-len(item)] | ||
+ | return (True, New_Name) | ||
+ | else: | ||
+ | if lower_name.startswith(item): | ||
+ | New_Name = name[len(item):] | ||
+ | return (True, New_Name) | ||
+ | return (False, name) | ||
+ | |||
+ | # Get number of media items in current project | ||
+ | Item_Count = RPR_CountMediaItems(0) | ||
+ | # Scan each item in project | ||
+ | Item_Index = 0 | ||
+ | Found = 0 | ||
+ | if Verbose: | ||
+ | RPR_ShowConsoleMsg("Checking {0} item(s)\n".format(Item_Count)) | ||
+ | |||
+ | while Item_Index < Item_Count: ############################################### | ||
+ | Item_ID = RPR_GetMediaItem(0, Item_Index) | ||
+ | Current_Take = RPR_GetMediaItemInfo_Value(Item_ID, "I_CURTAKE") # Get active take index for current item | ||
+ | Take_ID = RPR_GetMediaItemTake(Item_ID, int(Current_Take)); | ||
+ | Take_Name = RPR_GetSetMediaItemTakeInfo_String(Take_ID, "P_NAME", "", 0)[3] # Get active take name | ||
+ | Old_Name = Take_Name | ||
+ | (removed_suffix, Take_Name) = clean_name(Take_Name, suffix_list, suffix = True) | ||
+ | (removed_prefix, Take_Name) = clean_name(Take_Name, prefix_list, suffix = False) | ||
+ | removed_white_space = False | ||
+ | if clean_white_space: | ||
+ | New_Name = Take_Name.strip() | ||
+ | if len(New_Name) != len(Take_Name): | ||
+ | Take_Name = New_Name | ||
+ | removed_white_space = True | ||
+ | |||
+ | if removed_suffix or removed_prefix or removed_white_space: # Rename active take if changed | ||
+ | Found = Found + 1 | ||
+ | RPR_GetSetMediaItemTakeInfo_String(Take_ID, "P_NAME", Take_Name, 1) | ||
+ | if Verbose: | ||
+ | Msg = "Item {0} of {1}: Converted '{2}' to '{3}'\n".format(Item_Index + 1, Item_Count, Old_Name, Take_Name) | ||
+ | RPR_ShowConsoleMsg(Msg) | ||
+ | Item_Index = Item_Index + 1; | ||
+ | |||
+ | if Verbose: | ||
+ | RPR_ShowConsoleMsg(str(Found) + " item(s) cleaned\n") | ||
+ | </source> | ||
+ | |||
==See Also== | ==See Also== | ||
- | + | {{SeeAlso_item}} | |
- | + | ||
- | + | ''(Section automatically generated, edits may be overwritten.)'' | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
==Stuff== | ==Stuff== |
Latest revision as of 20:31, 28 January 2010
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetMediaItemInfo Value
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetMediaItemInfo Value
Contents |
GetMediaItemInfo_Value()
double GetMediaItemInfo_Value(MediaItem* item, const char* parmname)
Gets a named parameter from a specifed media item. All of these parameters are numeric.
- 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=beatsosonly
- 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 : char * fadein shape, 0=linear, ...
- C_FADEOUTSHAPE : char * 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
Parameter name | Type | Description |
---|---|---|
MediaItem* | item | the specified item |
const char* | parmname | the named parameter |
Returns
An array, containing double - the value of the requested parameter MediaItem* item, const char* parmname
Examples
C++
Perl
# # GetMediaItemInfo_Value.pl # use strict; use warnings; use constant CURR_PROJ => 0; use constant FIRST_SEL_ITEM => 0; # first catch your Media Item my $it = RPR_GetSelectedMediaItem(CURR_PROJ,FIRST_SEL_ITEM); my $B_MUTE = RPR_GetMediaItemInfo_Value($it,'B_MUTE'); my $B_LOOPSRC = RPR_GetMediaItemInfo_Value($it,'B_LOOPSRC'); my $B_ALLTAKESPLAY = RPR_GetMediaItemInfo_Value($it,'B_ALLTAKESPLAY'); my $B_UISEL = RPR_GetMediaItemInfo_Value($it,'B_UISEL'); my $C_BEATATTACHMODE = RPR_GetMediaItemInfo_Value($it,'C_BEATATTACHMODE'); my $C_LOCK = RPR_GetMediaItemInfo_Value($it,'C_LOCK'); my $D_VOL = RPR_GetMediaItemInfo_Value($it,'D_VOL'); my $D_POSITION = RPR_GetMediaItemInfo_Value($it,'D_POSITION'); my $D_LENGTH = RPR_GetMediaItemInfo_Value($it,'D_LENGTH'); my $D_SNAPOFFSET = RPR_GetMediaItemInfo_Value($it,'D_SNAPOFFSET'); my $D_FADEINLEN = RPR_GetMediaItemInfo_Value($it,'D_FADEINLEN'); my $D_FADEOUTLEN = RPR_GetMediaItemInfo_Value($it,'D_FADEOUTLEN'); my $D_FADEINLEN_AUTO = RPR_GetMediaItemInfo_Value($it,'D_FADEINLEN_AUTO'); my $D_FADEOUTLEN_AUTO = RPR_GetMediaItemInfo_Value($it,'D_FADEOUTLEN_AUTO'); my $C_FADEINSHAPE = RPR_GetMediaItemInfo_Value($it,'C_FADEINSHAPE'); my $C_FADEOUTSHAPE = RPR_GetMediaItemInfo_Value($it,'C_FADEOUTSHAPE'); my $I_GROUPID = RPR_GetMediaItemInfo_Value($it,'I_GROUPID'); my $I_LASTY = RPR_GetMediaItemInfo_Value($it,'I_LASTY'); my $I_LASTH = RPR_GetMediaItemInfo_Value($it,'I_LASTH'); my $I_CUSTOMCOLOR = RPR_GetMediaItemInfo_Value($it,'I_CUSTOMCOLOR'); my $I_CURTAKE = RPR_GetMediaItemInfo_Value($it,'I_CURTAKE'); my $F_FREEMODE_Y = RPR_GetMediaItemInfo_Value($it,'F_FREEMODE_Y'); my $F_FREEMODE_H = RPR_GetMediaItemInfo_Value($it,'F_FREEMODE_H'); RPR_ShowConsoleMsg("B_MUTE = $B_MUTE\n"); RPR_ShowConsoleMsg("B_LOOPSRC = $B_LOOPSRC\n"); RPR_ShowConsoleMsg("B_ALLTAKESPLAY = $B_ALLTAKESPLAY\n"); RPR_ShowConsoleMsg("B_UISEL = $B_UISEL\n"); RPR_ShowConsoleMsg("C_BEATATTACHMODE = $C_BEATATTACHMODE\n"); RPR_ShowConsoleMsg("C_LOCK = $C_LOCK\n"); RPR_ShowConsoleMsg("D_VOL = $D_VOL\n"); RPR_ShowConsoleMsg("D_POSITION = $D_POSITION\n"); RPR_ShowConsoleMsg("D_LENGTH = $D_LENGTH\n"); RPR_ShowConsoleMsg("D_SNAPOFFSET = $D_SNAPOFFSET\n"); RPR_ShowConsoleMsg("D_FADEINLEN = $D_FADEINLEN\n"); RPR_ShowConsoleMsg("D_FADEOUTLEN = $D_FADEOUTLEN\n"); RPR_ShowConsoleMsg("D_FADEINLEN_AUTO = $D_FADEINLEN_AUTO\n"); RPR_ShowConsoleMsg("D_FADEOUTLEN_AUTO = $D_FADEOUTLEN_AUTO\n"); RPR_ShowConsoleMsg("C_FADEINSHAPE = $C_FADEINSHAPE\n"); RPR_ShowConsoleMsg("C_FADEOUTSHAPE = $C_FADEOUTSHAPE\n"); RPR_ShowConsoleMsg("I_GROUPID = $I_GROUPID\n"); RPR_ShowConsoleMsg("I_LASTY = $I_LASTY\n"); RPR_ShowConsoleMsg("I_LASTH = $I_LASTH\n"); RPR_ShowConsoleMsg("I_CUSTOMCOLOR = $I_CUSTOMCOLOR\n"); RPR_ShowConsoleMsg("I_CURTAKE = $I_CURTAKE\n"); RPR_ShowConsoleMsg("F_FREEMODE_Y = $F_FREEMODE_Y\n"); RPR_ShowConsoleMsg("F_FREEMODE_H = $F_FREEMODE_H\n");
Python
# clean_take_names.py # use at your own risk etc etc # Modify these to suit your needs suffix_list = [".aif", ".aiff", ".bwf", ".flac", ".kar", ".mid", ".mp2", ".mp3", ".ogg", ".wav", ".w64"] prefix_list = ["*"] clean_white_space = True Verbose = True def clean_name(name, check_list, suffix = True): New_Name = "" lower_name = name.lower() # handle all cases for item in check_list: if suffix: if lower_name.endswith(item): New_Name = name[:-len(item)] return (True, New_Name) else: if lower_name.startswith(item): New_Name = name[len(item):] return (True, New_Name) return (False, name) # Get number of media items in current project Item_Count = RPR_CountMediaItems(0) # Scan each item in project Item_Index = 0 Found = 0 if Verbose: RPR_ShowConsoleMsg("Checking {0} item(s)\n".format(Item_Count)) while Item_Index < Item_Count: ############################################### Item_ID = RPR_GetMediaItem(0, Item_Index) Current_Take = RPR_GetMediaItemInfo_Value(Item_ID, "I_CURTAKE") # Get active take index for current item Take_ID = RPR_GetMediaItemTake(Item_ID, int(Current_Take)); Take_Name = RPR_GetSetMediaItemTakeInfo_String(Take_ID, "P_NAME", "", 0)[3] # Get active take name Old_Name = Take_Name (removed_suffix, Take_Name) = clean_name(Take_Name, suffix_list, suffix = True) (removed_prefix, Take_Name) = clean_name(Take_Name, prefix_list, suffix = False) removed_white_space = False if clean_white_space: New_Name = Take_Name.strip() if len(New_Name) != len(Take_Name): Take_Name = New_Name removed_white_space = True if removed_suffix or removed_prefix or removed_white_space: # Rename active take if changed Found = Found + 1 RPR_GetSetMediaItemTakeInfo_String(Take_ID, "P_NAME", Take_Name, 1) if Verbose: Msg = "Item {0} of {1}: Converted '{2}' to '{3}'\n".format(Item_Index + 1, Item_Count, Old_Name, Take_Name) RPR_ShowConsoleMsg(Msg) Item_Index = Item_Index + 1; if Verbose: RPR_ShowConsoleMsg(str(Found) + " item(s) cleaned\n")
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,
(Section automatically generated, edits may be overwritten.)
Stuff
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetMediaItemInfo Value
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetMediaItemInfo Value