RPR GetSetTrackState

From CockosWiki

Jump to: navigation, search

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

Contents

GetSetTrackState ()

bool GetSetTrackState(MediaTrack* track, char* str, int maxlen)

This function gets or sets the state of a track as an xml-ish rpp chunk.

When calling the function, if you set str="" it will return the current state of the track in the corresponding return array/list element. The returned state string is limited to maxlen characters, though there is an upper limit (currently 1MB) on maxlen. Supply str as an xml/rpp string to set the object state.

GetSetTrackState() can be used to examine the state of the track - the track's properties; it returns the string in its return array.

Track State Chunk Defintions

A Track State Chunk is documented below. Note that a Track State chunk contains the Items for that track. Note also that there're lots of question marks (gaps) in the definition; please fill in any gaps you can.

The comments are for illustration only, you can't really have comments in a Track State Chunk

<TRACK                                                          // Start of Track section
    NAME "vocals - stem - stem"                                 // name of the track
    PEAKCOL 16576                                               // ??
    BEAT -1                                                     // ??
    AUTOMODE 0                                                  // Automation mode ??
    VOLPAN 0.35949985591839 0.00000000000000 -1.00000000000000  // Volume & Pan Settings ??
    MUTESOLO 0 0                                                //  field 1, int, 0=false, 1=true (muted)
                                                                //  field 1, int, 0=false, 1=true (soloed)
    IPHASE 0                                                    //  invert phase 0=false, 1=true
    ISBUS 0 0                                                   // ??
    BUSCOMP 0                                                   // ??
    SHOWINMIX 1 0.666700 0.500000 1 0.500000                    // Show In Mixer
                                                                //  field 1, int, 0=false (hide), 1=true (show)
                                                                //  field 2, float, ??
                                                                //  field 3, float, ??
                                                                //  field 4, int, ??
                                                                //  field 5, float, ??
    FREEMODE 0                                                  // Free Item Positioning Mode, 0=false, 1=true
    REC 0 0 1 0 0 0                                             // record armed ??
    TRACKHEIGHT 0 0                                             // Height in TCP, 0=default track height, non-zero value in pixels ??
    INQ 0 0 0 0.5000000000 100 0 0 100                          // ??
    NCHAN 2                                                     // ??
    FX 1                                                        // ??
    TRACKID {5619EDC5-E743-4BE8-AE9F-3B3469A111B5}              // supplied by REAPER - ignore
    PERF 0                                                      // ??
    MIDIOUT -1                                                  // ??
    MAINSEND 1                                                  // ??
    <ITEM                                                       // Item section, documented in GetSetItemState
    >                                                           // End of Item section
>                                                               // End of Track section

Parameters

MediaTrack* item,  A pointer to a valid MediaTrack, as returned by GetSelectedMediaTrack()
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 1MB

Returns

An array, containing
 bool,             true on success, false on failure
 MediaTrack* item, unchanged
 char* str,        the current state of the item, possibly after a Set operation
 int maxlen,       unchanged

Examples

C++

 


Perl

#
# GetSetTrackState.pl
#
# example
#
 
use strict;
use warnings;
 
use constant CURR_PROJ => 0;
 
my ($bool, $tr, $chunk, $maxlen);
 
my $freemode = -1;
my $result = "fail";
 
# Get the first selected item in the current project
$tr = RPR_GetSelectedTrack(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, $tr, $chunk, $maxlen) = RPR_GetSetTrackState($tr, $chunk, $maxlen);
$result = "pass" if $bool;
RPR_ShowConsoleMsg("GetSetTrackState reports $result\n$chunk\n");
 
RPR_ShowConsoleMsg("FREEMODE = $freemode\n");
# Pick out the FREEMODE property
$chunk =~ /FREEMODE\s+(.*)\n/;
$freemode = $1;
# Display the current FREEMODE property
RPR_ShowConsoleMsg("FREEMODE = $freemode\n");
 
# set FREEMODE property to 1
$freemode = "1";
$chunk =~ s/FREEMODE.*\n/FREEMODE $freemode\n/;
 
# Set the ItemState
$result = "fail";
($bool, $tr, $chunk, $maxlen) = RPR_GetSetTrackState($tr, $chunk, $maxlen);
$result = "pass" if $bool;
RPR_ShowConsoleMsg("AFTER SET: GetSetTrackState reports $result\n$chunk\n");


Python

 

See Also

get set state: GetSetEnvelopeState, GetSetItemState, GetSetTrackState

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 GetSetTrackState
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetSetTrackState

Personal tools