geigr / ipytone

Interactive audio in Jupyter
https://ipytone.readthedocs.io
BSD 3-Clause "New" or "Revised" License
60 stars 8 forks source link

Google Colab (on Chrome) Not Working? #96

Open davies-w opened 1 year ago

davies-w commented 1 year ago

Hi,

I'm really excited to play with this, however, I don't seem to be able to get it to work with Google Colab. I cribbed the Getting Started Example, and it has literally played only once - and despite restarting everything, I haven't been able to get it to work since.

https://colab.research.google.com/drive/12AOjdfuGQS0Oed6f1IFhAR4T90FvtST3#scrollTo=WrOjM2Pj6VQr

Any help gratefully received! Winton

benbovy commented 1 year ago

Hi @wantondevious, thanks for the feedback!

I'm not using Google Colab so unfortunately I'm afraid I cannot help much on this right now. I wouldn't be surprised if there are some limitations in the Colab widget implementation such that you wont hear any sound.

(PS: 100 is painfully high for the volume value, better is something between -inf and 0)

benbovy commented 1 year ago

I wouldn't be surprised if there are some limitations in the Colab widget implementation such that you wont hear any sound.

One thing I'm not sure is whether the security model used in Colab is compatible with Tonejs. I suspect it wouldn't work out of the box: IIUC Colab outputs are each isolated in an iframe with different origin (https://stackoverflow.com/a/48920438) while Tonejs use a globally defined audio context (via the web audio API).

davies-w commented 1 year ago

Thanks so much Ben! It's such a cool project, I hope I can figure it out, the implications for being able to combine data science and music generation are amazing - your world animation for example!