I wanted to get coordinate remapping in before a release candidate, unfortunately I can’t seem to make it happen so the device will have one specific orientation that it will need to be placed in for it to work correctly (if you can help me with this then please don’t hesitate to contact me!).
You can edit the way the filtering/scaling is done by modifying “/lua/default.lua” and “/lua/scale.lua”, the one I used in the video is EWMA filtering, so you can use that by backing up “/lua/default.lua” and renaming “/lua/ewma.lua” to “/lua/default.lua”.
Over the past few weeks, I’ve been experimenting with FreeTrack and the gyroscope built into my phone (Galaxy Nexus); if you attempt to pipe the orientation obtained from the device straight into a FreeTrack compatible game, you will end up with a shaky and temperamental camera that isn’t quite sure where it wants to go (gyroscope drift + correction using the magnetic field) as seen here:
You can just slap a moving average on, but it results in undesirable input lag. Over the past week or two, I’ve been continually improving the algorithm to smooth the input, yet keep it snappy with as little input lag as possible; right now it is around 66ms input lag, which is almost unnoticeable when playing. Currently, the camera does not drift with slow movements, yet it does not loose sync with the true orientation, plotting this, we can compare a previous attempt with the current one:
Blue is input, and red is output; you can see that there is very little input lag and the latest one does not drift away, yet does not become out of sync; this keeps you immersed in the game without anything distracting you.
A limitation that should be noted when compared to other similar devices is, this does not have movement, only orientation.
Here is me using it when I’m in Arma 2 flying the Apache:
As you can see, this requires mounting your phone to your head some way; I’ve done it with velcro.
int main() {
int t;
for (t = 0;;t++) {
putchar((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7));
}
}
and you’ll get pseudo-random gibberish, but pipe the output of the same program into a 8-bit 8kHz pcm sound device and you’ll get something not far from a chip-tune symphony. There’s been a recent trend in the demoscene community of making simple, short programs that produce surprisingly complex music. Now, I don’t have anything for the hardcore demoscene artists who want to fit a techno song in a 12 byte program, but I do have something for those who want to experiment with algorithmic music.
Bit Orchestra is a tool for quickly testing and prototyping expressions for create interesting noises (and sometimes even music!). It has some helpful music related functions and allows you to hear the output immediately. You can download Bit Orchestra here (sorry, Windows only, at the moment at least) or view the (MIT-licensed) source here. Once you’ve download it, load and try out the included samples.
I was looking for a way to do this not to long ago; I came across some examples that used a third party libary and was over complicated, so I created this class based of one of MSDNs examples.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Packaging;
using System.IO;
public class ZipSticle
{
Package package;
public ZipSticle(Stream s)
{
package = ZipPackage.Open(s, FileMode.Create);
}
public void Add(Stream stream, string Name)
{
Uri partUriDocument = PackUriHelper.CreatePartUri(new Uri(Name, UriKind.Relative));
PackagePart packagePartDocument = package.CreatePart(partUriDocument, "");
CopyStream(stream, packagePartDocument.GetStream());
stream.Close();
}
private static void CopyStream(Stream source, Stream target)
{
const int bufSize = 0x1000;
byte[] buf = new byte[bufSize];
int bytesRead = 0;
while ((bytesRead = source.Read(buf, 0, bufSize)) > 0)
target.Write(buf, 0, bytesRead);
}
public void Close()
{
package.Close();
}
}
You can then use it like this:
FileStream str = File.Open("MyAwesomeZip.zip", FileMode.Create);
ZipSticle zip = new ZipSticle(str);
zip.Add(File.OpenRead("C:/Users/C0BRA/SimpleFile.txt"), "Some directory/SimpleFile.txt");
zip.Add(File.OpenRead("C:/Users/C0BRA/Hurp.derp"), "hurp.Derp");
zip.Close();
str.Close();
You can pass a MemoryStream (or any Stream) to ZipSticle.Add such as:
FileStream str = File.Open("MyAwesomeZip.zip", FileMode.Create);
ZipSticle zip = new ZipSticle(str);
byte[] fileinmem = new byte[1000];
// Do stuff to FileInMemory
MemoryStream memstr = new MemoryStream(fileinmem);
zip.Add(memstr, "Some directory/SimpleFile.txt");
memstr.Close();
zip.Close();
str.Close();