Stuff We Love - Sick of Beige

When Spectacle Labs makes its first million, I will be able to do two important things. One is afford to eat less lentils, and the other is to put some cheques in the post to the awesome open-source projects which are helping make Spectacle Labs a reality. Sadly whilst I'm still living on lentils and cups of tea the best I can manage is a a series of blog posts shouting about why the projects are so great.

First up is Dangerous Prototypes' Sick of Beige, described by Ian from DP in the video above. Now standards are kind of dull right? And I'm not going to convince anyone that the size of circuit boards is a fascinating topic of conversation. So why is a PCB sizing standard in the list of stuff we love? Three big reasons:

  1. Blank slates are bad: There is something incredibly dispiriting about seeing a whole bunch of components which need laying out. Having a fixed PCB size to aim at somehow makes the whole thing seem much more achievable.
  2. Project boxes are bad: Seriously, go to website of any enclosure manufacturer. Feeling inspired to make something? Thought not.
  3. Making things fit in project boxes is bad: The board is too big. Or too small. You need to drill holes for standoffs. Or get something custom made. Putting something in a box has never been so difficult.

For those three reasons we love Sick of Beige, and until I develop a competing standard it will be used in everything we make.

Standards
Standards from xkcd

Introducing... Miles

Miles Davis
Photo: Miles Davis by Tom Palumbo

Over the next couple of weeks I'll be running through a few of the libraries which will form the basis of the first Spectacle Labs board, and giving some quick examples of how they work. First up is Miles, the smallest and most complete library in the Spectacle arsenal.

What is it?

Miles is a C++11 library for representing musical scales and tunings. One of the most common tasks when creating music on a computer is constraining the notes you play to a certain scale, and working within a fixed tuning system. As part of this you need to work out what pitch the notes should represent. Sounds simple? Well, lets look at a seemingly straightforward problem.

What pitch is middle C?

Middle C (C4 for the scientists amongst you) is the fourth C note on a standard 88 key piano. Imagine we start a two-piece piano and electronics band. When you play middle C on your piano and I play it on my computer we want to both be playing the same pitch, otherwise we will sound like a chorus of cats...

But, which pitch should we both be playing? First we have to settle on a base pitch to work from. A common standard is to use the A above middle C as a fixed reference point. In the UK, most orchestras define this note to be at 440Hz (the A440 pitch standard), but in the US and continental Europe 442 or 443Hz is often used.

Once we have decided on a base pitch, we then have to agree on a tuning to use. In most western music equal temperament tuning is used, but non-western music often uses its own mathematically defined tuning systems. These change the relationship between our reference note A and middle C, meaning there are an even wider range of pitches we could be playing.

As you can see, our simple problem of playing a middle C has become increasingly difficult. Our newly formed band could be splitting up over "musical differences" before we've even played a note.

Enter Miles

Miles solves these problems for you by allowing you to specify which scale, tuning and reference pitch to use when working out which pitch to play. The following simple program prints the A major scale from our A440 reference pitch up to A5, one octave higher.

#include <iostream>

#include "miles.h"

using namespace miles;

// Create a major scale
Scale scale = MajorScale();

// Our reference frequency, used as the base frequency of our scale
float A440 = 440.0f;

int main() {
    // Print the A major scale from A440 up to A5
    for (uint32_t i=0; i<8; i++) {
        std::cout << scale.getFrequency(i, A440, 0) << std::endl;
    }
}

If we want to play in a different tuning then we can simply change the scale; for example Scale scale = MajorScale(JustTuning()); would play our scale using Just intonation. Miles has a number of standard scales and tunings built-in, and it is simple to add new custom scales and tunings.

There are more examples and further documentation available on GitHub, and please report any problems or bugs you find on the issue tracker. Hopefully Miles will help to solve your tuning issues and will ensure that your relationship with other musicians is as harmonious as possible.

Hello World!

Hello World

Hi, and welcome to the Spectacle Labs blog! Spectacle Labs is a super new open-source hardware startup based in snowy Leicester. Our first product, which is currently working it's way through prototyping, will involve microcontrollers, bleeping sounds, and code.

Over the next couple of months you can expect to hear plenty more about what we're working on, along with updates following the joy and the heartbreak of embedded software development, techy posts about audio processing which overuse the word 'aliasing', and thoughts on how computing education can be made far more awesome. Thanks for reading, and please don't hesitate to get in touch,either through the comments or by email.