Wednesday, 25 November 2015

Making sweet things sour with Miracle Berries

After watching Dara O'Briain on BBC's Tomorrow's Food, I was reminded of something I'd seen a few months ago and fancied trying out.

It wasn't the "electronic taste simulator" (which looked like nothing more than an Arduino Mini and a metal plate)

It was the article about "Miracle Berries" - those funny little red things that make sour things taste sweet. I first heard about them on Radio 4 (where else) about 9 months ago, and thought "they sound fun". And then forgot all about them. Then they appeared on the telly a few months later, and thought "I wonder where you could get those from?" and promptly forgot about them.

Then, after seeing the programme on BBC, and in a fit of spontaneity, I ordered some miracle berry tablets off the interwebs.

Despite what the various special offers in my email inbox say, it's the first time I've bought any tablets of any colour, red, blue or otherwise, off the 'net. And it is a bit risky - not just from a financial point of view (ten quid for ten little tablets is a gamble in itself) but also from a safety point of view - who knows what is actually in these things??

But curiosity got the better of me, so I bought some and they arrived today.
With some trepidation, I tried one of the little red pellets. The basic idea is not to gulp them down like paracetamol, but to let them dissolve and coat your tongue with the slimy red goop.

Nick also gave one a try (after all, if it was going to make me poorly, I didn't want to be the only one suffering stomach cramps and vomiting!) and together, and with some hesitation, we tried some of the sourest, most acidic things we had in the house.

Amazingly, the little berries actually worked!
Maybe it's because ours were in tablet form, rather than freeze-dried berry form (the berries themselves perish very quickly and can only be bought "fresh" if delivered in dry ice - an extra expense we deemed unnecessary just to try out something so frivolous on a whim) but the sweetening effect had a bit of an after-taste to it.

The sweetness was almost like an artificial sweetener - like putting too much Stevia, or Canderel (other artificial sweeteners are available) on already sweet food (like perhaps breakfast cereal). But the effect was amazing!

You can eat fresh limes like you would tangerines. You can bite lumps out of lemons, like you would an apple (apart from the skin is a lot tougher of course!). Normally sharp oranges taste really smooth and sweet (but normally sweet tangerines tasted a bit artificial and sickly!)

On super-sharp fruit, like lemons and limes, the effect is most pronounced, but also most peculiar - you can still tell you're tasting something "sharp" - it's more like a tartness than a sourness. But there's none of the screw-up-your-face nastiness that usually accompanies sour acid tastes.

Balsamic vinegar tastes amazing - almost like cherries. Cider vinegar tastes like slightly-tart apple juice. Carrots - never my favourite vegetable - taste sweet, instead of slightly soapy. Cheese however, just tastes weird.


The effects of the tablets last about 30 minutes. After this time, lemons are still edible, but taste a little sour. After 45 minutes, just about everything we'd tasted - deliberately under-ripe fruit and supermarket-flavourless veg - was unbearable in anything but the tiniest amounts.

Miracle Berries are ace. And (unlike a few of the last ideas listed on this blog) they work!

Silicone moulds for resin casting

After leaving to fully cure overnight, we turned out our test moulds. As the fingerboard was only held in place with a few strips of double-sided tape, it was easy enough to remove from the backing board

And when the master was removed, we had a very impressive looking mould. Sure, there are a few bits of burnt mdf stuck to the silicone, but we're pretty confident that these will come off with the first cast or two, made with our two-part resin (and if it doesn't, it's not likely to affect future casts either)

Our little test miniatures look promising too

After removing the play-doh and a little cleaning up with a knife tip

Unfortunately we forgot to add in some "pouring channels" with the front half, so we'll add them in before adding the back half of the two-part mould

The idea is that when fully cast, the two part mould will have two channels running from what will become the top of the mould - the first being a channel into which we'll actually pour the resin, the other being a vent to allow air to escape as the resin fills up the mould.

Now we just need to make up some more silicone rubber for the second half of the two-part moulds, and we'll be ready to actually start some casting.

We're holding off just because when we mix up a batch of resin for the guitar neck, we'll be able to try out our two-part moulds with the excess (there's always excess, since we always manage to mix up too much, for fear of not making enough!). Our polyurethane resin is also pretty stinky, so it's not something we want to have hanging around the place - we'll mix it up, pour it and let it go off overnight, at the unit, so the smell doesn't upset anyone while it's going off!

Tuesday, 24 November 2015

More silicone mould making for resin casting

We've been busy trying lots of different ways of creating a translucent fingerboard for our guitar fretlights electronic tutor project. By far the best result to date has been resin-casting except we want to be able to add our guitar fret-wire to the fingerboard after it has been cast/created.

Our first mould was made from an entire fingerboard, lifted off a guitar neck. It was complete, including frets. It was also a peculiar size - not quite 25.5" scale length, with a massive 24 frets, and a super-skinny nut width of just 41mm.

Our kit guitar has a 25.5" scale length neck, 21 frets, 46mm across the nut and 54mm at the 21st fret. A pretty "standard" fingerboard layout. So we made a "blank" of the fingerboard out of mdf, with slots to accept the fret wires, radius-ed it to 13.5" (using a home-made sanding block) and prepared it for silicone casting.

To help reduce the amount of silicone needed (it's pretty expensive stuff!) this time we made the box a bit tighter around our blank.

And because there's always a little bit of silicone left over when doing these kind of jobs, we stuck a couple of "Blood Bowl" miniatures into some Play-Doh to have a go at two-part resin casting. Blood Bowl miniatures are quite expensive on eBay, so we might get away with casting a couple of the ones we'd previously bought, just to bulk out a few teams (that's right, we've not given up on the electronic board game idea - just working on a couple of other things alongside it at the minute!)

(a glass bowl is great for mixing the silicone rubber - once we've scraped out as much as we can, simply leave it to cure, then peel the excess/waste away from the glass in the morning!)

The silicone is now mixed and poured and we're just going to leave it overnight to ensure it's cured fully before turning out the moulds.

Sunday, 22 November 2015

Making a curved acrylic fingerboard

While waiting for the casting materials and resin to arrive in the post, we thought we'd spend the intervening time trying out yet another idea; pre-curving the acrylic sheet before laser cutting it. We'd already trying laser-cutting acrylic and shaping it through heating, but the result was less than satisfactory. Well, the end result was more like the acrylic had never been shaped in the first place!

So what we reckoned we needed was a large-radius shape, over which we could form our entire sheet of acrylic before laser cutting it. Then once the entire sheet was nicely curved, we could cut the plastic into strips (each strip being up to 60mm wide, so only having a tiny part of the large radius on it) and then laser cut each strip as required.

This meant making a large, 27" diameter curved surface. A drum would be too large and cumbersome, so we set about creating a quarter-curve.

The first thing to do was cut out some 13.5" radius (27" diameter) curves from mdf. We created two lots of curves - one lot with an outer diameter of 27" and one lot with an inner diameter of 27".

We then glued the strips with the outer 13.5" radius to a sheet of thicker mdf, mirrored the whole design onto a second thick sheet of mdf, and then connected the two sheets with some strips of scrap pine, to act as cross braces.

With the two sides in place, it was simply a case of bending some 2mm thick hardboard (shiny side out) over the structure. To hold the board in place, we glued the strips with the inner 13.5" radius over the edges of the curved hardboard.

Lastly, we fixed a strip of mdf along the front of the curve, at the bottom. This would allow us to "wedge" our sheet of acrylic in placed before forming.

Simply using a heat gun we allowed the weight of the plastic, once heater, to get it to lay against the curved structure (originally we attached a wire and used weights to pull it down, but this kept pulling the sheet out of the "clamp" so we let gravity do the work for us!)

The idea seemed to be working fine. The heat gun caused the plastic to go nice and floppy, with deforming it too much, and the acrylic lay perfectly along the curved shape.

But then, as the plastic cooled, it started to twist and contort. We added weights again, to try to hold the plastic down, while it cooled, but with little success at obtaining a nice, smooth, uniform surface.

The finished result was a curved piece of acrylic sheet. But the curve was not consistent either across the sheet, not along it. Out of the entire sheet, we might - if we cut it into strips at about 75 degrees across the sheet - get one or maybe two usable pieces. That's an awful lot of (expensive) waste, with no guarantee of getting a usable piece if we tried the same process again.

All in all, another one for Steve's "wak-wak-oops" button he's been threatening to build.

Thursday, 19 November 2015

Optimising MIDI-based guitar tablature

Creating guitar tablature from MIDI files is great. But sometimes the results are less than optimal. For example, you might be playing a lead riff high up the guitar neck, when suddenly the MIDI-derived tab puts you back down on the first or seconds frets, mixing it up with some nasty open strings. Open strings when playing licks is seriously uncool! (unless you're playing rockabilly, in which case it's double-awesome).

Here's how our MIDI-to-tablature routines are drawing some chords from the tune "Need Your Love So Bad". Nothing fancy or clever, just some simple triads.

The first chord is the higher notes of a regular A major "open" chord.

(the full A major chord is shown, and the notes displayed in our midi-derived tab appear in red)

Similarly just by looking at the derived tab, we can also see the "higher" end of a regular D major chord, with the frets 2-3-2 held on the high E, B and G strings. But what if playing the open A chord isn't convenient? Wouldn't it be great if we could move these notes and put them on other frets (while maintaining their musical pitch values?)

A bit of javascript later, and that's exactly what we've got!
Basically, when you click on a number in the tab, the javascript looks at the fret number and tries to add five (four if the note is on the B string). If this sum total is less than 21 (the maximum number of frets on our guitar) it puts the note on the next lower string, and increases the fret value by five (or four if jumping from the B to the G string).

This means that our A chord can also appear like this:

Here we can see that the 5-6-7 variation of the A major chord is simply the "middle" of a barre chord at the fifth fret:

Likewise, where we've been clicking about with some of the D major chords on the next line, we can see that 2-3-2 becomes 2+5 = 7 and 3+4 = 7 and 2+5 = 7. As it turns out, this is the middle-finger barre on an A-shape barre chord at the 5th fret - exactly where you'll find your A-shape D major chord!

And when we take these values one string lower, we get 7+5 = 12 and 7+5 = 12 and 7+4 (since we've moving off the B string to the G string) = 11.

And when we plot these onto a guitar neck, we can see we're looking at an E-shape barre chord at the 10th fret - another well-known place where you'll find a D major chord!

So not only have we successfully parsed a MIDI file and been able to place all the "on notes" on the correct frets/strings on our guitar tablature, we've also got a really easy way of allowing players to choose alternative positions/finger placements for each note - either individually, or shift all of the notes to move an entire chord into a new shape.

Very exciting stuff!

Monday, 16 November 2015

Shaping acrylic for a guitar fingerboard

Putting the whole make-a-mould-a-cast-a-resin-fingerboard idea to one side for a moment, we thought we'd try a slightly different approach. It's bad enough that every idea so far has been greeted by one of Steve's "wak-wak-oops!" sounds. So it's time to do a little bit of investigating, and trying out a few different ideas.

This time we thought about adding a slight curve to a piece of acrylic, then laser cutting the fingerboard shape from the curved piece. Instead of cutting across the entire width of the fingerboard, we'd cut slots into it, to retain a single piece of acrylic.

It's quite possible to buy fretwire that is already cut to length, with fret tangs cut back from the very edges of the wire.

So it makes sense that we cut slots into the fingerboard, instead of cutting it into sections, which then need to be glued together.

Since a 13.5" radius curve only adds about 1.2mm to the height of the fingerboard at it's highest point, we're pretty confident that a laser that can carve through both 3mm and 5mm acrylic in a single pass should be able to cope with variable thickness material - especially since the variance is only between 3mm and 4.2mm thick.

With all this in mind, after pizza at BuildBrighton, and while the oven was still hot, we set about shaping a strip of 3mm acrylic, to see how it might work. Using our original sanding block for the curve, we put some acrylic on top and put the whole thing in the oven.

Things looked very encouraging at first. Then as the plastic cooled, something a bit peculiar happened.

While warm, the weight of the acrylic was enough to encourage it to "settle" into the curved form, while it was quite pliable. But as the acrylic cooled, it started to lift in the middle.

It became obvious that we'd need to clamp this (using the negative of the shape that we created to hold the mdf together when it was originally PVA-glued together). Using the positive and negative designs from earlier sanding blocks, we heated the acrylic with a hot-air gun and clamped the slightly floppy acrylic between the two pieces.

Once the strips of acrylic were set, we took them to the laser cutter to carve some shapes out. We put the laser cutter speed up to 300mm/sec, 10% power and scorched the outline of our fingerboard shape into some scrap mdf. The curved acrylic was then placed over the template and the shape cut at the "proper" speed.

The final fingerboard looks very encouraging. But whether or not the laser cutter had an effect, or whether it was the acrylic "relaxing" after cooling, but the laser-cut acrylic looks almost flat! It doesn't look much different to when we cut the same shapes from a sheet of flat acrylic - which left us wondering whether the whole "heat-up-the-plastic-and-curve-it-to-shape" approach had been a whole waste of time!

While that still remains to be seen, we've just taken receipt of some pre-cut fret-wire; so at the very least we should be able to create a playable surface - even if it doesn't have an inbuilt radius.

Sunday, 15 November 2015

Creating a web-based php MIDI to tablature system

A few days ago we managed to crack the secret behind parsing MIDI files - namely how to deal with variable length values (and bit-shifting seven instead of eight places left when multi-byte values were encountered).

We spent a bit of time reading through our midi files, which returned something like:

delta 183749 [4] note on 64
delta 183749 [4] note on 61
delta 183749 [4] note on 57

delta 184861 [4] note on 64
delta 184861 [4] note on 61
delta 184861 [4] note on 57

delta 185972 [4] note on 64
delta 185972 [4] note on 61
delta 185972 [4] note on 57

and using a MIDI note look-up table re-wrote the clusters of notes as their equivalent note names.
Where groups of notes share the same "delta time" they are all played together, as a chord (rather than individual notes).

So we looked up note 64 and found it was an E
Note 61 is a C# and note 57 is an A.

From simple music theory, we can work out that this is an A major triad. And looking back at some known tab for this particular song (Need Your Love So Bad) we can see that the song does indeed begin with an A major chord.

We checked a few other note combinations, later on in the MIDI file and found that they do indeed correspond to other chords throughout the song sequence. Yay! We're reading the midi files correctly.

But where to go from here?

TablEdit is a great program for converting MIDI files into readable guitar tablature. So we took a single track from our multi-track MIDI file and imported into TablEdit. It looked something like this:

We're just focussing on the first few chords to begin with

And in our php code, we loop through our midi note/time code values to see which notes appear where. When we find a bunch of notes that make up a chord (the same principle even applies to single notes, but this approach also works well for two or more notes played at once) we (bubble) sort them so that the highest pitched note comes first.

Now for an assumption. When playing guitar, particularly in a band, it's preferable to play "little chords" rather than full-on, six-note open ringing chords. Imagine you're playing guitar in a band that has a bass and a piano/keys, as well as a pretty good drummer (yeah, right, like you're ever going to make the grade in that band!). That's a lot going on. If you hit a full six-note barre chord over that, you're potentially playing a lot of the low-end/bass notes that the bass player is filling, and possibly even some of the mid-range notes that the keyboard player might be hammering out.

In short, when playing in an band, it's often preferable to keep the guitar to the high-end notes, and play two-or three note chords, to leave plenty of "room" for the other band members to fill.

With this in mind, we're making the assumption that we should always try to play on the high, treble strings on the guitar, where possible. So for each note in our MIDI chord, we're going to try to put it on the highest (high E) string first.

So we look at the numerical value of our first note (64) and we see if this will fit on the highest E string. If this value is greater than the MIDI value of the open string (but less than the open string plus 21, since there are only 21 frets on our light-up guitar neck) then this note can, indeed, be played on the high E string. If the midi value does not fall into the range available for the high E string, we try again on the next string, lower down (in tone).

Once we've successfully placed a note on a string, any future notes (in the same chord remember) must be placed on a lower (in tone) string. That's because it's not possible to have two notes on the same string, and have them both ring out, when played as a chord.

In our case, we can't put note 64 onto the high E string, since high E is MIDI value 76. So we try on the next string down (in tone). The B string is 5 frets "lower" in tone than the high E, and so has a MIDI value of 71. We can't  place our opening note (value 64) on the B string either. The open G string (stop sniggering at the back) has a MIDI value of 67 so we can't put our opening note on that string either. We can put it on the open D string, since this has a MIDI value of 62. Subtracting our note value from 62 gives us 64-2 = 2. So this note goes on the second fret of the D string.

Now we move onto the next note in the chord and repeat the whole process, but with one extra provision - since we already sorted the notes of the chord into descending order, we know that our second note won't fit onto strings 6-4. BUT we've already put a note on string 3, so we make that "out of bounds".

So when we come to place our second note (MIDI value 61) onto the tab, we're only interested in strings 2 or 1 (even if it would have fit on string three, that string is already taken by the previous note).  As it turns out, our second note (61) does fit on the second string since the open A string has a MIDI value of 57. Our fret number is therefore 61-57 = 4.

Repeating this process for the final note in the chord, we can't use strings 6-to-4 and 3 and 2 are already taken, so we have to put our final note (57) onto the first string. The open low E string has a MIDI note value of 52, so the fret number is 57-52 = 5.

If we look at the chord patterns drawn out by TablEdit, we can see that the opening chord of A major is played on the frets 2-4-5 which is exactly the pattern we created!

Although we haven't created the fancy-looking musical notes, and since we're only interested in "note on" messages (we'd have to compare note on and note off times to calculate note lengths) our note values are looking very encouraging indeed!

Transcribing the entire song, we ended up with exactly the same note clusters as the TablEdit software - which indicates that we're doing something right!

The "note spacing" isn't quite right - notes are supposed to be spaced according to the relative time between playing them - but the values look ok so far. Which means we're not far off being able to parse a MIDI file, create an array of "note on" values and squirt these over serial into our playable light-up fretboard; allowing players to see where their notes are and play them one step at a time. Very encouraging!