You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7KB

  1. #!/usr/bin/python2.5
  2. #
  3. # Copyright 2012 Olivier Gillet.
  4. #
  5. # Author: Olivier Gillet (ol.gillet@gmail.com)
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. # -----------------------------------------------------------------------------
  19. #
  20. # Waveshaper lookup tables.
  21. import numpy
  22. import audio_io
  23. boundaries = [0]
  24. sample_data = []
  25. TRUNCATE = False
  26. for i in xrange(1, 10):
  27. audio_data, sr = audio_io.ReadWavFile('elements/samples/hit_%02d.wav' % i)
  28. audio_data = audio_data.sum(axis=1)
  29. audio_data = list(audio_data)
  30. if TRUNCATE:
  31. audio_data = audio_data[:128]
  32. audio_data += [audio_data[-1]] # Add interpolation tail
  33. audio_data = numpy.round(numpy.array(audio_data) * 32767.0)
  34. sample_data += list(audio_data)
  35. boundaries.append(boundaries[-1] + len(audio_data))
  36. sample_data = [('sample_data', sample_data)]
  37. boundaries = [('boundaries', boundaries)]
  38. audio_data, sr = audio_io.ReadWavFile('elements/samples/noise.wav')
  39. audio_data = audio_data.sum(axis=1)
  40. audio_data = numpy.round(numpy.array(audio_data) * 32767.0)
  41. if TRUNCATE:
  42. audio_data = audio_data[:128]
  43. sample_data += [('noise_sample', audio_data)]