kylestetz / lissajous

:musical_note: A tool for programmatic audio performance in the browser using Javascript.

Home Page:http://lissajousjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

song object container

wildmolasses opened this issue · comments

I have been thinking of how to persist songs in lissajous as well as encapsulate the song as an object for sharing and more relevantly for collaborating in real time. I see that the clock object is keeping track of the song but that it also has methods that don't carry over into a JSON.stringify string. Therefore the clock can't be the container that gets updated to clients for collab nor the object that gets stringified for me to share my song.

So, this doesn't cover the entire scope of the problem, but:

In order to implement track.merge the track needs to keep a record of its state at a given time. To do that I implemented state getting and setting, which is called from all of the track's public API methods (with some exceptions). If you simply stored the name and arguments of each function call in an array alongside context.currentTime you would have a record of all the functions called through time.

Where this gets a little more complicated is in the fact that both AudioBuffer objects and generator functions get passed around as arguments. As you've pointed out, they can't be stringified. Not sure how to get around this for samples although I know that it's possible for generator functions.

To clarify, that all would make it possible to store a performance and play it back. Realtime collaboration is a different problem...