Spot any errors? let me know, but Unleash your pedant politely please.

…

Wednesday, 27 June 2012

Songwriting

On Saturday, I spent a delightful afternoon with my twelve year old daughter helping her to record a song. I've dabbled in this a little in the past, but without any success.  I've owned a cassette based 4-Track, an Atari ST with a dodgy copy of Cubase. I had Cubase lite on a 486 PC with an expensive but ultimately crap sound card. I bought a full copy of Cubase on a Mac running OS9 and pretty much failed to get it do do anything. I dabbled with Soundtrack Pro and Garageband. I have Garageband and Intua Beatmaker on my phone.

I can use music software in the same way as I can use a camera: I know enough of the technical details to get by, but I am largely devoid of talent. Both musical and visual.

In photography, I learned that my wife has a natural eye for picture, but no interest in the technical aspects of the camera. We make a reasonable team. She'll give me some indication of what she wants to do, I adjust the camera, she frames the shot and presses the shutter release.

A similar thing happened with my daughter and her song. She wandered into the living room at about 1PM and announced that she had written a song. I somewhat condescendingly asked her to play it for me. She did … quite badly … stumbling over the lyrics and with far too much right-hand damping as she strummed.  What was interesting is that she'd pretty much mastered the few chords I'd taught her a while back, discovered a few more, and strung them together into two distinct sequences.

I suggested that we record it. I launched Garageband. I asked her to play the song while I figured out the tempo and then we looked for a drum pattern that matched reasonably well. I picked a simple MIDI bass pattern that went with both. We worked though the first chord sequence to adjust the pitch of the bass to match. We repeated this for the second chord sequence and spent a remarkably small amount of time adjusting the number of bars of each. We had the foundations of the demo sorted.

Next we recorded her playing the guitar into my laptop's built-in mic. The first attempt was aborted early when I could see that the signal was too weak.  I adjusted the recording level and we the first sequence again, this time successfully.

My daughter's strumming is a bit erratic. The timing and clarity aren't consistently good, but we were able to pick the best 4 bars and copy and paste these.  We did the same for the second sequence.

I was quite careful at this point not to criticise.  Had it been my song a couple of years ago, I'd have probably spent the rest of the day trying to capture a better guitar part.  I've been listening to the wonderfully prolific Billy Childish recently though, and I've come around to the idea that getting a lot of songs done roughly is far better than perfecting just a few.

Next up were the vocals. The laptop mic was used again. My daughter sang the whole thing start to finish in one take. No getting lost, no problem with the timing into and out of the bridge, finishing at the right point too.

We then spent a bit of time mucking about with the software. We put pitch correction up to the max, tried all the vocal presets, changed the tempo.  Her pitch was pretty good for the most part, but she liked the effect of the pitch correction, so we kept that.

The song began at 100bpm. Adjusting the tempo of audio tracks works best at multiple values. I ramped it up to 200bpm. "I like it like that!", she exclaimed. The guitar sounded fine, the the vocals did not.

We recorded the vocals again at 200bpm.  Again, just the one take. There are some mistakes, some practice and more takes would no doubt fix these problems, but we were enjoying ourselves too much to worry about them. I adjusted the levels a little, and we had ourselves a song.

Knowing that multi-tracking the vocals to add depth/chorusing/richness is a common technique, I un-muted the original (now playing at 2x) vocal to see how it would sound. We got a lucky. The timing was different, so it sounded like two distinct voices singing different but complementary things. With the original vocal's level reduced so that it's not fighting, we ended up with quite a cool result:

Bowser.mp3

The song is about an unloved character in the Mario games. For bit more fun, my daughter wanted pictures of the character in a slideshow along with the music.  Five minus in Google images and 5 more in Final Cut produced something she added to her Facebook page that she was delighted with.

I have an old mixer and a condenser mic.  I just ordered a mic stand and XLR cable. Hopefully we can take the song and record it again, but do a better job and take a little more care.  If she wants to to a rough job on entirely different song though, that's fine with me. Just like with my wife and the camera, my daughter can tell me what she wants to do, and I'll help out with the technical side until she can get the hang of it herself.

Thursday, 17 May 2012

Syntax Highlighting

It's taken me ages to get around to adding Syntax Highlighting.  No idea why it took so long, but it's here now. w00t!

Tip of the hat to David Craft, who wrote the instructions I found and many thanks to Alex Gorbachev for the hard work.

Hex Dump

I'm off to Paris next week for a meeting. This has prompted me to investigate a minor bug in some code that was displaying "§" instead of "§". It's really just a cosmetic defect until a customer sees it. At that point, it makes me look like a careless dick.

My immediate thought was to look at the hex values in the file. The last time I did this was when I was using VAX/VMS systems. That was at least 6 years ago, but it may have been 10 years ago when I last looked inside a file in this way. 'hexdump' at the OS-X command line does the job, but not immediately in the way I wanted. I didn't bother to read the MAN pages, but decided to roll my own in Python instead:

#!/usr/bin/env python
#!/usr/bin/env python
# encoding: utf-8

import sys

WIDTH = 24

# §

def ascii(byte_value):
    if byte_value < 32:
       return {0:  'NUL',
               1:  'SOH',
               2:  'STX',
               3:  'ETX',
               4:  'EOT',
               5:  'ENQ',
               6:  'ACK',
               7:  'BEL',
               8:  'BS ',
               9:  'TAB',
               10: 'LF ',
               11: 'VT ',
               12: 'FF ',
               13: 'CR ',
               14: 'SO ',
               15: 'SI ',
               16: 'DLE',
               17: 'DC1',
               18: 'DC2',
               19: 'DC3',
               20: 'DC$',
               21: 'NAK',
               22: 'SYN',
               23: 'ETB',
               24: 'CAN',
               25: 'EM',
               26: 'SUB',
               27: 'ESC',
               28: 'FS ',
               29: 'GS ',
               30: 'RS ',
               31: 'US ',}[byte_value]
    elif byte_value < 127:
        return ' %s '%chr(byte_value)
    else:
        return '%03d'%byte_value
        
def hex_dump_line(bytes, index=0, width=WIDTH):
    if len(bytes)>0:
        hex_part = u""
        text_part = u""
        for byte_value in (ord(byte) for byte in bytes):
            hex_part += '%02X '%byte_value
            text_part += ascii(byte_value)
        print '%04X %s'%(index,hex_part)
        print '     %s\n'%(text_part)
            
def hexdumpfile(filename, width=WIDTH):
    file_to_dump = open(filename, "rb")
    byte = file_to_dump.read(1)
    bytes = []
    index = 0
    while byte != "":
        bytes.append(byte)
        if len(bytes)==width:
             hex_dump_line(bytes,index=index,width=width)
             bytes = []
        byte = file_to_dump.read(1)
        index +=1
    hex_dump_line(bytes, index=index, width=width)

if __name__=="__main__":
   hexdumpfile(filename=sys.argv[0],
               width=WIDTH)
The output looks like:

0017 23 21 2F 75 73 72 2F 62 69 6E 2F 65 6E 76 20 70 79 74 68 6F 6E 0A 23 20 
      #  !  /  u  s  r  /  b  i  n  /  e  n  v     p  y  t  h  o  n LF  #    

002F 65 6E 63 6F 64 69 6E 67 3A 20 75 74 66 2D 38 0A 0A 69 6D 70 6F 72 74 20 
      e  n  c  o  d  i  n  g  :     u  t  f  -  8 LF LF  i  m  p  o  r  t    

0047 73 79 73 0A 0A 57 49 44 54 48 20 3D 20 32 34 0A 0A 23 20 C2 A7 0A 0A 64 
      s  y  s LF LF  W  I  D  T  H     =     2  4 LF LF  #    194167LF LF  d 

This allowed me to see the '§' was encoded in the file as C2A7, and sure enough C2 is the unicode value of 'Â' and A7 is the unicode value of  '§'.   When I open the file in TextMate, I see just the '§', but in Safari's View Source, I see '§'.  It turns out that although I'm encoding correctly as UTF-8, I'd neglected to declare the encoding in the HTML . This fixes the problem:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'

I'm not sure when I'll need to look inside a file again. Not for this issue, I hope. I'll recognise it and check the header first.

EDIT: I should've just looked in the app store. File Viewer is free and does pretty much what I wanted to do - quicker, better, prettier, etc.

Friday, 23 March 2012

openpyxml win

I'm a software tester. I write and run a lot of test scripts. These scripts are usually written in Excel.

Excel feels much more appropriate than a dedicated test case management environment. It is a tester's tool, not a management tool. Its Achilles heel, however, is the fragility of inter-workbook linking. It just doesn't seem possible to create and maintain relative links for multiple users.

Using a separate summary/reporting workbook to show test progress requires quite a lot of link plumbing. This plumbing is a maintenance nightmare.

My current project is in its infancy. The shit and the fan aren't even in the same room yet. I have time to put things in place. Time to do something about the plumbing. I can't fix Excel, but I can rip out most of the troublesome plumbing.

I've had some success with Apache POI in the past (Java library for reading/writing Excel files). My Eclipse and Java skills are rusty, but my Python is not.

A little Googling gave me a few options. The first I tried was openpyxl. It worked, so I saw no reason to look beyond it.

The Test Scripts are all based on a template devised and maintained by the testers. This template has some rows at the top containing a live view of the state of the sheet (number of steps, number of passes, number of failures).

I've now reduced the plumbing to a few cells in a workbook that link to a few cells in a CSV. This CSV is written by a Python script that scans a folder and its subfolder for Excel files and uses openpyxl to scrape values from the results cells of test scripts.

If new scripts are created somewhere in the folder structure, these will show up in the CSV.

It's also possible to generate a summary at each level of folder hierarchy. That means we can create a meaningful hierarchy - say reflecting the requirements hierarchy - and easily get a summary at level.

Another benefit is that we can split long test scripts into smaller individual test cases. The Python that scrapes the results will simply find them all without any additional work.

Thursday, 2 February 2012

Single Story, Television and Violet Blue

Last night, due to very bad WiFi in my hotel, I watched a few TED videos I'd downloaded in case the WiFi in my hotel room was very bad. One was just superb. It was 'The Danger of a Single Story' from Chimamanda Adichie. I'd never heard of her before, but just ordered a couple of her books on the strength of how much I enjoyed this:











It made me think of The Wire. Just as Chimamanda was stuck telling single stories in her early writing, the majority of TV is stuck telling single stories. The majority of characters in TV are superficial. One dimensional. They have a single story … good policeman … bent copper… drug dealer … guy in red shirt in away team to the planet surface.

Characters become multi-dimensional when we know more than one of their stories. I've always thought this is why The Wire is so good. Most the characters have more than one story. It's not possible to do this for all of them, of course. Some minor characters are never fleshed out. Some characters have to wait for several seasons to pass before getting more of their stories told. After this happened a couple of times, I stopped judging characters on their single-story - being patient for the reveal of a second, third … nth story.

I haven't always extended that patience in the real world, but it's something I shall endeavour to do, having thought about it in this way.


I'm going to have to consider whether this is also why I like The Killing and Borgen. I think it's why Skins and Misfits are so good - they present single-story stereotypes intially, but dedicate whole episodes to fleshing out each of the main characters by giving them additional stories.

This assumption of a single story is what's bitten Violet Blue in captioning "The Saddest Booth Babe In The World" ). I'm not going to judge her too harshly. She'd just responding to a single story in he way most of us often do. She's not doing herself any favours, however, by not reconsidering, not apologising, not learning, not growing.

A person at conference booth can be a young attractive women, with breasts in a tight t-shirt, representing herself and her work and her nerdery. A young attractive woman, with breasts in a tight t-shirt is not necessarily hired marketing eye-candy. She may be bored and tired and disillusioned. She may be struggling to overcome shyness or social awkwardness (I am imagining myself in a similar situation). She may be sitting there thinking "Fuck! I wish I'd hired a booth-babe. I suck at this!"

Tuesday, 13 December 2011

Rivers of London (Peter Grant, #1)Rivers of London by Ben Aaronovitch

My rating: 3 of 5 stars


Picked this up at the airport last week. It's an odd mix. Like a Mark Billingham rewritten by Robert Rankin. It also reminds me of Neil Gaiman's Neverwhere.

The main sticking point is that there's a lack of balance between historical background and complexity of plot. It feels like 100 pages of plot and 250 pages of historical/geographical filler.

It's closer to Rankin or Pratchett than Gaiman. So if you like that kind of thing, you'll probably like this.



View all my reviews

Tuesday, 13 September 2011

Trying out ifttt


Really interesting and nicely designed new service called ifttt. It lets you link web stuff. I'm giving it a whirl right here by linking my blog, such as it is, to Twitter. I partly chose this because I don't update the blog often, and so it shouldn't annoy people too much. I'd also probably tweet about most blog posts anyway.

I haven't read T&Cs yet. I'm mostly positive about this, but I can see how it could potentially be abused.