1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 07:40:23 +02:00

Scripts in Piped-Work

- New docimages script for the tracks.
- Added new option in screenshots to capture ruler as well as track.
- Typo fix (focussed)
This commit is contained in:
James Crook 2018-02-10 19:50:30 +00:00 committed by Paul Licameli
parent 1f605ccfc8
commit 24e8bbc623
7 changed files with 146 additions and 13 deletions

View File

@ -0,0 +1,119 @@
# docimages_tracks.py
# Sends commands to get images for the manual.
# Images for https://alphamanual.audacityteam.org/man/Audio_Tracks
# Make sure Audacity is running first and that mod-script-pipe is enabled
# before running this script.
import os
import sys
if( sys.platform == 'win32' ):
print( "pipe-test.py, running on windows" )
toname = '\\\\.\\pipe\\ToSrvPipe'
fromname = '\\\\.\\pipe\\FromSrvPipe'
EOL = '\r\n\0'
else:
print( "pipe-test.py, running on linux or mac" )
toname = '/tmp/audacity_script_pipe.to.' + str(os.getuid())
fromname = '/tmp/audacity_script_pipe.from.' + str(os.getuid())
EOL = '\n'
print( "Write to \"" + toname +"\"" )
if not os.path.exists( toname ) :
print( " ..does not exist. Ensure Audacity is running with mod-script-pipe." )
sys.exit();
print( "Read from \"" + fromname +"\"")
if not os.path.exists( fromname ) :
print( " ..does not exist. Ensure Audacity is running with mod-script-pipe." )
sys.exit();
print( "-- Both pipes exist. Good." )
tofile = open( toname, 'wt+' )
print( "-- File to write to has been opened" )
fromfile = open( fromname, 'rt')
print( "-- File to read from has now been opened too\r\n" )
def sendCommand( command ) :
print( "Send: >>> "+command )
tofile.write( command + EOL )
tofile.flush()
def getResponse() :
result = ''
line = ''
while line != '\n' :
result += line
line = fromfile.readline()
#print(" I read line:["+line+"]")
return result
def doCommand( command ) :
sendCommand( command )
response = getResponse()
print( "Rcvd: <<< " + response )
return response
def do( command ) :
doCommand( command )
def quickTest() :
do( 'Help: Command=Help' )
do( 'Help: Command="SetTrackInfo"' )
do( 'SetPreference: Name=GUI/Theme Value=light Reload=false' )
def setup() :
global path
path = '\"C:/Users/James Crook/\"'
do( 'SetProject: X=10 Y=10 Width=1000 Height=800' )
def makeMonoTrack() :
do( 'SelectTime: StartTime=0 EndTime=30' )
do( 'Chirp: StartAmp=0.5' )
do( 'SelectTracks' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'SetTrack: TrackIndex=0 Name="Foxy Lady"')
def makeStereoTrack() :
do( 'SetProject: X=10 Y=10 Width=1000 Height=800' )
do( 'SelectTime: StartTime=0 EndTime=30' )
do( 'NewStereoTrack' )
do( 'Chirp: StartAmp=0.5' )
# do( 'SelectTracks: FirstTrack=0 LastTrack=1' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'SetTrack: TrackIndex=0 Name="Voodoo Children IN STEREO"')
def closeTrack( ):
do( 'SetTrack: TrackIndex=0 Focused=True' )
do( 'TrackClose' )
def image1() :
global path
makeMonoTrack()
do( 'SelectTime: StartTime=11 EndTime=14')
do( 'Screenshot: Path='+path+' CaptureWhat=First_Track_Plus' )
def image2() :
global path
makeStereoTrack()
do( 'SelectTime: StartTime=11 EndTime=14')
do( 'Screenshot: Path='+path+' CaptureWhat=First_Track_Plus' )
#quickTest()
setup()
image1()
closeTrack()
image2()
closeTrack()

View File

@ -73,6 +73,8 @@ enum kCaptureTypes
ktracks,
kfirsttrack,
ksecondtrack,
ktracksplus,
kfirsttrackplus,
nCaptureWhats
};
@ -103,6 +105,8 @@ static const wxString kCaptureWhatStrings[nCaptureWhats] =
XO("Tracks"),
XO("First_Track"),
XO("Second_Track")
XO("Tracks_Plus"),
XO("First_Track_Plus"),
};
@ -267,14 +271,15 @@ bool ScreenshotCommand::Capture(
//wxRect r(x, y, width, height);
// Ensure within bounds (x/y are negative on Windows when maximized)
r.Intersect(wxRect(0, 0, screenW, screenH));
// Convert to screen coordinates if needed
if (window && window->GetParent() && !window->IsTopLevel()) {
r.SetPosition(window->GetParent()->ClientToScreen(r.GetPosition()));
}
// Ensure within bounds (x/y are negative on Windows when maximized)
r.Intersect(wxRect(0, 0, screenW, screenH));
// Extract the actual image
wxBitmap part = full.GetSubBitmap(r);
@ -799,6 +804,12 @@ bool ScreenshotCommand::Apply(const CommandContext & context)
TrackPanel *panel = context.GetProject()->GetTrackPanel();
AdornedRulerPanel *ruler = panel->mRuler;
int x1,y1,x2,y2;
w->ClientToScreen(&x1, &y1);
panel->ClientToScreen(&x2, &y2);
wxPoint p( x2-x1, y2-y1);
if (mCaptureMode.IsSameAs(wxT("Window")))
return Capture(context, WindowFileName( context.GetProject(), w ) , w, GetWindowRect(w));
else if (mCaptureMode.IsSameAs(wxT("Fullwindow"))
@ -848,6 +859,18 @@ bool ScreenshotCommand::Apply(const CommandContext & context)
return Capture(context, mFileName, panel, GetTrackRect( context.GetProject(), panel, 0 ) );
else if (mCaptureMode.IsSameAs(wxT("Second_Track")))
return Capture(context, mFileName, panel, GetTrackRect( context.GetProject(), panel, 1 ) );
else if (mCaptureMode.IsSameAs(wxT("Tracks_Plus")))
{ wxRect r = GetTracksRect(panel);
r.SetTop( r.GetTop() - ruler->GetRulerHeight() );
r.SetHeight( r.GetHeight() + ruler->GetRulerHeight() );
return Capture(context, mFileName, panel, r);
}
else if (mCaptureMode.IsSameAs(wxT("First_Track_Plus")))
{ wxRect r = GetTrackRect(context.GetProject(), panel, 0 );
r.SetTop( r.GetTop() - ruler->GetRulerHeight() );
r.SetHeight( r.GetHeight() + ruler->GetRulerHeight() );
return Capture(context, mFileName, panel, r );
}
else
return false;

View File

@ -27,16 +27,7 @@
#include "CommandContext.h"
SetTrackCommand::SetTrackCommand()
{/*
mTrackIndex = 0;
mTrackName = "unnamed";
mPan = 0.0f;
mGain = 1.0f;
bSelected = false;
bFocused = false;
bSolo = false;
bMute = false;
*/
{
}
enum kColours
@ -65,7 +56,7 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
S.Optional( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 700 );
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
S.Optional( bHasSelected ).Define( bSelected, wxT("Selected"), false );
S.Optional( bHasFocused ).Define( bFocused, wxT("Focuseed"), false );
S.Optional( bHasFocused ).Define( bFocused, wxT("Focused"), false );
S.Optional( bHasSolo ).Define( bSolo, wxT("Solo"), false );
S.Optional( bHasMute ).Define( bMute, wxT("Mute"), false );
return true;