Hi Chuck,
1) Makes sense.
2) Doesn't make sense. 😉 You want audio data in the Spine JSON and/or binary formats? I think it makes sense for it to be separate, just like images.
3) You can import data into Spine using the Spine JSON and binary formats.
There currently isn't a plugin API. I appreciate the offer, but I think it makes most sense to either provide the functionality for you or otherwise provide a way for you to get the functionality you want. Spine could render audio via OpenAL relatively easily, but the rest of the UI functionality needed would take more effort. We have a pipeline of important features, so we won't get to audio in the short term.
Possibly the fastest way to get what you need would be for Spine to open a TCP socket to report and receive events. Eg, it could send playback start at frame 2, playback stop, etc. For audio, instead of wall time the animation needs to use the audio clock, so it would need to receive events. Eg, frame 2, frame 2.6, frame 3.2, etc. The API would need to be kept very simple.
I implemented this for kicks. It is experimental and subject to change, but this is how it works:
1) Start Spine with `
server 4567` where 4567 is the port Spine will listen on. You'll need Spine 3.0.11+ and you'll have to download a new Spine launcher for this.
2) Open a localhost socket and connect to that port.
3) When connected, you will receive events. There are currently 2 events. play 123\n
is sent when playback starts, where 123 is the time playback started. stop\n
is sent when playback stops.
4) When connected, animation playback in Spine will not use the wall time. Instead it will use the last time sent via the socket. Time is sent like time 123\n
where 123 is the time in seconds.
The idea is that your process plays the audio when Spine sends "play", continuously sends the audio renderer's time, and stops the audio when Spine sends "stop". Here's a 50 LOC example implementation (this will only play WAVs):
https://gist.github.com/NathanSweet/9848c90a35dc56a49cdc
Here's that as a JAR:
http://esotericsoftware.com/files/play.jar
Run it with: java -jar play.jar 4567 path/to/music.wav
It would not be too hard to allow a sound file to be chosen in Spine (libgdx supports OpenAL, MP3, OGG, WAV) and of course that would be a more proper way to do this, but getting distracted from our current plans is all too easy and I'd rather take the time to make sure the feature is properly thought through and integrated with the rest of the app.