31 Oct

music notation through JavaScript

I’m working on a project which will hopefully make me rich (mwuahahaha!).

The idea is that I build an application, where people with MIDI keyboards can test their sight-reading online.

The program will judge your playing objectively, according to whether you hit the right notes, what your timing was like, whether you got the dynamics right, etc.

But anyway – in order to do that, some technical hurdles needed to be cleared:

  • 1. how do you read from a MIDI keyboard in JavaScript?
  • 2. how do you render notation online in JavaScript?

Before you ask – I’m using JavaScript because that’s what I’m good at. JavaScript for the front end, and PHP for the back.

The first part already has a solution – not too long ago, Daniel created a Java applet which reads from the keyboard and passes the key events to Flash, by way of JavaScript.

So all I need to do there is to hijack the middle part, which is not difficult.

On the rendering side, though, there does not appear to be any existing music notation rendering software for JavaScript.

One solution might be to pre-render the notation with a console app and save them as images. That’s not perfect, though, because I want to be able to highlight wrong notes, and render the sheet in different ways according to how the reader’s screen is set up.

So – I need to write a renderer in JavaScript.

Here’s the beginning of it (source).

notation-screenie

To work on this, I will be going through my piano books and picking out pieces that are gradually more difficult for the notation renderer to try to render. Soon enough, it will be good enough for use.

Its current features:

  • reads from compressed MusicXML files.
  • renders crochets and minims, with appropriate padding between all notation symbols.
  • will wrap onto a second line of staff (or further if need be) if there is not enough room in just one.

Short-term upcoming features:

  • render two staves (bass and treble) to show left and right hands.
  • render semi-breves</li
  • show fingering on notes
  • dotted notes
  • quavers
  • tied quavers

The big idea with the application is that the site will be able to gradually increase the difficulty of the pieces, according to how well the player performs.

It’s not confined to sight-reading either – there’s no reason why this idea could not also be used to teach full songs.

26 Sep

grade 1 piano results

Last week, I went to Dublin to attend the OSS BarCamp in DIT, and to meet up with friends and to do a piano exam.

Bronwyn and myself have been learning piano for a few months, and I wanted to have some evidence that I was progressing.

piano exam results

I was nervous going in. In the exam, what happens is that you play a few scales and other little things, you play 3 songs from a selection of 8, and then you answer some questions.

The major scales were pretty easy – I was asked to play a few major scales, only one octave, and only one hand. Wasn’t asked to use the left hand at all.

I started out on the minors a bit wrong – the examiner asked my to play “A Minor Harmonic”, and I accidentally played “A Minor Melodic” (the difference is that the leading note, before the tonic, is sharp when ascending and natural when descending, in Melodic, and sharp in both directions in Harmonic).

I apologised and played the requested version. To be honest, I think the examiner made a mistake there, because the examinee is supposed to play /either/ harmonic or melodic, personal choice.

I made another mistake when asked to play triads. A triad is a group of arpeggios which start on a different note of the chord each time. For example, C triad is C E G E G A G A C A G A G E G E C. But, my teacher learned in the London School of Music, and the triads I learned ended on the dominant note – C E G E G A G A C A C A G A G E G E C G.

I corrected myself there as well. These were honest mistakes, but I think knowing the difference and being able to play them, helped with the score.

I had chosen three songs to play.

First, I played Menuet in F, by Leopold Mozart. I really like this piece – it’s light and airy, and there are a few stacatto bits that really fit well into the rhythm of it. I fumbled a bit on the first arpeggio, and wasn’t able to get the dynamics correct on the piano – the piano sounded weird compared to my own (tinny, maybe), and the keys didn’t have much “feel” to them – pressing the keys, I didn’t feel any “power” under them. Very hard to do piano forte when you can’t feel the difference between piano and forte ;-).

The second song, a waltz by Breslaur (Op. 46, No. 25), went perfectly – that’s another airy one, and I tried to play it as if it was being danced to, not as if it was being examined. Again, the dynamics were difficult to put n, but the fact that is a dance, and had a load of stacatto to it, helped get around that problem.

The third song, Study No. 1 by Felix Le Couppey, wasn’t too good. I chose this song because it was totally different in feel to the others – this was going to be the one that showed off the dynamics. I really should have practiced it on a few different pianos, so I knew how to approach the exam one.

I’ve been beating myself up all week over these mistakes, so was very surprised to find I’d passed the exam, “with first class honours”.

Yay me!

I’m choosing songs now for grade 2.

22 Aug

formula for figuring out keys

I was just looking at scales and trying to memorise how many sharps and flats each key has.

In short: count the sharps. multiply by 7. divide by 12. add the remainder in semi-tones to C. that’s the key. For flats, subtract the remainder from C.

The usual way to do this is to use the “circle of fifths” diagram:

In that, you count clockwise from C to find keys with sharps in them, and anti-clockwise for flats.

For example:

This key has 3 sharps, so you count three keys to the right of C, and that makes it A major.

If you want the minor key, then do the same, but then subtract 3 semi-tones from it, and you get F#m.

Now, what if you’ve a crap memory like me? There’s no bloody way I could remember a complex diagram like that.

Simple – let’s look at another variant of the diagram:

In this diagram, in order to figure out the key, you follow the lines; anti-clockwise for sharps, and clockwise for flats. For a key with 3 sharps, you start on C, then follow the lines 3 times, through G and D to A.

Yes, it’s another diagram, but look at the lines – they’re perfectly regular, which means that a formula can be built from it.

The formula is simply this: sharps * 7 % 12. Then add the result in semi-tones to C and you get the answer.

Examples:

CC#
D♭
DD#
E♭
EFF#
G♭
GG#
A♭
AA#
B♭
BC
0123456789101112
  • 1 sharp: 1*7=7. 7%12=7. 7 is G
  • 2 sharps: 2*7=14. 14%12=2. 2 is D
  • 3 sharps: 3*7=21. 21%12=9. 9 is A

For flats, subtract the result from 12 to get the answer:

  • 1 flat: 1*7=7. 7%12=7. 12-7=5. 5 is F
  • 2 flats: 2*7=14. 14%12=2. 12-2=10. 10 is B♭
  • 3 flats: 3*7=21. 21%12=9. 12-9=3. 3 is E♭
19 Jul

a few piano pieces

I started learning piano a few months ago. I’ll be going for the Grade 1 exam in September.

There are a few reasons I wanted to learn. Partly, it’s because there was an upright piano in my sitting-room, just looking at me as if waiting. But mostly, it was because I want to understand music.

I mean really, what the hell is music? Why does some music sound good and other music sound awful? Why is it that some people have different opinions about what is good music?

In order to figure it out, I’ve been trying my hand at writing little pieces and learning to play them.

These can in no way be considered professional attempts. They are amateur at best, and just my way of feeling along and figuring out what I’m doing.

I’ve no way of recording myself (an iphone’s camera is just not good enough), so I’ve supplied midi, and mp3 renderings of the midi, as well as the sheet in PDF form.

tune 6 – baroqueish

This one’s from this morning. I was lying in bed trying to sleep while the kids and Bronwyn did there best to not disturb me while jumping on the bed beside me, and this came to me. I rolled out of bed and turned on the computer to write it down.

It feels to me like a light-hearted baroque piece. I hesitate to even use that word because I’m not certain what it means, but I think it’s right.

midi rosegarden pdf mp3

tune 2 – the sad one

I can’t remember when this one came to me. It’s been floating in my head for a few years. It’s a bit more “modern” than my usual stuff.

midi rosegarden pdf mp3

tune 3 – icecream!

I originally wrote this one years ago and didn’t like it at the time. I like it now. It reminds me of ice-cream vans and the excitement we’d all feel as a kid when the ice-cream van would come around.

midi rosegarden pdf mp3

tune 5 – fall and rise

This one’s more of an exercise than a tune, although I suppose maybe something could be made of it. It’s a few arpeggio triplets over a slow descending then rising scale.

midi rosegarden pdf mp3

17 Apr

update on Me

Quick update of what’s happening in the world of Kae.

I’ve been busy recently with a new project in the office, making an ultra-WebME system which can be used by companies who are not web designers, to offer their clients “pre-packaged” websites. I may elaborate on that in a few weeks once the pilot study is out of the way.

I haven’t touched the KFM file manager project in ages, and recently realised that it’s because I’m just not happy with it anymore. It’s monstrously complex now, and just not flexible enough for the changes I want to build into it. So, I’m seriously thinking of rewriting it completely, or building a new file manager project to compete with it.

WebME is progressing quickly. The plugins architecture is damned easy to use, if I do say so myself. So much so that Conor wrote a mailing-list plugin before I even got to announce the plugin system. To try it out, get the Subversion copy of WebME, and also the subversion copy of the existing plugins (svn checkout http://webworks-webme.googlecode.com/svn/ww.plugins/) and create a symbolic link from ‘ww.plugins’ in the root of your WebME installation to the checked-out ww.plugins directory. Then in the /ww.admin section, go to Site Options > Plugins and try some stuff. I’ll be writing a proper tutorial on how to create a plugin. Probably today.

I started learning piano at the beginning of last month and am proud to say that I appear to be learning at a prodigious rate. This is probably because I can already play well on a number of other instruments. Last tune I learned was Ecossaise in E Flat by Beethoven (WoO 86), played here by Matt Baker:

Before that was I’ll Take You Home Kathleen, played here by Dave Seddon on steel guitar (couldn’t find a piano version that wasn’t ruined by people singing over the music 😉 ):

I’m still in quite a lot of pain since last week’s operation, but hopefully it will ease off over the weekend, as I have the next chapter of my book to submit.

13 Mar

419 con attempt

I advertised recently as a guitar teacher, and nothing happened for a while afterwards, then I got this interesting email:

Hello,

Good day to you over there, I need good teacher for my son smith for 2 month Smith is 13years of age.I want you to taech him 60mint per day, 3 times in a week.

1.CHARGE FOR AN HOUR….
2.TOTAL CHARGES FOR 1MONTH THAT HE WILL BE TAUGHT 3TIMES PER WEEK…
3.YOUR PHONE NUMBER…”

Kindly get back to me if you will be available for that time and you can as well get back to me with your total cost for 2 month.

Thanks and waiting to read from you..

I thought it was interesting, and a bit weird. The guy doesn’t say where he’s from, but the usage of “you over there” suggests overseas. Then, the guy’s son is called “Smith”, which is a surname. Then he’s insisting on 3 hour-long lessons per week. An hour is a very long lesson, and three times a week is /way/ too much – when you are learning an instrument, you only need a half-hour lesson once or twice a week.

I replied anyway with my usual rate (€15 per half-hour, €25 for an hour), asking what style of guitar “Smith” would like to learn.

Here’s the reply.

Hello,

Thanks for your email,More so i am glad the way you have kept me posted on the (tutoring) and i have accepted your offer and its okay by me.

I have make contacts with my son concerning the arrangement of the tutoringwhich he told me is ok by him and i want you to know that i am going to pay for 2 month which is €600 and also my client who is in DUBLIN will be sending you a cheque of €4,000

And the rest of the money will be used to get hotel accomodation nearby your location for my son and his nanny and any other arrangement for the lesson so that the tuition can be able to conveniet for both of you,

As soon as you get the cheque cash you will deduct cost of price of the lesson and send remaing balance to my son’s NANNY so that they can ba able to arrange themself to come up for the lesson at your location.

Regarding this kindly get back to me with your full information to receive the cheque ,like your full name we be on cheque your full address where you can receive it, so that payment can be able to made out intime,

Because i want the lesson to start as soon as you received the cheque.

Thanks and waiting to read from you.

Lewis.

As soon as I read that, I laughed. This is a classic Advanced-fee fraud, but with a slightly different target than usual.

A greedy person that doesn’t think clearly may fall for that, but there are a number of things that don’t ring true about the email.

Why would a cheque be sent if a NANNY (uppercase, notice) is going to be arriving anyway. Why is the cheque so god-damned large? Why is DUBLIN written in upper-case (copy/pasted, maybe?). He has “[made] contacts with [his] son concerning the arrangement” – he’s 13 years old, man – you don’t “make contacts”, you tell him what to do! Why would someone be flying in from some place overseas to a small town like Monaghan for two months without even checking first to see if I can actually teach?

For anyone interested, the email address used was lewis_001@ymail.com – it’s been reported already.

15 Jan

aw man…. 7 things

I thought I’d escaped this one. Everyone in the PHP world appears to have been “tagged” by now. Ken passed the buck to me, though, so I guess I’d better play.

Hmm… 7 things that people don’t already know about me? Hard task…

  1. I used to be into piercings, and if the piercing was common, then I wasn’t into it. Mostly, I was into surface piercings, and had a number of them down my sides and arms. I had planned on building a platform for a watch which would then be “embedded” in the arm, but never got around to it.
  2. I used to do “side-show” tricks, and have performed them on stage. This includes tricks such as “skewer through face” (horizontal – never got around to learning vertical), “human blockhead”, “face in glass”, eating glass, fire-eating, fire-blowing, and other weird stuff. Each of these is surprisingly safe when you know the trick.
  3. My first computer was a Commodore Vic 20 which I got when I was possibly 7 or 8. The highlight of that machine was writing (in BASIC) an animation of a bird which flew across the screen and “pooped” on a tank. I didn’t really consider that as “programming”, though – just playing. That machine was followed a year or two later with a Spectrum 48k+, which is where I really started – with 3d wire-frame graphics and text adventures. My first “real” computer was an Amstrad PPC640, where I learned QBASIC. My first CGI experience was writing applications (forums, etc) in C. That was followed by Perl, and finally I started writing php in about 1999 or so. Now I’m secretary of the Irish PHP User’s Group. Yay me! Oh, and Go Linux! I’ve been using Linux as my main OS since the 20th century as well.
  4. I can play a number of instruments. I played violin (rather, fiddle) for my school in a number of Feis Ceoil events and still have an electric violin that I pick up every now and then. I played Bagpipes in two separate pipe bands in Dublin – anecdote: in school, a music teacher was evaluating our playing of the tin whistle, and when he came to me, he saw immediately from the way I was holding it that I had training in a “pipe” instrument (uillean pipes and bag pipes are fingered similarly). I’ve played guitar in a few bands and like to get on stage at the Monaghan Blues Jam whenever I can (last compliment I got at one of them was “I like your playing – it’s /clean/ – very 70s”). I am looking for a classical guitar teacher at the moment. I also play keyboards, and have written music before (example).
  5. I’ve been vegetarian for more than half my life. This is not because of any hippy feelings towards animals. The two main reasons are 1) it’s disgusting to put dead animals in your mouth, and 2) it’s illogical, inefficient and cruel to kill animals for your food when you really don’t need to. I have no problem with people eating meat as long as they have no problems with me (and my family) not eating meat.
  6. I believe that the universe doesn’t really exist, but is a sort of shared illusion (look, it’s complex, ok!). Basically, it works like this – if the equation 2x-2x=0 is true, then you might consider that ‘x’ is a “real” object even though the sum of the equation is ‘0’ (ie; from nothing, comes something). This maps onto reality if you swap ‘x’ with ‘particle’, and ‘-x’ with ‘anti-particle’. I am always coming across situations where physicists discover this is true. Hawking radiation, for example, is an example of energy/matter spontaneously bursting into existence,, and is an exact analogy because you end up with ‘x’ (the radiation coming out of the black hole) and ‘-x’ (the radiation going into the black hole). Oh, and if you’re thinking it’s mad to think that ‘x’ could be real… in a computer game, all characters are “real” to each other, but not to an outsider looking in. In our case, we are those characters, and in an equation, each element is one of those characters. In the context of the equation/universe, all parts are real relative to all other parts, even if from the outside, they’re not.
  7. I used to do contact juggling. In fact, I founded the biggest contact juggling website. My son, Jareth, is named after David Bowie’s character from The Labyrinth where the goblin king (with the help of Michael Moschen) does some contact juggling (called “crystal ball manipulation” in the credits). I even wrote a book on the subject.
  8. Everyone in the world appears to have been tagged for this already, so I won’t bother tagging anyone.
    edit: suppose I’d better…

    1. Conor Mac Aoidh – local chap. Bright and enthusiastic. I feel that he’ll be producing sterling work soon and will be a credit to the Irish PHP community.
    2. Stéphane Lambert – tireless compiler of PHP Whitebook trivia, and host of a damned good neo-classical metal radio show.

    I can’t think of any other PHP developers that I know that haven’t already been tagged. Really! Now go away and read something else!

    Rules

    • Link your original tagger(s), and list these rules on your blog.
    • Share seven facts about yourself in the post – some random, some weird.
    • Tag seven people at the end of your post by leaving their names and the links to their blogs.
    • Let them know they’ve been tagged by leaving a comment on their blogs and/or Twitter
27 Sep

a few improvements in the guitar thing

try it out – you need to log in to get a proper feel for it.

New items: a metronome, external tabs are shown in an iframe (makes it easier to use with the metronome and keeps the song within the context of the site), you can edit the songs you added and you can add a video of the song being played.

In the backend, I have a few architectural improvements (better class structure, etc), and the beginnings of the rating system which will eventually be able to figure out how difficult songs are in comparison with each other.

The metronome was very simple to create – I used the sound manager 2 library to manage the sound production, and a very small piece of javascript to do the timing. There are minor hiccups in the timing, but I think that’s due to the interaction between JavaScript and Flash (and JS is probably not supposed to be used for precision timing anyway).

stand-alone demo of the metronome, source files

Anyway – please try the guitar application – I know it’s a bit bare at the moment, but whenever I get the time, I add to it, and the more people use it, the more complete it will appear. feature requests and bug reports go here.

19 Sep

guitar project started

Couldn’t wait, so I wrote the beginnings of the project yesterday.

Click here to try it.

So far, you can create a user, login, name the chords you know (simple chords only – for now, this is for beginners), find songs with those chords, or songs with 1 2 or 3 extra chords you don’t yet know.

If you log in, you can add songs. I am hoping that people will find this useful, as I can’t begin to measure the relative difficulties of each song until I have a reasonable amount of data.

I’ve set up a project for it on my issue tracker – if you want to see ‘x’ feature, or you spot ‘y’ bug, please report them.

I hope you find this useful.

I’m debating with myself about whether to release the code for this – I want to share, but I also don’t want someone taking my code and building a huge money-printing site with it and leaving me in the cold (and Monaghan gets cold this time of year). Maybe I’ll release code for “old” versions – like if I’m on version 1.3, I’ll release 1.1 for other people to take.