gensound
gensound copied to clipboard
Crash when realising sequential Sines controlled by Lines
Code:
if __name__ == '__main__':
x = Sine(Line(220, 440, 1e3)) | Sine(Line(440, 220, 1e3))
x.play()
Trace:
Traceback (most recent call last):
File "test.py", line 15, in <module>
x.play()
File "python3.8/site-packages/gensound/signals.py", line 54, in play
audio = self.realise(sample_rate)
File "python3.8/site-packages/gensound/signals.py", line 41, in realise
audio = self.generate(sample_rate)
File "python3.8/site-packages/gensound/signals.py", line 382, in generate
phase = (phase + signal.end_phase)%(2*np.pi) # phase inference
File "python3.8/site-packages/gensound/signals.py", line 500, in end_phase
return (phase + 2*np.pi * self.frequency * self.duration / 1000)%(2*np.pi)
TypeError: unsupported operand type(s) for *: 'float' and 'Line'
Thanks for finding this!
I found the problem, but I still need to decide on the most efficient way to prevent it.
In the meanwhile, here is a more natural way to accomplish this:
if __name__ == '__main__':
x = Sine(Line(220, 440, 1e3) | Line(440, 220, 1e3))
x.play()