我正在尝试使用 wavebender 库来创作音乐并从音乐中获取数据。我遇到了这个错误,不知道如何解决。
from wavebender import *
from itertools import *
import sys
def ncycles(iterable, n):
"Returns the sequence elements n times"
return chain.from_iterable(repeat(tuple(iterable), n))
def waves():
l = int(44100*0.4) # each note lasts 0.4 seconds
return cycle(chain(ncycles(chain(islice(damped_wave(frequency=440.0, amplitude=0.1, length=int(l/4)), l),
islice(damped_wave(frequency=261.63, amplitude=0.1, length=int(l/4)), l),
islice(damped_wave(frequency=329.63, amplitude=0.1, length=int(l/4)), l)), 3),
islice(damped_wave(frequency=440.0, amplitude=0.1, length=3*l), 3*l),
ncycles(chain(islice(damped_wave(frequency=293.66, amplitude=0.1, length=int(l/4)), l),
islice(damped_wave(frequency=261.63, amplitude=0.1, length=int(l/4)), l),
islice(damped_wave(frequency=293.66, amplitude=0.1, length=int(l/4)), l)), 2),
chain(islice(damped_wave(frequency=293.66, amplitude=0.1, length=int(l/4)), l),
islice(damped_wave(frequency=329.63, amplitude=0.1, length=int(l/4)), l),
islice(damped_wave(frequency=293.66, amplitude=0.1, length=int(l/4)), l)),
islice(damped_wave(frequency=261.63, amplitude=0.1, length=3*l), 3*l)))
channels = ((waves(),), (waves(), white_noise(amplitude=0.001),))
samples = compute_samples(channels, None)
write_wavefile(sys.stdout, samples, None)
产生此错误;
/usr/bin/python2.7 /home/nerzid/PycharmProjects/Deneme/assets/beep.py
Traceback (most recent call last):
File "/home/nerzid/PycharmProjects/Deneme/assets/beep.py", line 28, in <module>
RIFFRIFF write_wavefile(sys.stdout, samples, None)
File "/usr/local/lib/python2.7/dist-packages/wavebender/__init__.py", line 98, in write_wavefile
w.writeframesraw(frames)
File "/usr/lib/python2.7/wave.py", line 422, in writeframesraw
self._ensure_header_written(len(data))
File "/usr/lib/python2.7/wave.py", line 473, in _ensure_header_written
self._write_header(datasize)
File "/usr/lib/python2.7/wave.py", line 481, in _write_header
self._form_length_pos = self._file.tell()
IOError: [Errno 29] Illegal seek
Exception IOError: (29, 'Illegal seek') in <bound method Wave_write.__del__ of <wave.Wave_write instance at 0x7fbe63ecad88>> ignored
任何意见,将不胜感激。