Difference between revisions of "Scripting Syntax"

From Audacity Wiki
Jump to: navigation, search
(Updates.)
(Obsolete content now.)
Line 1: Line 1:
 
* See also [https://manual.audacityteam.org/man/scripting.html scripting] in the manual.
 
* See also [https://manual.audacityteam.org/man/scripting.html scripting] in the manual.
  
 +
{{ednote|1=
 +
* '''James:''' The content of this page has now been corrected, updated and transferred to the alphamanual. 
 +
* I've implemented missing/incomplete commands.
 +
* I will probably remove the content here, and just use it for new features as they are developed}}
  
{{alert|This page is a proposal for extended scripting syntax that is not fully implemented.  The commands actually supported are documented in the manual.}}
+
 
 +
{{alert|This page is an obsolete proposal for extended scripting syntax.  The commands have been reworked and implemented and are documented in the manual.}}
 
{{alert|When commands return a syntax error, the results may subsequently lag behind the requests, which can get confusing.}}
 
{{alert|When commands return a syntax error, the results may subsequently lag behind the requests, which can get confusing.}}
  

Revision as of 22:59, 13 January 2018

* James: The content of this page has now been corrected, updated and transferred to the alphamanual.
  • I've implemented missing/incomplete commands.
  • I will probably remove the content here, and just use it for new features as they are developed


Warning icon This page is an obsolete proposal for extended scripting syntax. The commands have been reworked and implemented and are documented in the manual.
Warning icon When commands return a syntax error, the results may subsequently lag behind the requests, which can get confusing.

Overview

This page contains information about an expanded Syntax for GetTrackInfo and SetTrackInfo for the scripting feature in Audacity.

GetTrackInfo and SetTrackInfo, Expanded Syntax:

GetTrackInfo:

Returns information about one track.

In each of the following commands the value is returned if the setting exists. Not clear what is returned if the setting does not.

Parameters:

Type: Info to get. One of:
  • Name
  • StartTime
  • EndTime
  • Pan
  • Gain
  • Solo
  • Mute
  • Selected
  • Linked
  • Focused
TrackIndex: The number of the track to get info from

Name returns a string, StartTime, EndTime, Pan and gain return decimal values, the others boolean values.

Examples:

Send Receive
GetTrackInfo: Type=Selected TrackIndex=2 false
GetTrackInfo: Type=Gain TrackIndex=3 0.5


SetTrackInfo:

Warning icon Type=Name is implemented and documented, but not these types yet.


Sets information for one track.

Parameters:

Type: Info to set. One of:
  • Selected
  • Solo
  • Mute

N.B. 'Type' is not yet supported.

TrackIndex: The number of the track to set.

0 is the top audio track.

Setting: The value to set. One of
  • true, 1 or yes (all three are treated the same)
  • false, 0 or no (all three are treated the same)

Solo and Mute only work on Audio Tracks. On tracks other than Audio Tracks, nothing is changed, there is no check, nor is there an error message, there is simply nothing done.

Examples:

Send Receive
SetTrackInfo: Type=Selected TrackIndex=2 Setting=true SetTrackInfo finished: OK
SetTrackInfo: Type=Solo TrackIndex=3 Setting=false SetTrackInfo finished: OK

If the track index is out of range, or otherwise invalid, the following occurs:

Send Receive
SetTrackInfo: Type=Selected TrackIndex=2 Setting=true SetTrackInfo: Failed! Invalid TrackIndex


New Commands GetProjectInfo and SetProjectInfo:

Returns the chosen information about the tracks in the current project.

Parameters:

SelectedTracks: An integer (default: 0) identifying the track
Type: Info to get. One of:
  • Name
  • NumberOfTracks
  • SelectedTracks
  • SoloTracks
  • MuteTracks
  • FocusedTrackID

(default: Name)

Name is the filename.


Examples:

Send Receive
GetProjectInfo: Type=SoloTracks 001010000
GetProjectInfo: Type=FocusedTrackID 5
GetProjectInfo: Type=NumberOfTracks 9


SetProjectInfo:

Allows state of one parameter type on all of a project's tracks to be set.

The TrackSet parameter represents the setting for tracks numbering left to right, starting with 1, as in 12345...

The characters in the string represent enabling (1) disabling (0), or leaving alone (x) the parameter indicated by Type=ParamTracks for each channel.

  • '1' means that parameter is asserted in that track, for example, for MuteTracks, a 1 will mute that track.
  • '0' de-asserts it, for example for MuteTracks a 0 unmutes that track.
  • 'x' will leave the indicated track in its current state.


The string length is not required to match the number of channels in a project. If the string of 1s and 0s is shorter than the number of channels, then channels beyond the “reach” of the TrackSet string are untouched.

If the TrackSet string is longer than the number of channels in the project, then those characters in the string beyond the last track in the project are ignored.

No checking done for any mismatch between the TrackSet string length and the actual number of tracks in a session project. We could decide to return a condition flag indicating the mismatch as the TrackSet string being either too long or too short, if this is deemed important.


Parameters:

Type: Info to set. One of:
  • SelectedTracks
  • SoloTracks
  • MuteTracks
SelectedTracks: A string of characters: {1,0,x} indicating Assert, Deassert or leave alone, respectively


Examples:

Send Receive
SetProjectInfo: Type=SoloTracks TrackSet=10010xxx1 SetProjectInfo finished: OK
SetProjectInfo: Type=MuteTracks TrackSet=101000xxx SetProjectInfo finished: OK