You need to parse int(duration * sample_rate) otherwise it yields the following error when using 3D player:
Exception in Tkinter callback
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/piano/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
return self.func(*args)
File "/home/ubuntu/anaconda3/envs/piano/bin/pianoplayer", line 103, in vpCMD
vk.play()
File "/home/ubuntu/anaconda3/envs/piano/lib/python3.6/site-packages/pianoplayer/vtk_keyboard.py", line 134, in play
if self.rightHand: self._moveHand( 1, t)
File "/home/ubuntu/anaconda3/envs/piano/lib/python3.6/site-packages/pianoplayer/vtk_keyboard.py", line 198, in _moveHand
playSound(n, self.speedfactor)
File "/home/ubuntu/anaconda3/envs/piano/lib/python3.6/site-packages/pianoplayer/wavegenerator.py", line 75, in playSound
soundof([n], n.duration/speedfactor)
File "/home/ubuntu/anaconda3/envs/piano/lib/python3.6/site-packages/pianoplayer/wavegenerator.py", line 30, in soundof
t = np.linspace(0, duration, (duration * sample_rate), False)
File "<__array_function__ internals>", line 6, in linspace
File "/home/ubuntu/anaconda3/envs/piano/lib/python3.6/site-packages/numpy/core/function_base.py", line 113, in linspace
num = operator.index(num)
TypeError: 'float' object cannot be interpreted as an integer
There is a bug https://github.com/marcomusy/pianoplayer/blob/5624af859e8d50dec8de35a6b35d604255ed39bc/pianoplayer/wavegenerator.py#L30
You need to parse
int(duration * sample_rate)
otherwise it yields the following error when using3D player
: