- Đã chỉnh sửa
Spine Plugin in Support
- Đã chỉnh sửa
Hello,
We currently support flash and Spine and have written code to merge the Spine files with flash into our own proprietary file format. Spine is great for creating quick animations with very small footprints which is exactly what we need but there are some features that are not in yet that would make our lives way easier.
1) Importing audio and scrubbing (lip syncing, timing audio, previewing animations with audio for art direction and approvals)
2) exporting those audio clips as one combined file
2) importing other data (like text files that will add events or driving animations with midi etc)
My question for you guys is is there a plugin API for spine? If not would it be possible for us to help develop these features for you and you in exchange we get the functionality we need and you guys get the updated code base?
Chuck
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.
#2 If you drag multiple audio clips into spine you would be able to export one combined audio track in .wav or what ever.
I will play with the import data some more, it looked like you needed a whole character data structure to import the event data and seeing we will be exporting the data from another program we would have to write something that looked at the character and merged that event data in. Am I in the ball park on this? If I just wanted to import something like this how would I go about it?
{
"animations": {
"walk": {
"events":[
{"time":0,"name":"footstep"},
{"time":0.2,"name":"footstep"},
{"time":0.3,"name":"footstep"},
{"time":0.4,"name":"footstep"},
{"time":0.5,"name":"footstep"},
{"time":0.6,"name":"footstep"},
{"time":0.7,"name":"footstep"},
]
}
}
As for the audio I think the socket will work.... just some way to hear the audio while still in the package where the editing happens is a big win.
Thanks!
Chuck
For #2, I think it'd be best to keep audio manipulation in purpose-built programs. What is the use case? Is your audio a number of sound effects rather than music?
For import, you can important a whole skeleton or an animation. For the whole skeleton, export the skeleton to JSON, manipulate the data, import it back. For an animation, export an empty skeleton with 1 animation to see the structure, output data in that structure, import that animation to your existing skeleton.
Hey Nate,
Finally got around to playing with the events in spine.
Here is what I am trying to do.
with Python I create a blank scene with keys and events that correspond to midi triggers (beats).
In this scene it's just a root bone and skeleton with events.
Merge that into a rigged character project.
Copy those events over to the character I need to animate.
This is where is goes wrong. It looks like you can only add events to an already animated character (otherwise even track doesn't show up) Also the events don't paste from character to character. Am I doing something wrong or is this a limitation?
Chuck
Hey Nate-
This is awesome, though I was wondering if you could give a quick walk thru of step one for Mac.
Thanks!
Sorry, I didn't see the request for how to run the audio server.
1) Start Spine from the command line with `
server 4567.
Spine.exe
Windows:
server 4567Mac:
/Applications/Spine/Spine.app/Contents/MacOS/Spine
server 4567Linux:
./Spine.sh
server 4567`
2) Download and run the play.jar
file:
http://esotericsoftware.com/files/play.jar
To run it:
java -jar play.jar 4567 path/to/music.wav
You will need to have Java installed.
Bumping this to note that we uploaded a slightly improved play.jar
file. Same link as above. Also in 3.6.11-beta we've made improvements to synching playback, the audio loops with playback, etc.
It may be helpful to create a shortcut that launches Spine with the `
server 4567` argument.
Also, this may help: on Windows, create a new text file called play.bat
and put this in it:
@echo off
cd "%~dp0"
java -jar play.jar 4567 %1
pause
Now you can just drag and drop any WAV file on to play.bat
(Spine should already be running with `
server`) and it will connect to Spine and synch playback with the Spine timeline.
Looks like the manifest in the latest play.jar is broken. To invoke the app, use this line
java -cp play.jar Play