Monday, October 7, 2013

Skeleton Tracking - v1.0 Complete!

I've finally gotten the spatial audio + skeleton tracking model to work! After struggling with hosting the html webpage from webpy last week I realized I was overthinking the problem and could just host the html file on the same C# server by merely having C# read my html file and print the text to the screen. I got this working easily however two things were wrong, first, the mime-type was defaulting to text/plain and second the files I was including were erroring. The first thing wasn't really a problem, at least at the moment, because chrome still treated the text like html. The second problem was being caused because unlike with webpy, the C# server doesn't have a concept of a "static" folder so my requests for "static/jquery" etc. were just hitting the web server and receiving no response. I added responses for my jquery include but then realized I'd hit another issue with the cauldron file. Cauldron.wav needs to be sent as binary data and the vanilla C# web server I took from David's blog only provided string responses. At this point in time I also decided it'd be a good idea to go ahead and bundle all the files in Visual Studio so I added them as resources and could eliminate the need to open a file reader to them and have extra files to keep up with. VS Studio resources are quite easy to deal with and the index and jquery include were both stored as strings. The .wav file was stored as the datatype "UnmanagedMemoryStream". Using the .Read() method of a UMS I was able to write the byte data to a buffer. Then, I modified the C# server to pass the response method the actual response object which allowed me to do two things: 1) write byte data to the response 2) change the mime type. Thus I was able to respond to the request for the .wav file in binary format and also fixed the mimetype all 3 files. I came across this useful mapping of common extensions to mime types.

Additional changes I made to this first version of Skeleton Tracking were:
- Allowing for the starting/stopping of the server independent of the form (I had a button before but "stop" actually closed the server)
- Set the server to automatically start when the program does
- Renamed the major components of the program to "SkeletonTracking" instead of Microsoft's sample name since I have been directly modifying their skeleton tracking sample.

One final thing to note is that the webpage reading the kinect data is not actually using the filtered version of the data but the raw, noisy data. It didn't appear to have any affect on the spatial quality of the sound so I will leave it for now.

A video with audio and commentary is coming soon.

No comments:

Post a Comment