Shower coding!!

Seems I have some of my best coding breakthroughs in the shower.  Hot on the heals of my recent sound engine release I had a think in the shower today about further optimisations I can probably build into it.  I have quite a significant rewrite planned, but a low level component of this rewrite worked on using 32bit cache buffers for sample data (recent release uses just 16bit ones).

As the samples used are all 8 bits, a 16bit word can obvioulsy hold 2 samples, thus half the number of time the DSP has to talk to main RAM, reading the sample data once from main RAM and then the next subsequent read from it’s own cache.  As the resampling will in some cases simply need the same sample n number of times, this saves a chunk of bus time.  The reason I chose 16bit originally is the DSP only has a 16bit data bus connection to the main RAM (more of an IO port style connection IIRC).

Thinking about it, I am assuming that 1x 32bit read will take less system resource/bus time than 2x 16bit reads seperated by several ticks of other instructions.  Especially as whilst the DSP is making its 16bit reads, nothing else can be using the bus and will need to have been paused.  I am most impressed with how little additional code was needed to support this change, the current code has to translate the requested sample address to determine if it has it in cache, then retrieve just the single byte from the cache that is needed, it all came together very nicely.

I imagine the overall gain will be quite minimal, but every little helps, I have sent the code off to be tested in a real world environment, hopefully there will be some positive results 🙂

Next up is a complete rewrite of the render subsystem for the sound engine to effectively invert the way the cache works and hopefully keep the DSP off the bus even more!

SoundEngine new release

Well as my very lovely lady is away, and I seem to have irked my hamstring somehow AND the weather here is utter rubbish at the moment I thought I would crack on with some improvements to my Sound Engine.

Last few days have been spent faffing with the Vibrato effect, this effect takes two parameters, one sets the frequency and the other the amplitude of a pitch distortion of a playing sound.  It always gives me a headache to code, and as my OCD tends to want perfection that irks me further.  The amplitude is based on 8ths of a semitone, of course as these are calculated by a non-linear expression it requires some look up action.. but then if you are coming off the end of a slide, there is a good chance that the current playback period may not actually exist in your lookup table.. so I engineered a less than accurate, but hopefully good enough work around.

So I compute a percentage of the current period which is approximetly the same size as an 8th of a semitone between the current note and it’s neighbour, so whilst not 100% accurate, it works irrespective of the actual playback period and gives similar audiable effects.

Overall I am quite pleased with my solution, that combined with the other effects I have added support for and the improved timing code so that non 50Hz timing based modules play correctly make quite a lot of modules that sounded a bit iffy now sound bob-on..

Of course this has meant I have had to rethink a lot of previous ideas, had new ideas and subsequently need to re-write a fair chunk of the code before I progress further.. or I will claw my own eyes out, but its all going nicely and I have my most hated effect completed, so the rest should be easy now… should be… 😀

Anyone who is interested you can download it from the website here, complete with a changelog

Hooked… I think

Seems that the ride on Monday has had a lasting effect on me.. I enjoyed it so much I have a hankering for more of the same.  To fuel my newfound addiction I went and looked on for more fun things to do… So I have signed up for the Manchester to Blackpool ride, and have intentions of also signing up for the Manchester to Chester and Manchester 100 rides too.. Just need to decide which (if any) charity I am going to do fund rasing for…

Whilst these are steps in the right direction, they lacked a certain something, I wanted something a bit more.  So in an attempt to find this I had a mooch around on the British Cycling website.. and have now applied for a racing License! hoping to take part in some national races and see how I do in the rankings 🙂

My plan is to go to see a a race on Tuesday after work, and if possible to take part in it myself the following week :)  I’ll post here following that I think.

Exciting times!

52 miles….

Today was the day of the Great Manchester Cycle.  13 miles of closed roads forming a loop that starts at the Eithad stadium along the Mancunian way (A57M), through Media City and past Old Trafford before heading back along the same route.

The event has 3 flavours, 13 miles, 26 miles or 52 miles… of course, I went for the 52 mile option 🙂 this also brought an additional caveat in that I was required to maintain a speed of 18MPH or faster on average to complete the course in time!  I thought what the hell and signed up anyway.

The 52 mile ride started this morning, setting off at 8:00AM with rider assembly at 7:30AM, of course I got a whole 5 and a bit hours sleep before hand :/ and probably didn’t eat the best of foods, but meh don’t want to make things easy for myself now do I!  I was hoping to wear just the event Jersey and my shorts, but despite the sun it was a little cold so I ended up needing my cycling jacket too.. so glad I did that!  My toes were frozen and I never really got too sweaty, not too bad a temp for the ride really (BBC Weather stated around 8 degrees C to about 12 degrees, my Garmin was saying about 13 degrees).

Once we set off the ride out was really rather enjoyable, this being my 1st ride of this type and my 1st real experience of bunches and chains.  WOW! how much fun are they!  Riding along the A57M itself is fun, but when you are doing 30MPH easily, slipstreaming off another rider or two.. awesome!  Which reminds me of another cool thing, the noise.. near silence (other than some chatting).. just the faint hum of wheels on tarmac.  I was quite pleased that I managed to get right up to the lead bunch at the start quickly and without having to push myself!  It didn’t last 🙁 after the pinch point at Media City which almost has the riders single file onto a foot bridge I just lost the bunch and ended up riding solo.. and into that bloody wind, and up hill.. 🙁 🙁 :(  So this really sucked the life and speed out of me.

Thankfully after each lap I learnt a bit more and started looking for wheels to hang off of, actively chasing after a chain to sit in its slip stream.. I was quite pleased to realise I had someone slipstreaming behind me for a fair turn of the route, spurred me on a little to maintain the 25MPH I was doing!

Towards the end of the ride I was pretty tired, this was the fastest, non-stop, constant peddling ride I have ever done, my Manchester to Blackpool rides of previous years have been slower, and involved stops at lights and feed stations.  Today I stopped after the 1st lap for a loo break and that was it!  I didn’t free wheel too much just kept spinning away.  Another boost to my speed and drive was switching the screen on my Garmin to show the current time and my ride time.. until that point I had been concentrating on my average speed more than anything, so had no idea of the time.  Switching to see the time revealed it was a lot earlier than I thought and indicated that I was doing better than I had thought! this really helped spur me on!

A brill day out, lots of fun, I will doing another of this I think.  Which only leaves my stats really…

I completed the full ride in 2:42:36 with splits of 42:08, 40:08, 40:39 and last lap of 39:41  (found a good chain that got me most of the way back 😀 )

and the stats from my Garmin via Endomondo are:

And my best distances were:

Now, I think I’ll go have a bit of a rest 🙂