JavaScript in Max/MSP/Jitter
Saturday April 22nd 2017, 7:56 pm
Filed under: Realtime
"use strict";

// ~ ~ ~ these variables are built-in ~ ~ ~
inlets = 3;
outlets = 3;
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

var nowTime = 0;
var lastTime = 0;
var deltaTime = 0;
var timeCounter = 0;
var timeMax = 10;
var firstRun = true;

// ~ ~ ~ these functions are built-in ~ ~ ~

// this runs when the object is first loaded
function loadbang() {

// this runs each time the object receives a bang
function bang() {
    if (inlet === 0) {
    } else if (inlet === 2) {

// this runs when the object receives a float message
function msg_float(data) {
    if (inlet === 1) {
        timeMax = data;
        outlet(1, timeMax);
        post("new max: " + timeMax.toFixed(2));

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

function init() {
    if (firstRun && typeof jsarguments[1] === "number") {
        timeMax = jsarguments[1];
        firstRun = false;
    nowTime = new Date().getTime();
    timeCounter = 0;
    outlet(0, timeCounter);
    outlet(1, timeMax);
    outlet(2, bang);

function update() {
    lastTime = nowTime;
    nowTime = new Date().getTime();
    deltaTime = (nowTime - lastTime) / 1000.0;
    timeCounter += deltaTime;
    if (timeCounter < timeMax) {
        outlet(0, timeCounter);
    } else {
Comments Off on JavaScript in Max/MSP/Jitter

Blender Keyboard Shortcuts
Sunday November 06th 2016, 10:13 am
Filed under: Blender

I find the default keyboard shortcuts in Blender very frustrating. Here are a list of changes that I prefer, adapted from Nimble Collective’s excellent video tutorial.

Step 1.
File > User Preferences > Input > …

Step 2.
Select With: Left

Step 3.
3D View:

  • Rotate View: Alt-Left Mouse
  • Move View: Alt-Middle Mouse / Alt-Cmd-Left Mouse
  • Zoom View: Alt-Right Mouse

Step 4.

  • Pan View: Alt-Middle Mouse / Alt-Cmd-Left Mouse
  • Zoom 2D View: Alt-Right Mouse

Step 5.
Image > Image (Global):

  • View Pan: Alt-Middle Mouse / Alt-Cmd-Left Mouse
  • View Zoom: Alt-Right Mouse

Step 6.
Search Box: [loop select] > Mesh > Loop Select:

  • Select: Double Click

Step 7.
File > Save Startup File

Comments Off on Blender Keyboard Shortcuts

MIDI Over a Network (Win)
Friday November 04th 2016, 7:01 am
Filed under: Midi

Windows doesn’t come out of the box with support for MIDI over a network, but you can add it with Tobias Erichsen’s rtpMIDI driver.

Comments Off on MIDI Over a Network (Win)

Inter-Application Midi (Win)
Friday November 04th 2016, 6:35 am
Filed under: Midi

Windows doesn’t come set up out of the box for inter-application MIDI, but the capability can be added with free software. The process has gotten more complicated, however, on recent versions of Windows.

Step 1. Download the MIDI-Yoke driver.

Step 2. Right-click on the installer and choose Troubleshoot compatibility.

Step 3. Click Test the program. Unintuitively, this will actually perform the installation.

Step 4. Reboot.

Step 5. Sign up for the Coolsoft MidiMapper beta program.

Step 6. Download and install the MidiMapper beta utility.

Step 7. Choose a MIDI-Yoke port using the MidiMapper to enable inter-application MIDI.

Comments Off on Inter-Application Midi (Win)

Raspberry Pi Setup
Friday October 14th 2016, 6:13 am
Filed under: Raspberry Pi

1. Current lineup is:
* $20 for RPi A+ (1 x 700MHz, 256MB RAM)
* $40 for RPi 2B (4 x 900MHz, 1GB RAM).
They both have the same GPU, but the 2B is by far the best value because you can assign the GPU much more RAM. This guide is for a 2B with at least 8GB storage.

2. Basic RPi 2B kit with power supply, case, SD card, wifi dongle, and some cables can be had for $60-70. I used a Canakit. Generally cheaper than acquiring each accessory separately. Good for a fast first-time setup; if you need to, you can invest in better components later.

3. Some useful hardware accessories; a compatility list is maintained at …
* faster SD cards can greatly improve system performance.
* The image quality of the in-house PiCam camera accessory isn’t exceptional, but with a direct bus connection it’ll run faster than third-party USB cameras. It also comes in an infrared version.
* An HDMI dummy dongle fools the OS into thinking a monitor is connected, which can speed things up when running headless and sharing the main display.

4. NOOBS is the boot utility, Raspian is the OS. If your RPi didn’t ship with a preformatted SD card, you’ll need to install it yourself from … Default install settings are fine.

5. The first time you set up, you’ll need a keyboard, mouse, and monitor. (Well, strictly speaking the mouse is optional.)

6. First thing, run sudo rpi-update (firmware) and then sudo apt-get update/upgrade.

7. Then run raspi-config:
* Change the default password
* Enable ssh
* increase GPU memory to 1/4 of total (if working with graphics). You can go higher by editing the config file …
* Change hostname (don’t use an underscore, or you’ll have to fix the hostname by editing the config files … and … )
* Enable camera, if you have one.

8. Wifi will not autostart the first time. Add auto wlan0 to config … now it will try wifi at boot.

9. If you’d like to preload ssids to connect to, enter them into the config file …

10. Reboot and test your network connection and ssh.

11. Install vnc server. Most guides use tightvncserver, which lets multiple users connect to their own desktops but can’t share the main screen. For most cases x11vnc, which shares only the main screen and runs much faster, is a better choice;

12. Add lines … to config … so vnc will run on boot.

13. Reboot and test vnc.

14. To connect headless more easily, you can set a static IP. Or if you have access to your router, you can reserve one for the Pi’s ethernet or wifi MAC address.

15. Right now, no popular RPi VNC viewer will let you view OpenGL graphics–apps will run, but the window will be invisible to you. To work with OpenGL you’ll need a monitor connected.

16. Vnc without a firewall is extremely insecure; even if you keep nothing of value on the RPi, it could still be used to attack your network. So install ufw.

17. Before starting ufw, tell it to allow the ports you’ll be using–for example, 22 and 80. (But don’t allow the unencrypted VNC port, usually 5900 or 5901–we want to block that!) You can also tell uwf to allow all ports on a trusted local network.

18. Start ufw. If you get something wrong and lock yourself out, connect a keyboard, mouse, and monitor and check ufw status. If you get stuck you can always disable ufw; it’ll stay off until you enable it again.

19. Reboot and confirm that you’re asked for your user and pass when you start a VNC session over SSH.

20. Reboot once more and confirm that everything’s working. Now you can disconnect your keyboard, mouse, and monitor and run your RPi headless.

21. Hard part’s over. Next, add some software tools, for example:
* Btsync
* Gphoto
* ffmpeg
* imagemagick
* PureData

22. Finally, set up dev environments for your favorite programming languages. The RPi comes with Python, but here are some more options:

* JavaScript:
Sublime Text

* Ruby

* C++:

* Java:

Comments Off on Raspberry Pi Setup

Clone Your Windows Boot Drive
Friday October 14th 2016, 6:11 am
Filed under: Windows

I. Prepare the New Disk
1. Connect your new disk as a secondary disk.
2. In DiskManager, create a 200MB hidden NTFS partition (no drive letter) on your new disk.
3. Right-click the hidden partition and mark it Active.
4. Then create a regular NTFS partition (with drive letter) filling the rest of the space.

II. Clone Old Disk to New
5. In DriveImage XML, choose Drive to Drive or Restore and clone your disk. Ignore warnings.

III. Make the New Disk Bootable
6. Create a Windows Recovery disk (CD / DVD / USB).
7. Connect your new disk as primary disk and boot from the Windows Recovery disk you created.
8. Try automatic repair.
9. If automatic repair fails, open the Windows Recovery command prompt and navigate to:
10. Type:
bootrec /FixMbr
bootrec /FixBoot
bootrec /RebuildBcd
…the last command may give an error but you should still be OK.

IV. Cleanup
11. Scan your new boot disk for errors.
12. If the cloned disk complains about not having a genuine version of Windows, open a prompt as Administrator and type:

Further Reading:

Comments Off on Clone Your Windows Boot Drive

Types of Anti-Aliasing
Tuesday September 22nd 2015, 12:06 pm
Filed under: Concepts

1. FXAA (Fast Approximate): Post-processes the final rasterized image to smooth edges. Very fast but poor quality, adding blurriness. Aka MLAA (Morphological).

2. SMAA (Subpixel Morphological): Like FXAA, but compares across multiple frames. Substantially reduces blurriness at a modest performance cost.

3. SSAA (Super-Sample): Renders the scene at a larger resolution and downsamples. High-quality with no artifacts, but extremely slow. Aka FSAA (Full Screen).

4. MSAA (Multi-Sample): Detects the edges of geometry, renders only those areas at a higher resolution, then downsamples. Good balance between speed and quality but sometimes has inconsistencies between frames; hardware support can be limited. Aka EQAA (Enhanced Quality), CSAA (Coverage Sample).

5. TXAA (Temporal): Like MSAA, but compares the edges of geometry across multiple frames, delivering greatly improved quality with comparable performance. However, currently has extremely limited hardware support.

Comments Off on Types of Anti-Aliasing

Motion Capture: Kinect 1 vs. 2
Sunday February 08th 2015, 11:40 am
Filed under: Kinect

The Kinect 2 is supposed to have superior skeleton tracking, so I tested it against the Kinect 1 in a single-camera setup of iPi Studio.

Conclusion: a single camera is always going to have trouble when the actor doesn’t face front, so both tests show obvious glitches. However the Kinect 2 does seem to capture more subtle movements.

Kinect 1 is purple, Kinect 2 is green:

Download FBX files.

Comments Off on Motion Capture: Kinect 1 vs. 2

Scanning Clay Models
Monday September 08th 2014, 8:08 pm
Filed under: Kinect

Step 1. Build a model with armature wire and air-drying clay.

Step 2. Scan… (to be continued)

Comments Off on Scanning Clay Models

Safe Mode in Windows 8
Friday January 10th 2014, 11:45 pm
Filed under: Windows

In earlier Windowses, if you pressed F8 at boot time, you’d go to a special “Safe Mode,” which was very useful for repairing a damaged install that otherwise wouldn’t boot. Safe Mode still exists in Windows 8, but it’s disabled by default. To enable it:

Step 1. Run a Command Prompt as Administrator.

Step 2.Type:

bcdedit /set {default} bootmenupolicy legacy

That’s it! Pressing F8 at boot should now bring up the traditional Safe Mode menu.

Comments Off on Safe Mode in Windows 8