spacetelescope / astronify

Astronomical data sonification.
https://astronify.readthedocs.io
72 stars 15 forks source link

Can not call write() in Python notebooks. #19

Open scfleming opened 4 years ago

scfleming commented 4 years ago

I am unable to make a call to write() on a sonified object. I haven't debugged it a ton yet, but it seems there is an order-of-operations problem in the _write() pyo statement (at least for me) where it again causes an error about the server being booted.

It complains around this set of code:

` self.server.reinit(audio="offline") self.server.boot() self.server.recordOptions(dur=delays[-1]+duration, filename=filepath)

    env = pyo.Linseg(list=[(0, 0), (0.1, 1), (duration - 0.1, 1),
                           (duration - 0.05, 0.5), (duration - 0.005, 0)],
                     mul=[self.gain for i in range(len(pitches))]).play(
                         delay=list(delays), dur=duration)
    sine = pyo.Sine(list(pitches), 0, env).out(delay=list(delays),
                                               dur=duration)
    self.server.start()`

where it is unhappy with the .play() command inside the 'env' line. I tried moving the server.start() above the env line, but no avail.

ceb8 commented 4 years ago

I can't reproduce this problem, I can write the sonified object both before and after playing it. Can you describe more specifically the steps you take?

scfleming commented 4 years ago

Well, now I am able to save a .wav file using write(), but it doesn't play any sound for me (in iTunes or Quicktime, at least). Not sure if that's a new bug or not.

ceb8 commented 4 years ago

What happens if you restart the kernel and try again?