Exemple #1
0
def signal_test (small_exponent, large_exponent, signal, filename):
  fft_size = 1 << ((small_exponent + large_exponent) / 2)
  length_windows = fft_size / 2
  length_samples = fft_size * length_windows

  print "creating signal"
  input = K.Complexes(length_samples)

  for i in range(length_samples):
    t = (0.5 + i) / length_samples
    input[i] = signal(t)

  print "transforming signal"
  s = K.Multigram(small_exponent, large_exponent)
  
  length_frames = length_samples / s.size_in
  input = input.reshape((length_frames, s.size_in))
  output = K.Reals(length_frames, s.size_out)

  for i in range(length_frames):
    s.transform_fwd(input[i,:], output[i,:])

  print "writing multigram to %s" % filename

  output = util.energy_to_loudness(output)
  formats.write_image(output, filename)
Exemple #2
0
def file_test (small_exponent = 9, large_exponent = 12):
  "multigram"
  s = K.Multigram(small_exponent, large_exponent)
  size_in = s.size_in
  large_size = s.size_out
  length = s.size_out / 2#arbitrary

  print "reading sound file"
  sound = formats.read_wav('test.wav', size_in*length, size_in)
  image = K.Reals(length, large_size)

  print "transforming data"
  for i in range(length):
    s.transform_fwd(sound[i,:], image[i,:])
  del sound

  print "saving image"
  image = util.energy_to_loudness(image + 1e-5)
  formats.write_image(image, 'test.png')
Exemple #3
0
def signal_test (exponent, signal, filename):
  width = 1 << exponent
  size = width * width

  print "creating signal"
  input = K.Complexes(size)

  for i in range(size):
    t = (i + 0.5) / size
    input[i] = signal(t)

  input = input.reshape((width,width))

  print "transforming signal"
  output = K.Reals(width,width/2)

  s = K.Spectrogram(exponent)
  for i in range(width):
    s.transform_fwd(input[i,:], output[i,:])

  print "writing spactrogram to %s" % filename
  output = util.energy_to_loudness(output)
  formats.write_image(output, filename)