Skip to content

Instantly share code, notes, and snippets.

@wyager
Created February 7, 2017 03:08
Show Gist options
  • Save wyager/7362cd7d73d847c3ae0a24d9ec703774 to your computer and use it in GitHub Desktop.
Save wyager/7362cd7d73d847c3ae0a24d9ec703774 to your computer and use it in GitHub Desktop.
# Warps a song
import scipy.io.wavfile as wav
import numpy as np
import sys
if len(sys.argv) != 3:
print sys.argv
print("Error: Must run as: python Warp.py in.wav out.wav")
sys.exit(1)
[pgm,i,o] = sys.argv
(sampleRate,data) = wav.read(i)
dtype = data.dtype
biggest = max(np.max(data), abs(np.min(data)))
data = data.astype(float)
data /= biggest
print np.max(data)
print np.min(data)
signs = np.sign(data)
data = signs * np.sqrt(np.abs(data))
data = np.sin(2*np.pi*data)
data *= biggest
data = data.astype(dtype)
wav.write(o,sampleRate,data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment