RPR GetSetItemState
From CockosWiki
(→GetSetItemState()) |
|||
Line 1: | Line 1: | ||
{{API_Doc_Header}} | {{API_Doc_Header}} | ||
=GetSetItemState()= | =GetSetItemState()= | ||
+ | '''bool GetSetItemState(MediaItem* item, char* str, int maxlen)''' | ||
+ | |||
+ | This function gets or sets the state of a media item as an xml-ish rpp chunk. | ||
+ | |||
+ | When calling the function, if you set str="" it will return the current state of the item in the corresponding | ||
+ | the returned state string is limited to maxlen characters, though there is an upper limit (currently 16K) on maxlen. | ||
+ | supply str as an xml/rpp string to set the object state. | ||
+ | returns true on success. | ||
+ | |||
+ | GetSetItemState() can be used to examine the state of the item - the item's properties; it returns a string in its return array. Below is the item state of a short MIDI item. | ||
+ | <pre> | ||
+ | <ITEM | ||
+ | POSITION 12.00000000000000 | ||
+ | SNAPOFFS 0.00000000000000 | ||
+ | LENGTH 8.81585503963759 | ||
+ | LOOP 1 | ||
+ | ALLTAKES 0 | ||
+ | SEL 1 | ||
+ | FADEIN 1 0.000000 0.000000 | ||
+ | FADEOUT 1 0.000000 0.000000 | ||
+ | MUTE 0 | ||
+ | IGUID {967EE770-4144-472A-89D6-B72BB910A916} | ||
+ | NAME "lalala untitled MIDI item" | ||
+ | VOLPAN 1.000000 0.000000 1.000000 -1.000000 | ||
+ | SOFFS 0.00000000000000 0.00000000000000 | ||
+ | PLAYRATE 1.00000000000000 1 0.00000000000000 -65536 | ||
+ | CHANMODE 0 | ||
+ | GUID {9C93A652-09A2-4A46-9E1B-EF83EB7CED29} | ||
+ | <SOURCE MIDI | ||
+ | HASDATA 1 960 QN | ||
+ | e 300 90 2b 60 | ||
+ | e 60 80 2b 00 | ||
+ | E 120 90 27 60 | ||
+ | E 60 80 27 00 | ||
+ | E 1200 90 2c 60 | ||
+ | E 60 80 2c 00 | ||
+ | E 60 90 29 60 | ||
+ | E 60 80 29 00 | ||
+ | E 360 90 2a 60 | ||
+ | E 60 80 2a 00 | ||
+ | E 120 90 26 60 | ||
+ | E 60 80 26 00 | ||
+ | E 540 90 2a 60 | ||
+ | E 60 80 2a 00 | ||
+ | E 120 90 2e 60 | ||
+ | E 60 80 2e 00 | ||
+ | E 540 b0 7b 00 | ||
+ | GUID {9DAB52C8-6257-4A4E-9E60-323514C0DB9B} | ||
+ | IGNTEMPO 0 120.00000000 4 4 | ||
+ | VELLANE 128 97 0 | ||
+ | BANKPROGRAMFILE "C:\Program Files\REAPER/Data/GM.reabank" | ||
+ | CFGEDITVIEW 3787.833051 0.178906 0 48 0 0 0 | ||
+ | CFGEDIT 1 1 0 1 1 16 1 1 1 1 1 0.06250000 -4 -4 1404 1001 0 2 0 0 0.00000000 0 0 | ||
+ | EVTFILTER 0 -1 -1 -1 -1 0 1 | ||
+ | > | ||
+ | > | ||
+ | </pre> | ||
+ | |||
+ | You can then use the same function to set one or more properties of that item. This is shown in the Perl example below. | ||
==Parameters== | ==Parameters== | ||
+ | MediaItem* item, A pointer to a valid MediaItem, as returned by GetSelectedMediaItem() | ||
+ | char* str, str="" to get the state returned in str, str as an xml/rpp string to set the object state. | ||
+ | int maxlen, maximum number of characters that will be returned, limited to 16k | ||
==Returns== | ==Returns== | ||
+ | An Array/List | ||
+ | bool, true on success, false on failure | ||
+ | MediaItem* item, unchanged | ||
+ | char* str, the current state of the item, possibly after a Set operation | ||
+ | int maxlen, unchanged | ||
==Examples== | ==Examples== | ||
===Perl=== | ===Perl=== | ||
Line 13: | Line 80: | ||
# | # | ||
+ | use strict; | ||
+ | use warnings; | ||
use constant CURR_PROJ => 0; | use constant CURR_PROJ => 0; |
Revision as of 12:41, 7 November 2009
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetSetItemState
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetSetItemState
Contents |
GetSetItemState()
bool GetSetItemState(MediaItem* item, char* str, int maxlen)
This function gets or sets the state of a media item as an xml-ish rpp chunk.
When calling the function, if you set str="" it will return the current state of the item in the corresponding the returned state string is limited to maxlen characters, though there is an upper limit (currently 16K) on maxlen. supply str as an xml/rpp string to set the object state. returns true on success.
GetSetItemState() can be used to examine the state of the item - the item's properties; it returns a string in its return array. Below is the item state of a short MIDI item.
<ITEM POSITION 12.00000000000000 SNAPOFFS 0.00000000000000 LENGTH 8.81585503963759 LOOP 1 ALLTAKES 0 SEL 1 FADEIN 1 0.000000 0.000000 FADEOUT 1 0.000000 0.000000 MUTE 0 IGUID {967EE770-4144-472A-89D6-B72BB910A916} NAME "lalala untitled MIDI item" VOLPAN 1.000000 0.000000 1.000000 -1.000000 SOFFS 0.00000000000000 0.00000000000000 PLAYRATE 1.00000000000000 1 0.00000000000000 -65536 CHANMODE 0 GUID {9C93A652-09A2-4A46-9E1B-EF83EB7CED29} <SOURCE MIDI HASDATA 1 960 QN e 300 90 2b 60 e 60 80 2b 00 E 120 90 27 60 E 60 80 27 00 E 1200 90 2c 60 E 60 80 2c 00 E 60 90 29 60 E 60 80 29 00 E 360 90 2a 60 E 60 80 2a 00 E 120 90 26 60 E 60 80 26 00 E 540 90 2a 60 E 60 80 2a 00 E 120 90 2e 60 E 60 80 2e 00 E 540 b0 7b 00 GUID {9DAB52C8-6257-4A4E-9E60-323514C0DB9B} IGNTEMPO 0 120.00000000 4 4 VELLANE 128 97 0 BANKPROGRAMFILE "C:\Program Files\REAPER/Data/GM.reabank" CFGEDITVIEW 3787.833051 0.178906 0 48 0 0 0 CFGEDIT 1 1 0 1 1 16 1 1 1 1 1 0.06250000 -4 -4 1404 1001 0 2 0 0 0.00000000 0 0 EVTFILTER 0 -1 -1 -1 -1 0 1 > >
You can then use the same function to set one or more properties of that item. This is shown in the Perl example below.
Parameters
MediaItem* item, A pointer to a valid MediaItem, as returned by GetSelectedMediaItem() char* str, str="" to get the state returned in str, str as an xml/rpp string to set the object state. int maxlen, maximum number of characters that will be returned, limited to 16k
Returns
An Array/List bool, true on success, false on failure MediaItem* item, unchanged char* str, the current state of the item, possibly after a Set operation int maxlen, unchanged
Examples
Perl
# # GetSetItemState.pl # # "Get" and "Set" example # use strict; use warnings; use constant CURR_PROJ => 0; my ($bool, $it, $chunk, $maxlen); my $length = -1; my $result = "fail"; # Get the first selected item in the current project $it = RPR_GetSelectedMediaItem(CURR_PROJ, 0); # set-up for call to GetSetItemState $chunk=""; # Get, not Set $maxlen=2048; # max num of chars to return # Get the ItemState ($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen); $result = "pass" if $bool; RPR_ShowConsoleMsg("GetSetItemState reports $result\n$chunk\n"); RPR_ShowConsoleMsg("LENGTH = $length\n"); # Pick out the LENGTH property $chunk =~ /LENGTH\s+(.*)\n/; $length = $1; # Display the current LENGTH property RPR_ShowConsoleMsg("LENGTH = $length\n"); # Add one second to the LENGTH property $length++; $chunk =~ s/LENGTH.*\n/LENGTH $length\n/; # Set the ItemState $result = "fail"; ($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen); $result = "pass" if $bool; RPR_ShowConsoleMsg("AFTER SET: GetSetItemState reports $result\n$chunk\n");
Python
See Also
Media Item: AddMediaItemToTrack, CountMediaItems, CountSelectedMediaItems, CountTrackMediaItems, DeleteTrackMediaItem, GetMediaItemInfo_Value, GetMediaItemNumTakes, GetMediaItemTake, GetMediaItemTake_Item, GetMediaItemTake_Source, GetMediaItemTake_Track, GetMediaItemTakeInfo_Value, GetSelectedMediaItem, GetSetMediaItemTakeInfo_String, GetTrackMediaItem, GetTrackNumMediaItems, MoveMediaItemToTrack, SetMediaItemInfo_Value, SetMediaItemTakeInfo_Value, SplitMediaItem
Stuff
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetSetItemState
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetSetItemState