Recently I have been having fun in my spare time discovering how to implement a tcp server / client in Haskell. It’s incredible easy to implement just a couple of lines of code. Building on top of that, today I learned how to implement an http server. Turns out http is just sending and receiving text (and other content) over tcp. As a nice application, I quickly coded a program that given a port and file path starts a web server which will display a webpage with a link to the file which when clicked sends the file to the client’s browser. This is very handy to quickly transfer a file to a friend over a local network. I was impressed with how little code it was needed to implement this in Haskell, and how high level and elegant that code was.
There isn’t a program for playing sound files in Linux which has the functionality that I want: fast, light, play files with any number of channels and 32bit floating-point encoded aiffs or wavs, so I decided to just code my own file player in SuperCollider. I didn’t want to have to start up SuperCollder to use the file player, I was in need of a “standalone”. Standalone is concept from OSX, which is not really use much in Linux. On OSX apps are just a folder with all the files and data inside (except some configuration files in ~/Library) while in Linux apps are usually installed system wide. Since the introduction in SuperCollider of the language configuration system via a yaml file, it’s possible to override which paths get searched for class files, and so kind of emulate standalones in linux too.
A SuperCollider standalone can then be created using the language config file, with the caveat that it has to be generated from a script in order to determine the location of the home folder, in order to disable loading the default extensions folder and class library folder. I have pushed a demo of this to github.
For quick scripts I just place
on top of the file and either run it from terminal or create a .desktop file for it:
So now I have a file player app !
Usually async actions in SuperCollider are dealt with the sync message. A sync message is placed in between each group of commands containing an async command which needs to run before some other future command. An alternative to the sync message is to use the completion messages. This is the mechanism used by the Request monad from hsc3-server.
Today I needed to quickly get some code going to record from the input buses of a server to a file on disk, and I decided to chain the commands via completion messages:
Inspired by the signals provided by elm for mouse and keyboard interaction I’ve revised the corresponding event sources and signals in FPLib and updated them to be usable with ENDef.
- mouseClicksENInputES – EventSource – fires when mouse clicks come in
- mousePosENInput – FPSignal – tracks mouse position. Needs .acceptsMouseOver_(true) on the view.
- mouseIsDownENInput – FPSignal – tracks if mouse is down.
- keyDownENInputES – EventSource – fires when keyboard keys are pressed
- keysDownENInput – FPSignal -tracks the currently pressed keys.
On the 5th of past June a bunch of kids came to the sonic lab of SARC in Belfast for a presentation showcasing some of what we do at SARC. For my presentation I prepared two patches using Unit Lib. One would loop a sample, with a game controller controlling the sample duration and position in the file and panning it in 3D space using VBAP and the 32 speakers of the sonic lab. The other patch used a webcam to track the movement of sphero glowing ball, it would then play a sound whenever the ball “collided” with a virtual object. Also a sound of footsteps would move together with the ball, positioning the sound in the same physical location as the ball. Both patches showcase nicely the interaction of Unit Lib, VBAPLib and FRP from FPLib. The computer vision part was done in processing via the scala language and is available in github. You can see the code below:
Carlos Suárez (GZ) + Miguel Negrão (PT)
One of the goals of Unit Lib is to make using SuperCollider easier. The set of abstractions provided by the main class library of SuperCollider are quite low level (Synth, Group, etc). They require a lot of work to manage the server/client architecture, buses, node ordering, loading buffers, etc. Its possible to simplify these tasks by building higher level abstractions on top of the built in classes. There are many such higher level abstractions, such as JITLib, but the design space is still being explored. With Unit Lib we have quite simplified resource loading, specifically loading buffers, to the point that it has now become a one liner:
Starting the synth will automatically load the buffer. Nifty isn’t it ?
Unit Lib is shaping up to be quite nice for live coding or prototyping, it’s very easy to build guis, specify the specs for controls and connect controllers to it.
Since I’ve moved to Ubuntu Linux I’ve been mostly using btrfs for all my filesystems. btrfs makes it super easy to create snapshots of subvolumes and to go back in time to a previous snapshot (just use mv). I always create a snapshot before updating packages so that I can easily go back if something breaks.
I’ve been using Back In Time for my backups but this app takes more then 30 minutes for every single backup, no matter how small, and does a lot of disk I/O in the process, even just to transfer 2 or 3 files (I think that happens because it’s creating hard links). I’ve recently discovered that btrfs has a send / receive functionality which allows sending a snapshot to another btrfs partition and it also allows to send just the diff between snapshots. Using btrfs send and btrfs receive it’s possible to setup a backup process entirely based on btrfs.
I found that btrfs send / receive is broken in the current ubuntu version 13.04, so I had to uninstall the btrfs-tools package and compile from the source in git of btrfs-progs. After that btrfs send and btrfs receive seem to work fine. I’m now doing all my backups with btrfs which on average now take just one or two minutes, much much faster then with Back In Time.
Finally I created a Haskell Shelly script to automate my backup procedure. It’s still very incomplete, but I put here in case it’s useful to others. Be careful with this script, it might delete snapshots that it shouldn’t so use at your own risk !