PageRenderTime 102ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/import_wav.py

https://bitbucket.org/rcompton/musical-gauss-seidel
Python | 43 lines | 23 code | 15 blank | 5 comment | 2 complexity | 1c968082794b08331b3c1bdeff045eb1 MD5 | raw file
  1. from numpy import *
  2. import scipy.io.wavfile as S
  3. import pylab
  4. import os
  5. (fs,x) = S.read("haydenSample.wav")
  6. x = x#/32768.0
  7. #kill off the left speaker
  8. for i in x:
  9. i[0] = 0
  10. #make the data nonstero
  11. b = x[:,1]
  12. for i in range(len(b)-100000):
  13. b[i] = b[i+100000]
  14. S.write("hayden_same_on_both_speakers.wav", fs, b)
  15. #os.system("mplayer hayden_same_on_both_speakers.wav")
  16. secs = 1.0
  17. fs = 44100
  18. t = arange(fs*secs)/fs
  19. freq = 440
  20. #this is scaled wrong and sounds buzzy and shit
  21. x = cos(t*2*pi*freq)*.7
  22. #this is nice
  23. x = (x*32768.0).astype(int16)
  24. pylab.figure()
  25. pylab.plot(t, x)
  26. pylab.show()
  27. S.write("sine_wave.wav", fs, x)
  28. os.system("mplayer sine_wave.wav")