Skip to content

Commit 0d4e7a0

Browse files
author
Nasca Octavian PAUL
committed
Change 'print' statement to make compatible with python3
1 parent 013e9d4 commit 0d4e7a0

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

paulstretch_mono.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def load_wav(filename):
2424
smp=(smp[:,0]+smp[:,1])*0.5
2525
return (samplerate,smp)
2626
except:
27-
print "Error loading wav: "+filename
27+
print ("Error loading wav: "+filename)
2828
return None
2929

3030

@@ -101,9 +101,9 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,outfilename):
101101

102102
start_pos+=displace_pos
103103
if start_pos>=len(smp):
104-
print "100 %"
104+
print ("100 %")
105105
break
106-
print "%d %% \r" % int(100.0*start_pos/len(smp)),
106+
sys.stdout.write ("%d %% \r" % int(100.0*start_pos/len(smp)))
107107
sys.stdout.flush()
108108

109109
outfile.close()

paulstretch_newmethod.py

100755100644
+10-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def load_wav(filename):
3333
smp=tile(smp,(2,1))
3434
return (samplerate,smp)
3535
except:
36-
print "Error loading wav: "+filename
36+
print ("Error loading wav: "+filename)
3737
return None
3838

3939

@@ -176,9 +176,9 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,onset_level,outfilenam
176176
get_next_buf=False
177177

178178
if start_pos>=nsamples:
179-
print "100 %"
179+
print ("100 %")
180180
break
181-
print "%d %% \r" % int(100.0*start_pos/nsamples),
181+
sys.stdout.write ("%d %% \r" % int(100.0*start_pos/nsamples))
182182
sys.stdout.flush()
183183

184184

@@ -203,9 +203,9 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,onset_level,outfilenam
203203

204204

205205
########################################
206-
print "Paul's Extreme Sound Stretch (Paulstretch) - Python version 20110223"
207-
print "new method: using onsets information"
208-
print "by Nasca Octavian PAUL, Targu Mures, Romania\n"
206+
print ("Paul's Extreme Sound Stretch (Paulstretch) - Python version 20141220")
207+
print ("new method: using onsets information")
208+
print ("by Nasca Octavian PAUL, Targu Mures, Romania\n")
209209
parser = OptionParser(usage="usage: %prog [options] input_wav output_wav")
210210
parser.add_option("-s", "--stretch", dest="stretch",help="stretch amount (1.0 = no stretch)",type="float",default=8.0)
211211
parser.add_option("-w", "--window_size", dest="window_size",help="window size (seconds)",type="float",default=0.25)
@@ -214,12 +214,12 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,onset_level,outfilenam
214214

215215

216216
if (len(args)<2) or (options.stretch<=0.0) or (options.window_size<=0.001):
217-
print "Error in command line parameters. Run this program with --help for help."
217+
print ("Error in command line parameters. Run this program with --help for help.")
218218
sys.exit(1)
219219

220-
print "stretch amount =",options.stretch
221-
print "window size =",options.window_size,"seconds"
222-
print "onset sensitivity =",options.onset
220+
print ("stretch amount = %g" % options.stretch)
221+
print ("window size = %g seconds" % options.window_size)
222+
print ("onset sensitivity = %g" % options.onset)
223223
(samplerate,smp)=load_wav(args[0])
224224

225225
paulstretch(samplerate,smp,options.stretch,options.window_size,options.onset,args[1])

paulstretch_stereo.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def load_wav(filename):
2828
smp=tile(smp,(2,1))
2929
return (samplerate,smp)
3030
except:
31-
print "Error loading wav: "+filename
31+
print ("Error loading wav: "+filename)
3232
return None
3333

3434

@@ -124,28 +124,28 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,outfilename):
124124

125125
start_pos+=displace_pos
126126
if start_pos>=nsamples:
127-
print "100 %"
127+
print ("100 %")
128128
break
129-
print "%d %% \r" % int(100.0*start_pos/nsamples),
129+
sys.stdout.write ("%d %% \r" % int(100.0*start_pos/nsamples))
130130
sys.stdout.flush()
131131

132132
outfile.close()
133133

134134
########################################
135-
print "Paul's Extreme Sound Stretch (Paulstretch) - Python version 20110222"
136-
print "by Nasca Octavian PAUL, Targu Mures, Romania\n"
135+
print ("Paul's Extreme Sound Stretch (Paulstretch) - Python version 20141220")
136+
print ("by Nasca Octavian PAUL, Targu Mures, Romania\n")
137137
parser = OptionParser(usage="usage: %prog [options] input_wav output_wav")
138138
parser.add_option("-s", "--stretch", dest="stretch",help="stretch amount (1.0 = no stretch)",type="float",default=8.0)
139139
parser.add_option("-w", "--window_size", dest="window_size",help="window size (seconds)",type="float",default=0.25)
140140
(options, args) = parser.parse_args()
141141

142142

143143
if (len(args)<2) or (options.stretch<=0.0) or (options.window_size<=0.001):
144-
print "Error in command line parameters. Run this program with --help for help."
144+
print ("Error in command line parameters. Run this program with --help for help.")
145145
sys.exit(1)
146146

147-
print "stretch amount =",options.stretch
148-
print "window size =",options.window_size,"seconds"
147+
print ("stretch amount = %g" % options.stretch)
148+
print ("window size = %g seconds" % options.window_size)
149149
(samplerate,smp)=load_wav(args[0])
150150

151151
paulstretch(samplerate,smp,options.stretch,options.window_size,args[1])

0 commit comments

Comments
 (0)