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. There are still a few question marks (gaps) in the definition; please fill in any gaps you can.

Comments, empty lines and indentation are for illustration only.

For the sake of formatting, decimal precision of floats in AUXRECV has been truncated from fourteen places to two, item and envelope definitions have been removed, the JS plugin definition has been truncated and the shorthand "int (bool)" has been used to denote "0 = False, 1 = True"

<TRACK                                                          // Start of Track definition
    NAME "vocals - stem - stem"                                 // Track name
    PEAKCOL 16576                                               // Peak colour (items and takes override?)
    BEAT -1                                                     // Track timebase (-1 = proj default)
    AUTOMODE 0                                                  // Automation mode
                                                                //   0=Trim/Read, 1=Read, 2=Touch, 3=Write, 4=Latch
    VOLPAN 0.35949985591839 0.00000000000000 -1.00000000000000  // Volume/Pan
                                                                //  field 1, float, track volume
                                                                //  field 2, float, track pan
                                                                //  field 3, float, track pan law
    MUTESOLO 0 0 0                                              // Mute/solo
                                                                //  field 1, int (bool), mute
                                                                //  field 2, int, solo, 0=no solo, 1=solo, 2=solo-in-place
                                                                //  field 3, int (bool), solo defeat
    IPHASE 0                                                    // Invert phase, int (bool)
    ISBUS 0 0                                                   // ??, Unknown but related to folder tracks 
                                                                //   1 1 = is folder, 2 -1 = is folder end, 0 0 for others
    BUSCOMP 0 0                                                 // Collapse folder (bus compact?)
                                                                //  field 1, int, 0=full, 1=med, 2=small
                                                                //  field 2, int, ??
    SHOWINMIX 1 0.666700 0.500000 1 0.500000 -1 -1 -1           // Show In Mixer
                                                                //  field 1, int (bool), show in mixer
                                                                //  field 2, float, ??
                                                                //  field 3, float, ??
                                                                //  field 4, int (bool), show in track list
                                                                //  field 5, float, ??
                                                                //  field 6, int, ??
                                                                //  field 7, int, ??
                                                                //  field 8, int, ??
    FREEMODE 0                                                  // Free Item Positioning Mode, int (bool)
    REC 0 0 0 0 0 0 0                                           // Record settings
                                                                //  field 1, int (bool), armed
                                                                //  field 2. int, input,
                                                                //    0=mono left, 1=mono right, 1024=stereo left+right...
                                                                //    device + channel(s) coded via unknown bitwise method
                                                                //  field 3. int, monitor, 0=off, 1=on, 2=auto
                                                                //  field 4. int, record mode,
                                                                //   0=input, 1=output (stereo), 2=disable(monitor),
                                                                //   3=output (stereo, latency comp), 4=Output (MIDI),
                                                                //   5=output (mono), 6=output (mono, latency comp),
                                                                //   7=MIDI overdub, 8=MIDI replace, 9=MIDI touch replace,
                                                                //   10=output (multichannel),
                                                                //   11=output (multichannel, latency comp)
                                                                //  field 5. int (bool), monitor track media while recording
                                                                //  field 6. int (bool), preserve PDC delayed monitoring
                                                                //  field 7. int, record path, 0=primary, 1=secondary, 2=both
    TRACKHEIGHT 0 0                                             // Height in TCP,
                                                                //  field 1, int, height in pixels
                                                                //  field 2, int (bool), folder override (collapsed)
    INQ 0 0 0 0.5000000000 100 0 0 100                          // Input quantize settings
                                                                //  field 1, int (bool), quantize midi
                                                                //  field 2, int, quantize to pos (-1=prev, 0=nearest, 1=next)
                                                                //  field 3, int (bool), quantize note-offs
                                                                //  field 4, float, quantize to (fraction of beat)
                                                                //  field 5, int (%), quantize strength
                                                                //  field 6, int (%), swing strength
                                                                //  field 7, int (%), quantize range min
                                                                //  field 8, int (%), quantize range max
    NCHAN 2                                                     // Number of track channels, int
    <RECCFG 1                                                   // Recording format data. Not present if not changed.
        dmdnbwAAAD8AgAAAAIAAAAAgAAAAAAEAAA==                    //  binary data, leave it alone
    >                                                           //
    FX 1                                                        // FX state, int, 0=bypassed, 1=active
    TRACKID {5619EDC5-E743-4BE8-AE9F-3B3469A111B5}              // REAPER track id, leave it alone
    PERF 0                                                      // Performance options, int (bitwise)
                                                                //  val & 1 = prevent media buffering
                                                                //  val & 2 = prevent anticipative fx
    LAYOUTS "tcp layout name" "mcp layout name"                 // Track layout names. Not present if not changed.
																
                                                                // --- Start of recieve data ---
                                                                //     One for each recieve or not present if no recieves
    AUXRECV 2 1 1.00 0.00 0 0 0 2 0 1.00 80 1                   // First receive
                                                                //  field 1, int, source track index (zero based)
                                                                //  field 2, int, mode
                                                                //   0 = Post Fader (Post Pan), 1 = Pre FX, 3 = Pre Fader (Post FX)
                                                                //  field 3, float, volume
                                                                //  field 4, float, pan
                                                                //  field 5, int (bool), mute
                                                                //  field 6, int (bool), mono sum
                                                                //  field 7, int (bool), invert phase
                                                                //  field 8, int, source audio channels
                                                                //    -1 = none, 0 = 1+2, 1 = 2+3, 2 = 3+4 etc.
                                                                //    probably different if non-standard pairs aren't allowed
                                                                //  field 9, int, dest audio channels (as source but no -1)
                                                                //  field 10, float, panlaw
                                                                //  field 11, int, midi channels
                                                                //    source = val & 0x1F (0=None), dest = floor(val / 32)
                                                                //  field 12, int, automation mode (-1 = use track mode)
																
                                                                // --- Start of envelope definitions for the above recieve
                                                                //     One definition block for each non-empty envelope.
                                                                //     See GetSetEnvelopeState() for full envelope definition.
    <AUXPANENV                                                  //  Start of first recieve envelope
        (definition removed)                                    //   ...
    >                                                           //  End of first recieve envelope
    <AUXMUTEENV                                                 //  Start of second recieve envelope.
        (definition removed)                                    //   ...
    >                                                           //  End of second recieve envelope
	                                                            // --- End of envelopes for first recieve
																
    AUXRECV 3 0 1.00 0.00 0 0 0 0 0 -1.00 0 -1                  // Second track receive settings (as above but no envelopes)
                                                                // --- End of recieve data ---
																
    MIDIOUT -1                                                  // MIDI hardware output settings. int (bitwise)
                                                                //  device = floor(val / 32)
                                                                //    index of device (inc. ignored devices)
                                                                //    -1 for no MIDI hardware output
                                                                //  channel = val & 0x1F
                                                                //    channel number or 0 for 'use original'
                                                                //    val = device * 32 + channel (device 2, ch 4 == 68)
    MAINSEND 1                                                  // Master/parent send, int (bool)
	
                                                                // --- Start of track envelopes ---
                                                                //     One definition block for each non-empty envelope.
                                                                //     See GetSetEnvelopeState() for full envelope definition.
    <VOLENV2                                                    //   First track envelope.
        (definition removed)                                    //   ...
    >                                                           //   End of first track envelope
                                                                // --- End of track envelopes

                                                                // --- Start of FX section ----
    <FXCHAIN                                                    //     Not present if track hasn't got/had FX ---
    WNDRECT 0 42 716 227                                        // FX Window pos, int (top, left, width, height)
    SHOW 0                                                      // Show FX window, int (bool)
    LASTSEL 1                                                   // Index of selected plugin (zero based), int
    DOCKED 0                                                    // FX window is docked, int (bool)
	
                                                                // --- Start of first plugin definition
    BYPASS 0 0                                                  //  Plugin bypass state
                                                                //   field 1, int (bool), bypassed
                                                                //   field 2, int (bool), offline
    <VST "VST: mda RezFilter" "mda RezFilter.dll" 0 ""          //  Start of VST plugin data
                                                                //   field 1, str, default name
                                                                //   field 2, str, filename
                                                                //   field 3, int, ??
                                                                //   field 4, str, display name (default used if empty)
    RmFkbe9e7f4CAAAAAQAAAAAAAAACAAAAAAAAAAIAAAABAAAAAAAAAA==    //  Binary data, leave it alone (variable number of lines)
    AgAAAAAAAAAwAAAAAAAAAAAAEADvvq3eDfCt3sP1qD4zMzM/AAAAPw==    //
    mplZPwAAAAAAAAA/MzMzP83MzD4AAAAAAABAP1Jlc29uYW50IEZpbA==    //  
    dGVyAA==                                                    //
    >                                                           //  End of VST plugin data
    FLOATPOS 0 0 0 0                                            //  Plugin floating window pos, int (top, left, width, height)
    FXID {1191A7FE-F583-477E-8416-D9F0F58226CD}                 //  Plugin id, leave it alone
                                                                //  Start of parameter envelopes for this plugin.
                                                                //   One definition block for each non-empty envelope.
                                                                //   See GetSetEnvelopeState() for full envelope definition.
    <PARMENV 2 0.000000 1.000000 0.500000                       //  Start of first parameter envelope
      (definition removed)                                      //   ...
    >                                                           //  End of first parameter envelope
                                                                //  End of parameter envelopes
    PARM_TCP 4 2 0                                              //  Params visible on TCP/MCP.
                                                                //   List of int indexes separated by spaces.
    WAK 0                                                       //  int, ??
    <COMMENT                                                    //  Start of plugin comment. Not present if no comment.
        Y29tbWVudA==                                            //   Binary data, probably best to leave it alone
    >                                                           //  End of plugin comment
	
                                                                // --- Start of second plugin definition (as above)
    BYPASS 0 0                                                  //  ...
    <JS "Guitar/tremolo" ""                                     //  Start of JS plugin data
                                                                //   field 1, str, filename
                                                                //   field 2, str, display name (filename used if empty)
        4.000000 -6.000000 0.000000 - - - - - - - - - - - -     //   Plugin data, single line, 64 fields of float or '-'
    >                                                           //  End of JS plugin data
    FLOATPOS 0 0 0 0                                            //  ...
    FXID {BE5D3334-6675-4DAD-AFDD-F4489878D82A}                 //  ...
    WAK 0                                                       //  ...
    >                                                           // --- End of FX section
	
                                                                // --- Start of item definitions.
                                                                //     See GetSetItemState() for full definition.
    <ITEM                                                       // First item definition
      (definition removed)                                      //  ...
    >                                                           // End of first item
                                                                // --- End of item definitions

>                                                               // End of Track definition

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 4MB

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