1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-02 23:23:53 +01:00

Shared part of script extracted.

This commit is contained in:
James Crook
2018-02-16 09:38:31 +00:00
committed by Paul Licameli
parent 0ec5cbb339
commit 213202d4f1
4 changed files with 167 additions and 352 deletions

View File

@@ -0,0 +1,156 @@
# docimages_core.py
# Sends commands to get images for the manual.
# This is the shared part reused in a bunch of scripts.
# Make sure Audacity is running first and that mod-script-pipe is enabled
# before running this script.
import os
import sys
def startPipes() :
global tofile
global fromfile
global EOL
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 ) :
global tofile
global EOL
print( "Send: >>> \n"+command )
tofile.write( command + EOL )
tofile.flush()
def getResponse() :
global fromfile
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: <<< \n" + response )
return response
def do( command ) :
doCommand( command )
def quickTest() :
do( 'Help: Command=Help' )
def setup() :
global path
global sample
global sample2
path = 'C:\\Users\\James Crook\\'
sample ='C:\\Users\\James Crook\\Music\\The Poodle Podcast.wav'
sample2 ='C:\\Users\\James Crook\\Music\\PoodlePodStereo.wav'
startPipes()
do( 'SetProject: X=10 Y=10 Width=850 Height=800' )
def makeWayForTracks( ) :
do( 'Select: First=0 Last=20' )
do( 'RemoveTracks' )
def capture( name, what ) :
global path
do( 'Screenshot: Path="'+path+name+'" CaptureWhat=' + what )
def loadMonoTrack():
global sample
makeWayForTracks( )
do( 'Import2: Filename="'+sample+'"' )
do( 'Select: First=0 Last=0 Start=0 End=150')
do( 'Trim')
do( 'ZoomSel' )
def loadStereoTrack():
global sample2
makeWayForTracks( )
do( 'Import2: Filename="'+sample2+'"' )
do( 'Select: First=0 Last=0 Start=0 End=150')
do( 'Trim')
do( 'ZoomSel' )
def loadMonoTracks( num ) :
makeWayForTracks( )
loadMonoTrack()
do( 'SetTrack: Track=0 Name="Foxy Lady"')
for i in range( 0, num-1 ):
do( 'Duplicate' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def loadStereoTracks( num ) :
makeWayForTracks( )
loadStereoTrack()
do( 'SetTrack: Track=0 Name="Foxy Lady"')
for i in range( 0, num-1 ):
do( 'Duplicate' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70 First=0 Last=' + str(num*2-1) )
def makeMonoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewMonoTrack' )
do( 'SetTrack: Track=0 Name="Foxy Lady"')
do( 'Select: Start=0 End=150 First=0 Last=' + str(num-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def makeStereoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewStereoTrack' )
do( 'SetTrack: Track=0 Name="Voodoo Children IN STEREO"')
do( 'Select: Start=0 End=150 First=0 Last=' + str(num*2-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
try:
coreLoaded
except NameError:
setup()
coreLoaded=True
print( "Set up done")
else :
print( "Already set up")

View File

@@ -5,113 +5,10 @@
# Make sure Audacity is running first and that mod-script-pipe is enabled
# before running this script.
import os
import sys
#load and run the common core.
exec( open("docimages_core.py" ).read() )
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: >>> \n"+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: <<< \n" + response )
return response
def do( command ) :
doCommand( command )
def quickTest() :
do( 'Help: Command=Help' )
def setup() :
global path
global sample
path = '\"C:/Users/James Crook/\"'
sample ='\"C:\\Users\\Public\\Music\\Sample Music\\Concerto.mp3\"'
do( 'SetProject: X=10 Y=10 Width=850 Height=800' )
def makeWayForTracks( ) :
do( 'Select: First=0 Last=20' )
do( 'RemoveTracks' )
def capture( name, what ) :
global path
do( 'Screenshot: Path='+path+name+' CaptureWhat=' + what )
def makeMonoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewMonoTrack' )
do( 'SetTrack: Track=0 Name="Foxy Lady"')
do( 'Select: Start=0 End=30 First=0 Last=' + str(num-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=11 End=14')
def loadStereoTrack():
global sample
makeWayForTracks( )
do( 'Import2: Filename='+sample )
do( 'Select: Start=0 End=150')
do( 'ZoomSel' )
do( 'SetTrack: Track=0 Name="The Poodle Podcast"')
def makeStereoTracks( num ) :
makeWayForTracks( )
if( num == 1 ):
loadStereoTrack()
return
for i in range( 0, num ):
do( 'NewStereoTrack' )
do( 'SetTrack: Track=0 Name="Voodoo Children IN STEREO"')
do( 'Select: Start=0 End=30 First=0 Last=' + str(num*2-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def addLabels():
do( 'Select: Start=0 End=1' )
@@ -205,9 +102,11 @@ def image8and9and10() :
do( 'Delete' )
capture( 'AutoLabels010.png','First_Three_Tracks' )
#quickTest()
setup()
image1and2()
image3and4()
image5and6and7()
image8and9and10()

View File

@@ -5,140 +5,10 @@
# Make sure Audacity is running first and that mod-script-pipe is enabled
# before running this script.
import os
import sys
#load and run the common core.
exec( open("docimages_core.py" ).read() )
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: >>> \n"+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: <<< \n" + response )
return response
def do( command ) :
doCommand( command )
def quickTest() :
do( 'Help: Command=Help' )
def setup() :
global path
global sample
global sample2
path = 'C:\\Users\\James Crook\\'
sample ='C:\\Users\\James Crook\\Music\\The Poodle Podcast.wav'
sample2 ='C:\\Users\\James Crook\\Music\\PoodlePodStereo.wav'
do( 'SetProject: X=10 Y=10 Width=850 Height=800' )
def makeWayForTracks( ) :
# Twice to remove stereo tracks.
do( 'SelectTracks: First=0 Last=20' )
do( 'RemoveTracks' )
do( 'SelectTracks: First=0 Last=20' )
do( 'RemoveTracks' )
def capture( name, what ) :
global path
do( 'Screenshot: Path="'+path+name+'" CaptureWhat=' + what )
def loadMonoTrack():
global sample
makeWayForTracks( )
do( 'Import2: Filename="'+sample+'"' )
do( 'Select: First=0 Last=0 Start=0 End=150')
do( 'Trim')
do( 'ZoomSel' )
def loadStereoTrack():
global sample2
makeWayForTracks( )
do( 'Import2: Filename="'+sample2+'"' )
do( 'Select: First=0 Last=0 Start=0 End=150')
do( 'Trim')
do( 'ZoomSel' )
def loadMonoTracks( num ) :
makeWayForTracks( )
loadMonoTrack()
do( 'SetTrack: Track=0 Name="Foxy Lady"')
for i in range( 0, num-1 ):
do( 'Duplicate' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def loadStereoTracks( num ) :
makeWayForTracks( )
loadStereoTrack()
do( 'SetTrack: Track=0 Name="Foxy Lady"')
for i in range( 0, num-1 ):
do( 'Duplicate' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70 First=0 Last=' + str(num*2-1) )
def makeMonoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewMonoTrack' )
do( 'SetTrack: Track=0 Name="Foxy Lady"')
do( 'Select: Start=0 End=150 First=0 Last=' + str(num-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def makeStereoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewStereoTrack' )
do( 'SetTrack: Track=0 Name="Voodoo Children IN STEREO"')
do( 'Select: Start=0 End=150 First=0 Last=' + str(num*2-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
# 11 2KHz tones, of decreasing amplitude.
# With label track to annotate it.
@@ -182,7 +52,7 @@ def image3and4():
capture( 'Spectral004.png', 'First_Two_Tracks' )
#quickTest()
setup()
image1and2()
image3and4()

View File

@@ -5,118 +5,10 @@
# Make sure Audacity is running first and that mod-script-pipe is enabled
# before running this script.
import os
import sys
#load and run the common core.
exec( open("docimages_core.py" ).read() )
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: >>> \n"+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: <<< \n" + response )
return response
def do( command ) :
doCommand( command )
def quickTest() :
do( 'Help: Command=Help' )
def setup() :
global path
global sample
path = 'C:\\Users\\James Crook\\'
sample ='C:\\Users\\James Crook\\Music\\The Poodle Podcast.wav'
do( 'SetProject: X=10 Y=10 Width=850 Height=800' )
def makeWayForTracks( ) :
do( 'SelectTracks: First=0 Last=20' )
do( 'RemoveTracks' )
def capture( name, what ) :
global path
do( 'Screenshot: Path="'+path+name+'" CaptureWhat=' + what )
def loadMonoTrack():
global sample
makeWayForTracks( )
do( 'Import2: Filename="'+sample+'"' )
do( 'Select: First=0 Last=0 Start=0 End=150')
do( 'Trim')
do( 'ZoomSel' )
def loadMonoTracks( num ) :
makeWayForTracks( )
loadMonoTrack()
do( 'SetTrack: Track=0 Name="Foxy Lady"')
for i in range( 0, num-1 ):
do( 'Duplicate' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def makeMonoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewMonoTrack' )
do( 'SetTrack: Track=0 Name="Foxy Lady"')
do( 'Select: Start=0 End=150 First=0 Last=' + str(num-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def makeStereoTracks( num ) :
makeWayForTracks( )
for i in range( 0, num ):
do( 'NewStereoTrack' )
do( 'SetTrack: Track=0 Name="Voodoo Children IN STEREO"')
do( 'Select: Start=0 End=150 First=0 Last=' + str(num*2-1) )
do( 'Chirp: StartAmp=0.5' )
do( 'Wahwah' )
do( 'FitInWindow' )
do( 'Select: Start=55 End=70')
def image1and8() :
loadMonoTracks(1)
@@ -177,8 +69,6 @@ def image9and10() :
do( 'SetPreference: Name=/GUI/SampleView Value=0 Reload=1')
capture( 'AutoTracks010.png', 'First_Track' )
#quickTest()
setup()
image1and8()
image2and6()
image3()