Skip to content

Commit

Permalink
Applying the windowing function should be vectorized, instead of perf…
Browse files Browse the repository at this point in the history
…ormed many times in a loop
  • Loading branch information
JohnVinyard committed Jul 8, 2018
1 parent 10b0ce6 commit 01a303e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zounds/synthesize/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def _overlap_add(self, frames):

# create an empty array of audio samples
arr = np.zeros(int(time_dim.end / sample_freq))
for i, f in enumerate(frames):
windowed_frames = self._windowing_function() * frames

for i, f in enumerate(windowed_frames):
start = i * hopsize
stop = start + windowsize
l = len(arr[start:stop])
arr[start:stop] += (self._windowing_function() * f[:l])
arr[start:stop] += f[:l]

sr = nearest_audio_sample_rate(Seconds(1) / sample_freq)
return AudioSamples(arr, sr)
Expand Down

0 comments on commit 01a303e

Please sign in to comment.