mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +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:
parent
1f605ccfc8
commit
24e8bbc623
119
scripts/piped-work/docimages_tracks.py
Normal file
119
scripts/piped-work/docimages_tracks.py
Normal 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()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -73,6 +73,8 @@ enum kCaptureTypes
|
|||||||
ktracks,
|
ktracks,
|
||||||
kfirsttrack,
|
kfirsttrack,
|
||||||
ksecondtrack,
|
ksecondtrack,
|
||||||
|
ktracksplus,
|
||||||
|
kfirsttrackplus,
|
||||||
nCaptureWhats
|
nCaptureWhats
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,6 +105,8 @@ static const wxString kCaptureWhatStrings[nCaptureWhats] =
|
|||||||
XO("Tracks"),
|
XO("Tracks"),
|
||||||
XO("First_Track"),
|
XO("First_Track"),
|
||||||
XO("Second_Track")
|
XO("Second_Track")
|
||||||
|
XO("Tracks_Plus"),
|
||||||
|
XO("First_Track_Plus"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -267,14 +271,15 @@ bool ScreenshotCommand::Capture(
|
|||||||
|
|
||||||
//wxRect r(x, y, width, height);
|
//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
|
// Convert to screen coordinates if needed
|
||||||
if (window && window->GetParent() && !window->IsTopLevel()) {
|
if (window && window->GetParent() && !window->IsTopLevel()) {
|
||||||
r.SetPosition(window->GetParent()->ClientToScreen(r.GetPosition()));
|
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
|
// Extract the actual image
|
||||||
wxBitmap part = full.GetSubBitmap(r);
|
wxBitmap part = full.GetSubBitmap(r);
|
||||||
|
|
||||||
@ -799,6 +804,12 @@ bool ScreenshotCommand::Apply(const CommandContext & context)
|
|||||||
TrackPanel *panel = context.GetProject()->GetTrackPanel();
|
TrackPanel *panel = context.GetProject()->GetTrackPanel();
|
||||||
AdornedRulerPanel *ruler = panel->mRuler;
|
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")))
|
if (mCaptureMode.IsSameAs(wxT("Window")))
|
||||||
return Capture(context, WindowFileName( context.GetProject(), w ) , w, GetWindowRect(w));
|
return Capture(context, WindowFileName( context.GetProject(), w ) , w, GetWindowRect(w));
|
||||||
else if (mCaptureMode.IsSameAs(wxT("Fullwindow"))
|
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 ) );
|
return Capture(context, mFileName, panel, GetTrackRect( context.GetProject(), panel, 0 ) );
|
||||||
else if (mCaptureMode.IsSameAs(wxT("Second_Track")))
|
else if (mCaptureMode.IsSameAs(wxT("Second_Track")))
|
||||||
return Capture(context, mFileName, panel, GetTrackRect( context.GetProject(), panel, 1 ) );
|
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
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -27,16 +27,7 @@
|
|||||||
#include "CommandContext.h"
|
#include "CommandContext.h"
|
||||||
|
|
||||||
SetTrackCommand::SetTrackCommand()
|
SetTrackCommand::SetTrackCommand()
|
||||||
{/*
|
{
|
||||||
mTrackIndex = 0;
|
|
||||||
mTrackName = "unnamed";
|
|
||||||
mPan = 0.0f;
|
|
||||||
mGain = 1.0f;
|
|
||||||
bSelected = false;
|
|
||||||
bFocused = false;
|
|
||||||
bSolo = false;
|
|
||||||
bMute = false;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum kColours
|
enum kColours
|
||||||
@ -65,7 +56,7 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
|
|||||||
S.Optional( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 700 );
|
S.Optional( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 700 );
|
||||||
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
||||||
S.Optional( bHasSelected ).Define( bSelected, wxT("Selected"), false );
|
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( bHasSolo ).Define( bSolo, wxT("Solo"), false );
|
||||||
S.Optional( bHasMute ).Define( bMute, wxT("Mute"), false );
|
S.Optional( bHasMute ).Define( bMute, wxT("Mute"), false );
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user