Created
February 7, 2017 03:08
-
-
Save wyager/7362cd7d73d847c3ae0a24d9ec703774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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