Piping to stdout and file simultaneously

Just another note to self here:

./[program] [arguments] | tee [filename.txt]

Run program with arguments, use pipe “|” and the program named “tee” to output do both stdout and a particular file. Great for logging terminal programs.


  • -a Appends the output to the end of File instead of writing over it.
  • -i Ignores interrupts.

Since it’s a GNU-core utility, “man tee” gives a manual of the program.


More Barcodes

I’ve been working more with my barcode application and am finally close to a working solution.

Adding start and stop characters is more or less dependent on which charset you want to use, unless you’re going to use special characters or some other special functionality, you’ll be using Code128 B – which supports most normal alphanumeric characters and punctuation characters in the ASCII table. The rest is just basic String concatenation, which you can do in LibreOffice Calc or through programming.

The first stretch was developing the checksum method in Java, which was pretty easy thanks to the information provided by wikipedia here.

What I did was simply to make an array with the characters listed for Code 128 B, disregarding special characters since I won’t be using them anyway. The array looks a little something like this…

private String code128B_table[] = {
" ","!","\"","#","$"," %","&","'","(",")","*","+",",","-",".","/",
private String code128_table[] = code128B_table;

With the Array in place, all I needed to do to calculate the checksum was write this method:

* Calculates the checksum
* @param input String input for calculating checksum
* @return the checksum in integer form
public int checksumInt(String input) {
int checksum = STARTCODE;
for(int i = 0; i < input.length(); i++) {
int value = charNumber(input.charAt(i));
if(value < 0)
return value;
int position = i+1;
checksum += (value * position);
return checksum % 103;

* Helper function for checksumInt
* Finds the number of the particular character using the Code128B table
* @param c
* @return
public int charNumber(char c) {
for(int i = 0; i < code128_table.length; i++) {
if(code128_table[i].charAt(0) == c)
return i;
System.out.println("Could not find " + c);
return -1;

But wait, there’s more. The checksum itself isn’t enough, it needs to be in the form of a character, but since we already have the table for Code128B in array form, we just convert the integer to character for printing.

* Converts calculated checksum into character
* @param i calculated checksum
* @return character for printing checksum
public char checksumChar(int i) {
if(i < 95)
return (char) (i + 32);
return (char) (i+ 100);

Since the computers come with Norwegian keyboards and the barcode scanner will read barcodes as if receiving keyboard input, I had to do a few cheap hacks to remap the characters according to Norwegian keyboards, this isn’t a problem with alphanumeric data, but characters like { [ ] and } will read on a computer set with  a Norwegian keyboard layout as receiving the letters Æ Ø and Å or some other character because of this, I made a function with way too many if/else tests rather than using a HashMap or other key-value pair since it just seemed simpler to write at the time.

The class file is available on github here.

Beginning Barcodes

About a year ago, I made a bit of an impulse buy on eBay and purchased a barcode scanner for a little less than a dollar (little did I know that shipping and handling would cost me 9 dollars more, but 10 bucks isn’t really anything to worry about).


Why you ask?

Because for some reason I thought it might be a good idea to have a barcode scanner available so I could learn a bit about programming applications using barcodes.

What have I learned so far?

Well there’s a lot of talk on how you need permission to use certain barcodes. Especially EAN and UPC seem to be regulated if you want to distribute your product, but EAN is only the tip of the iceberg.

Some of the simplest barcodes to work with today can be installed as fonts and these include Code 39, Code 93 and Code 128.

But you can’t just download a font and think it’ll work like that – barcodes usually need some way of knowing where to start and stop reading, so the name “Studio Black” would have to be written “ÌStudioÂBlack{Δ to work in Code 128.

Luckily, several websites, like this one, can help translate for you.

So how does this work?

Barcodes are actually an incredibly simple and efficient input method and isn’t really all that different from a computer keyboard. Think of it as a mix between a keyboard and a scanner. When it reads any barcode it supports, your computer will pretty much only act as if it received keyboard input in the form of a string or number.

Some barcodes support alphanumeric data (like Code 39 and Code 128), which means it can contain both text and numbers, while others are simply numeric (like EAN and UPC).

Because of this, programming an application that reads barcodes require next to nothing extra and you can probably just use the same old text fields and forms as always. The USB barcode scanner I have is pretty simple to use and drivers were as easy and automatic as when connecting a keyboard or mouse – just plug and play.

In the long run, the biggest hassle is probably getting familiar with the legal issues of it all.

You can find the fonts for the different barcode systems:

Here: Code 39

Here: Code 93 and

Here: Code 128

As of yet I’ve had the best luck using Code 128, with the type of barcode scanner you can find for about 10 bucks off eBay. My model is called X-9100 and works like a charm.

By the way, make sure to never use bold or italic with barcode fonts, they mess up everything.

Mounting shared folder

mkdir ~/Documents/VBShared


mount -t vboxsf VBShared /home/$USER/Documents/VBShared

Save this as a file, such as “mount.sh”

$ chmod +x mount.sh

$ sudo ./mount.sh

I’m writing this as a reference for every time I make a new Virtualbox guest linux machine

Install guest additions.

Make sure settings have a shared folder set with automount enabled.

Run script at startup.


For systems without an X-Server:

Make sure sufficient packages are installed. Build essential is useful.

Click on “insert guest additions CD image”

sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run


I didn’t know how much fun it would be to play around with orthographic projection once you get the hang of it in Illustrator.

Things I’ve learned:

1. The “polygon” tool makes foor a perfect hexagonal shape, which is pretty much the outline of an isometric square.

2. Just remember isometry is basically a rectangle with 30 90 90 30 degrees angles, and use the shear tool to either 30 or 330 degrees (i.e. 330=-30)

3. It’s quite simple to just make anything two dimensional and then use the “shear” tool using the rule of thumb I mentioned in point no. 2.

4. Isometric projection is a great way to sketch ideas to use for more “realistic” perspectives, since projectional systems using distortion has a tendency to hide and distort details. That way, using orthographic projection makes for a great way of making “visual notes” to use later on.

There seems to be a certain demand for it on iStock even though there are already thousands of files available, maybe I’ll try my luck with a few isometric drawings if my first application as an illustrator isn’t accepted.

Kind of feels like I’m playing Sim City again, only not just playing a game while doing it, but actually working on something productive.

There’s something impersonal about this way of presenting things, you know, reminiscent of technical drawings and whatnot, but then again, I really do enjoy the “video game graphics” feel of isometric perspective.

After I finished this drawing I came to think of the problem of elipses and other difficult shapes and finally found this tutorial extremely helpful:

How to create advanced isometric illustrations using the ssr method

Especially worth noting is scaling everything to 86.602% then shearing according to which axis you want it in (+/-30 degrees etc.). So as a little note to self, 86.602% is worth remembering when working with isometric projection.

Such a long time!

It’s almost half a year since I last said anything here.

Why? Because I’ve just moved back to Norway that’s why – been looking for a job, working part-time at an old job, and collecting, always collecting stuff.

And in the spirit of what I enjoy collecting, I thought I’d comment on what type of drafting equipment I’ve had a hard time getting a hold of.

1. Staedtler Mars Lumograph:

Best artist pencils around, 4H really IS 4H and 8B really is black. From experience I’ve had luck getting them at Akademika in Oslo, as well as I’ve found they sell them at the “Pen Store” in Stockholm. Otherwise they seem to have a meager collection of a few at the Ark book store at Egertorget in Oslo as well as Zinkvit in Uppsala.

2. Rotring and Koh-i-Noor Rapidograph/Isograph:

Probably best bet is to get them on Amazon.

3. Beam compass:

Again, the UK seems to have the best selection of illustration and drafting equipment.

4. Bristol Board:

I’ve actually found a great little Art Supply store in Ski that sells original Bristol Board in A4 and A3. Otherwise, Letraset seems to offer a similar type of paper – only a bit more expensive at stores such as Clas Ohlson and Panduro.

5. Flexible Curves:

Another product I’ve yet only found at the Torso Art Supply store in Ski, how strange to find what your looking for right under your nose while looking far and wide for this stuff.

As for light tables – they sell them in stores now, but at ridiculout prices. Alternatively you could use an old flat screen computer monitor or TV set as a light table, or just get a simple plexiglass plate. Personally I was in luck finding one in the trash one day (that’s 1895 NOK worth of light table for free).

For those of you who live in Scandinavia, I suggest trying out the Swedish ebay: www.tradera.se and search for “passare”, and you might not find a beam compass for sale at all times, but at least they sell some really nice sets for a reasonable price.

I’ve been going through the Cheeseman-Meyer book on Perspective to check for good drafting equipment, as there’s a little list there on practical drawing equipment for descriptive geometry.

I think that’s all for now…


“I Like Motor Oil”

What’s up for today you ask?

Well I’m working on what I feel is my first “real song”, and in the theme of a few of my other tracks available here:

Happy Robot

and here:

Square One

I’m writing about what a robot would sing about if he or she’d be given a voice, of which is possible now thanks to speech synthesis (and as is implied by the picture, I’m using Vocaloid, and the voice known as Sonika).

This is going to be my first Vocaloid and the lyrics go like this:

I like motor oil
I like how it trickles down my cog wheels
I like motor oil
I like how it lubricates my joints

I like motor oil
I like how it minimizes friction
That’s why motor oil
Is why I will never disappoint

And so.

That’s how I work like
perfect clockwork and
that’s how you should
take care of me
oh can’t you see how
I can move with a
perfect groove and that’s how
I shake my shiny metal ass

I like motor oil
I like how it stops me from corroding.
And on every coil
No manner of dust will it omit.

I like motor oil
by now you should know just why I like it
that’s how I can toil
And work as my user might seem fit

And again

Tell me how I may
feel this way and how
that I can know
it makes me glow and
let’s me show how
I’m a robot
with a weak spot
for liquids that gets my body moving.

By the way, I just had a listen online, and it came out rather loud, so I thought I’d write a little warning here.

So here goes! And as mentioned, it’s a work in progress, and an early draft.

      1. Motor Oil

Motor Oil

Tutorial: How to make a basic synthesized drum kit (using FL Studio)

OK then, it’s been a while since I last put anything up here, but seeing as I just might be writing about sound design for the Audio Times ( www.audio-times.com ), as well as seeing as I’ve been very active in the FL Studio forum lately. I thought I’d do a fairly basic introduction to creating percussion instruments using subtractive synthesis.


This time I’ll be using the 3XOSC that comes with FL Studio as it’s one of my favourites and really the «Swiss Army Knife» of Image-Line to make a basic Roland 808 style drumkit.


It should be noted that I will be using a proprietary piece of software known as FL Studio (earlier known as Fruity Loops before they changed their name). FL Studio is one of the leading Digital Audio Workstation applications in addition to being the most affordable and versatile. I have nothing to do with this piece of software other than being an enthusiastic user, but I still think it’s worth mentioning as it’s one of those big “bang for the buck” applications (while Ableton, Cubase, Nuendo and Samplitude are great pieces of software, none can match the price and versatility of the Image-Line line of production tools). You can download the (fully functional) demo HERE.

If you’re an open source enthusiast, I might suggest LMMS, which is today one of the most interesting and powerful pieces of open source production software. LMMS is made for Linux, but could be run alongside Windows either as part of a virtual machine, or using the Wubi (Ubuntu installed as a software application) installation available on the Ubuntu website. LMMS is not only interesting as it’s free and powerful and comes with some very interesting Game Boy synth and SID emulation synthesizers, but also because it very closely resembles FL Studio, and also features a clone of the 3XOSC I will be talking about here.

The  audio demo and tutorial demo .flp file can be found here:


      1. SynthDrums

      2. Click here for download (if you're having problems with flash).

Click here for .flp file


Finally, before we start, I’ve also uploaded this tutorial as a .pdf document if you’re not a big fan of white text on black to be found here: SynthDrumKitHowTo


Part one – The Bass Drum.


Step one:


Start up FL Studio and load the 3XOSC (well duh!).

Step two:

Set all the Oscillators to a sine wave and set the course tuning (crs) knob to the same pitch for all three. You could also use just one oscillator and set the volume of osc two and three to zero, but using all three gives you the option to combine waveforms, which is something we’ll want if we want a more «distorted» bass drum sound.

To set all the crs knobs to zero, simply hold down the alt key while clicking on the buttons, either that or try and turn all the crs buttons to zero, but it takes less time by just defaulting it (which is what you do when you alt click in FL Studio).

Step three:

Click on the instrument property tab of the 3XOSC channel settings.

Step four:

Set the attack (att), release (rel), hold and sustain (sus) knobs to zero. Then right click on the delay (del) knob and set it to «2 steps».

Step five:

Click on the pitch tab and set the attack, release, hold and sustain knobs to zero as well, and set the delay knob to «1 step». In addition to all this – set the amount (amt – the little knob at the far right) to maximum.

Step six:

You now have a basic bass drum patch, but to get the bass drum sound, you will probably have to play somewhere between four or five octaves lower – so to change this, you might want to change the master pitch of the instruments four or five octaves down (that is right click four or five octaves higher up than where the orange light is to make it lower).

I find setting it five and a half octave lower often does the trick (notice I set it to G rather than C).

And there’s your bass drum.

Now to change the timbre of the drum you could:


1. Change the waveform of one of the second or third oscillators to triangle or square to make the drum a bit more distorted.

2. Add a weak distortion to the drum using the Fruity Fast Dist, Hardcore, or using a bitcrusher like dBlue Crusher (freeware vst)

3. Put it through a compressor such as Fruity Compressor, Fruity Limiter, Maximus or Soundgoodizer (Soundgoodizer is great for adding a bit of «color» to the sound).

4. Equalize it (which is fairly obvious – equalizing the sound is particularly useful when designing any sort of percussive sound).


Part two – The Tom-Toms.


To create tom toms, simply experiment with the delay of the pitch and volume envelope and make it slightly longer – then change the master pitch of the instrument or just simply play notes higher up on the keyboard.


If you want a 70s lazer sound, all you need to do is experiment with the delay again and play even higher notes than that of the tom-toms.


Part three – The Snare Drum and Hi Hat.


If you followed the steps for creating the bass drum part one to four, all you really need to do is change the waveforms to white noise (the waveform right next to the question mark ( ? ) waveform). Then experiment with the delay.


The rule of thumb is basically that the delay of the snare should be slightly longer than the hi-hat.


To add colour to the hi-hat sound you might experiment with filtering it and/or equalizing it. You could use the resonance button (also known as modulator y within the 3XOSC) to make it slightly more metallic.


Putting it all together.


To make a beat you could simply use the step sequencer interface or you could set up a layer, set all the different 3XOSCs as children, then click «split children» in the layer properties and you now have a drumkit ready to use within the Piano Roll.


The drums in this tutorial will sound rather synthetic, which is why they’re perfect for any kind of lo-fi music. All you need to do to make it sound like a «Game Boy» drumkit is to set all the synths through a bitcrusher and there you go.



Weekend at the internets

I just realized I’ve spent the whole weekend trying to polish up on the WordPress theme here (the layout of the page) – and I haven’t even started looking that much into code functionality. As of yet, I’ve been able to make this theme:

  • Widget friendly
  • Plugin friendly
  • Able to change website name and description using the Settings panel in the WordPress dashboard.
  • Make admins able to edit individual pages with an “Edit” button below each post and page.
  • Featured permalinks both in title and seperate “Permalink” button for each individual post.

Yet still I have to admit I’ve spent most of the time fixing up CSS – recent changes involving.

  • New background (not just the clock, but cogwheels and whatnot further down the page for a bit of variation)
  • Styled Links to make things look cleaner and without all the underlines and everything.
  • Changed brightness of background as well as “window” density with a 85% transparent background for content instead of just 70 like it used to.
  • Changed caption formatting.
  • Removed published-dates for pages, so that it only shows for individual posts.

PS: I’ve also made an alternate version of the theme with inverted light colours, available HERE!.

Lorem ipsum


“Lorem ipsum dolor sit amet, consectetur adipiscing elit. In mauris nisi, lacinia bibendum semper id, euismod sed ipsum. Nunc nibh mi, euismod id ultrices eu, posuere eget lorem. Proin ac orci tortor. Nam porta felis in neque tincidunt dignissim vel bibendum justo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque blandit diam in metus sollicitudin sagittis. Pellentesque a mi vel magna lacinia pharetra sit amet vitae sem. Aliquam erat volutpat. Integer blandit, nibh ut dignissim elementum, nibh lectus vestibulum nunc, id dignissim dolor turpis et risus. Nulla ut dapibus massa. Aliquam lectus nisi, tempor in aliquet eu, consectetur vel odio. Fusce vitae lorem purus.”


So what’s all this Lipsum about?

And that short post stating the layout is finished?

Well, thing is – I finally got around to learning enough about developing WordPress themes to make my own, and this “proof of concept” (the concept being that I – with no previous experience with PHP (and still no considerable understanding of PHP apart from a general understanding of HTML, CSS and Perl) will be able to make my own WordPress theme) being the result of several days of “hard” labour trying to make this work.

So how did I do it without really knowing all that much PHP?

Well – the good thing about programming and markup languages is that once you know at least parts of one, you can pretty much get along using logical reasoning to get by – especially with a bit of cutting and pasting from the WordPress documentation pages as well as using simple themes as models.

Hopefully this theme will be able to be released for the general public – that is: the WordPress theme database if they chose to accept it (I probably have a lot of cleaning up to do with the code and everything), but for now, I think I’ll add a download link … HERE.