commit 5827e539219f1c52491490d5f7121599c377466f
parent 644a02a9df6ceb7ba41b5eeeeadbcf8dc7c65b85
Author: Nasca Octavian PAUL <zynaddsubfx@yahoo.com>
Date: Wed, 23 Feb 2011 21:18:52 +0200
The time streching is more accurate related to the transients (i.e. it doesn't short the sound on transinets).
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/paulstretch_newmethod.py b/paulstretch_newmethod.py
@@ -89,6 +89,7 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,transient_level,outfil
displace_tick_increase=1.0/stretch
if displace_tick_increase>1.0:
displace_tick_increase=1.0
+ extra_transient_time_credit=0.0
get_next_buf=True
while True:
if get_next_buf:
@@ -108,6 +109,7 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,transient_level,outfil
m=sqrt(m)
if m>transient_level:
displace_tick=1.0
+ extra_transient_time_credit+=1.0
cfreqs=(freqs*displace_tick)+(old_freqs*(1.0-displace_tick))
@@ -146,7 +148,16 @@ def paulstretch(samplerate,smp,stretch,windowsize_seconds,transient_level,outfil
print "%d %% \r" % int(100.0*start_pos/nsamples),
sys.stdout.flush()
- displace_tick+=displace_tick_increase
+
+ if extra_transient_time_credit<=0.0:
+ displace_tick+=displace_tick_increase
+ else:
+ credit_get=0.5*displace_tick_increase #this must be less than displace_tick_increase
+ extra_transient_time_credit-=credit_get
+ if extra_transient_time_credit<0:
+ extra_transient_time_credit=0
+ displace_tick+=displace_tick_increase-credit_get
+
if displace_tick>=1.0:
displace_tick=displace_tick % 1.0
get_next_buf=True