Showing posts with label Music. Show all posts
Showing posts with label Music. Show all posts

Wednesday, 5 May 2021

Don't Worry (Paul O'Brien)

Song written by Paul O'Brien. Guitar & vocals by Paul O'Brien.
Additional instrument parts written & performed by John Michael Kerr.
Sound production & captioning by John Michael Kerr.

Watch on YouTube

Instrumentation

  1. Video - Paul's original iPhone recording (audio not used)
  2. Vocals - Condenser mic through Behringer UMC204HD
  3. Guitar - Fender semi-acoustic
  4. Drums - 64 Pad Kit Rock
  5. Piano - East Village Grand
  6. Violins 1 - BBC SO Discover
  7. Violins 2 - BBC SO Discover
  8. Violas - BBC SO Discover

Production Notes

This was the point where I finally abandoned the idea of combining my two vocal audio sources - iPhone and condenser mic - because of the extreme difficulty in getting them to register after stitching for tempo. Most of the time it would work out well, but just occasionally, due to the differences in ambience, the two signals would contain unmatched transients, and any attempt to bring them into mutual agreement would result in - not just distracting echoes and phase effects, but actually disturbing ring modulations, worthy of a 1960s Dr Who episode. And Paul made it quite clear, he was not standing for this sort of treatment!

Critical Response

From Paul's Facebook page:

  • Nothing yet!

Friday, 30 April 2021

Stations Of The Cross (Paul O'Brien)

Song written by Paul O'Brien. Guitar & vocals by Paul O'Brien.
Additional instrument parts written & performed by John Michael Kerr.
Sound production & captioning by John Michael Kerr.

Watch on YouTube

Instrumentation

  1. Video - Paul's original iPhone recording (audio not used due to poor recording quality)
  2. Vocals - Condenser mic through Behringer UMC204HD
  3. Guitar - Fender semi-acoustic
  4. Recorders - Ableton Core "Recorder Keys"
  5. Violins - BBC SO Discover
  6. Double Bass - BBC SO Discover

Production Notes

After the 10-channel extravagance of Union Card (mixing like it's 1969!), we had a chat about our next project, and seemed to agree that a simpler, more restrained production would be appropriate. "Something along the lines of the Stairway To Govan intro, with recorders, flutes, or similar..."

Paul's original iPhone video recording had such poor quality audio, we agreed to bin it. This didn't make life much easier for me, however, as the video still had to be stitched or "warped" to ensure the guitar notes synchronised correctly with the video experience. At the time of writing we still haven't figured out why the iPhone audio has taken such a nosedive recently.

I've boosted Paul's guitar in the beginning and end sections. His fingerpicking work is good here, so I showcased it by increasing its volume and dropping out the double bass in the last 8 bars.

Vocals have a tweaked "Vocal Presence" filter applied, and Guitar uses "Acoustic Git EQ 1".

Critical Response

From Paul's Facebook page:

  • SO beautiful!!! ❤️
  • Hey, Elenor Rigby, where's ur hair shirt? ( good song)

Previously: Midnight Sky Of Blue

Next time: Don't Worry

Thursday, 29 April 2021

Midnight Sky Of Blue (Paul O'Brien)

Song written by Paul O'Brien. Guitar & vocals by Paul O'Brien.
Additional instrument parts written & performed by John Michael Kerr.
Sound production & captioning by John Michael Kerr.


Instrumentation

  1. Video - Paul's original iPhone recording
  2. Vocals - Condenser mic through Behringer UMC204HD
  3. Guitar - Fender semi-acoustic
  4. Bass Guitar - Core Library Guitar Bass
  5. Drums - 707 Core Kit
  6. Pedal Steel Guitar, Harmony Mono - Impact Soundworks
  7. Pedal Steel Guitar, Poly Legato - Impact Soundworks

Production Notes

First outing for my shiny new Pedal Steel Guitar! Actually a keyboard instrument, this offering from Impact Soundworks for the Kontakt Player is an absolute joy to play, once you master its two ingenious idiosyncrasies: overlapping notes legato, and a set of left hand keys control harmony generation.

The main design goal was to interleave the "second country voice" of the steel guitar with Paul's vocals, so that it would never get in the way. When it does play through the vocals, it does so at just one note per beat, lending a little strength to the acoustic guitar chords. On this recording I've used two PSG tracks, to take simultaneous advantage of legato and polyphony, particularly in the second half.

Had a disagreement with Paul about the quality of one note in the vocals: the word "blue" around the 3:50 mark would originally glide across four notes, and I thought the third of these was missing its mark. We agreed for me to elide it, and I have bent it like the truth.

Critical Response

From Paul's Facebook page:

  • A beautiful masterpiece Paul.. so full of emotion and fabulous work by John.
  • Can hear this playing on the radio. Wonderful. 👏👏👏👏❤️❤️
  • Such a rich, evocative narrative. Lingers in the mind as all great music does 🎼
  • Previously: Union Card

    Next time: Stations Of The Cross


    Sunday, 25 April 2021

    Lyric Captions

    Praise the Lord and Pass the Microphone

    The Digital Audio Workstation "Ableton Live" works almost as well with full video files as it does with audio samples, but has no native facility to add lyric captions to a musical video, nor to generate the necessary caption format files to upload to video services like YouTube. Having produced a full square sixteen of Paul O'Brien's song recordings, and in the process almost accidentally created an equal number of "live" performance videos, I wanted the ability to add closed captions containing the song lyrics.

    Oh, and it had to be free and quick and easy. There are commercial solutions available, but I didn't want to spend one cent. If you search the intertubes for "Ableton Lyrics" today, most of your results will be from American "worship sites", and a little thought will reveal the reason for that. Obviously this is a bit removed from my particular use case.

    There are also automatic options. The AIs may be coming for all of our jobs, and speech recognition is certainly improving exponentially as we, erm, speak. But it's not quite there yet as far as the singing voice is concerned. I mean, just look at this effort.

    So it has to be accurate too, but within limits. We're not building a karaoke machine complete with bouncing ball. One-second accuracy should be adequate for the display of each line of the lyrics, so the listener can follow along with the performance.

    SubRip File Format

    Most subtitles distributed on the internet, for example those ripped from movie DVDs, use a file format called - for obvious reasons - SubRip. Since this format is one of the two most popular currently supported for videos uploaded to YouTube or Google Drive (the other being SubViewer, support for which was added later) I settled on it initially for this project.

    SubRip is a very simple text format: each text entity (line of dialog or song lyric) is preceded by a header containing its index (line) number and the start and stop times for its display on screen, and followed by a blank line. Obviously any text editor could be used to produce such a file, but look how fiddly it is, even after you've determined the full list of correct values, to incorporate these time marks into the format (the milliseconds separator is a comma because SubRip was originally written in France):

    "Union Card" song lyrics - Copyright © 2021 Paul O'Brien

    That's the little app I ended up with, after two hours in Visual Studio - one hour for the calculation engine, and one for the user interface. Here's the code, and here's how it works: 

    1. Specify the total duration of the video file, by either entering the minutes & seconds at the foot of the form, or selecting the video or associated audio file (via menu or drag & drop) and letting the code read the relevant duration from it. This feature uses the magic of TagLibSharp.
    2. Either drag the lyrics file into the window, or paste the lyrics from the clipboard into the left panel, or right-click and select the lyrics text file to load it.
    3. The captions file appears immediately in the right panel. This text may be copied to the clipboard, or saved with a menu command.
    4. Any alterations to the duration controls, or to the contents of the left lyrics panel, are immediately reflected in the right captions panel, so it's always kept up to date, ready to be copied or saved.

    Tweaking the Timing

    Given the above description of the tool's operation, you probably guessed that it's simply counting the number of lines in the lyrics, and allocating an equal time slice to each out of the total video duration. Sure, this isn't exactly how songs work, and without some degree of tweaking, the lyrics displayed will drift into and out of synchrony with the performance - that's if you're lucky, and they ever enter synchrony at all!

    The one blunt weapon at our disposal is the blank line. It's usually enough to restore an adequate level of synchrony, without introducing complicated user operations, judiciously to insert one or more blank lines into the lyrics. For example, the above song Union Card has a classic 12-bar blues structure. If you don't know what that is, think of Led Zeppelin's Rock And Roll. And if you don't know what that it, get off of my lawn.

    Union Card has a 4-bar instrumental introduction, during which we don't want any lyrics appearing, although we could use this to add the artist's name, song title, copyright notice etc. Assuming we don't want any of that, we just observe that each "line" of the song lyrics occupies two bars, and add two blank lines to the start of the lyrics to account for those four wordless bars.

    Next, observe that here - as often in the 12-bar blues format - the first six bars of a verse are occupied by the first three lines of lyrics; the next two bars are instrumental; the next two hold the fourth "punch" line of the verse; and the last two bars are instrumental once again. Following our guide of one line of text equalling two bars, we see that inserting one blank line after the third and fourth line of each verse should align things very nicely. When my app sees a blank line, it just retains the previously displayed line of text, because why not? There's no advantage in blanking it. Incidentally if you do want to insert a blank line somewhere, just use a line containing only a backslash ('\') instead, and the program will oblige.

    But wait - a glance at the Ableton project reveals there's actually a 5-bar outro after the 9th and final verse. If one blank line represents two bars, how can we add half a blank line to compensate for the final, odd-numbered bar? Well, we can't, at least not without complicating our beautifully simple timing scheme. Easier maybe just to add two blank lines, and truncate the final bar. Looking again at the score we see the tempo is 96bpm, the time signature is 4/4, so one bar is 4/96 minutes, or 2½ seconds. So, just clip 2½ seconds from the file duration using the up/down controls at the foot of the form.

    Och That's Too Complicated

    Okay, how about this then. You can add a half-length line by including an initial period ('.') in the lyrics. If this appears on a line on its own, it's equivalent to a blank line, but of just half the usual duration. If it appears at the start of a lyric line, then that line will occupy just one-half of the usual time for a line; so for example, if each line of lyrics so far has occupied two bars of music, this one will occupy just one bar.

    Inspired by musical notation, I'll expand this a little further. So, a line starting with two consecutive periods ('..') will occupy a further 50% of the duration of the single period line, i.e. three quarters or 75% of the usual line length; while a line starting with a colon (':') will occupy just one quarter.

    These markups can alternatively be appended to the end of a line, extending its duration by the given amount, so for example a period at the end of a line causes it to be displayed for 1½ times the usual interval, a colon 1¼, and so on. With a little thought, this is almost identical in effect to putting the punctuation on its own (otherwise blank) line, after the lyric. The "almost" covers the fact these trailing marks will be ignored if leading marks are also present.

    Handy reminder from the Help menu or F1 key

    But what if my lyrics... end with a haunting ellipsis? If you want to incorporate leading or trailing punctuation in the displayed text of a particular lyric line, no problem, just pad the text with a leading or trailing space, so that your punctuation symbols don't actually appear right at the very start or end of the line. The program strips all leading and trailing markup and whitespace, before adding a single space for legibility to the start and end of each line, so your trailing ellipsis will be preserved without altering the line's display duration.

    More general extensions are possible, but I'll reserve those until the need arises. Paul's written some songs in 3:4 time, so that shouldn't be too far in the future.


    Here's the final result. Note how it changes text precisely on the first beat of the bar throughout. A little distracting of course when Paul's singing anticipates this point, but that's by design, and it's doing just what I asked. Precisely positioned lyric captions with the absolute minimum of time, cost, effort and fuss.

    Thursday, 22 April 2021

    Union Card (Paul O'Brien)

    Song written by Paul O'Brien. Guitar & vocals by Paul O'Brien.
    Additional instrument parts written & performed by John Michael Kerr.
    Sound production & captioning by John Michael Kerr.

    Instrumentation

    1. Video - Paul's original iPhone recording
    2. Vocals - Condenser mic through Behringer UMC204HD
    3. Guitar - Fender semi-acoustic
    4. Bass - Tension AAS "Pick Bass"
    5. Drum - Mind Flux "Drums Dirty Kick"
    6. Piano - East Village "Grand Piano"
    7. Tubular Bell - BBC SO Discover
    8. Spiccato - BBC SO Discover
    9. Violins - BBC SO Discover
    10. Horns - BBC SO Discover

    My First 10 Channel Mix

    Two weeks after filling out the requisite survey form, I receive my free licence for Spitfire Audio's "BBC Symphony Orchestra - Discovery" in the email. Under the circumstances, you might agree this track shows considerable restraint in the orchestration department.

    Work begins with the now-familiar process of stitching Paul's original YouTube video download, bar by bar, then note by note, to the metronome. Then the separate audio-only file, vox in the left, gtr in the right, is also stitched in the same manual process. Of course the transients don't agree everywhere, this track being distinct from the iPhone microphone feed, so multiple passes are needed to resolve unwanted echoes and phasing effects, if the extra ambience afforded by separate audio signals is to be enjoyed. The very occasional Bob Ross moment yields a happy accidental effect that's actually worth keeping.

    Update: see later articles. Phone audio has been removed at Paul's request. He is the boss! (no, not that Boss, though not for want of trying...)

    Next, the just-stitched audio is split into two tracks, Vocals and Guitar, so that a Mono effect can be applied to each, isolating just their side of the stereo signal and allowing them to be treated independently in Ableton Live. At this stage the iPhone audio and the Guitar are sent off to opposite sides of the sound stage, to think about what they've done. The Vocals-only track is kept central, and as usual, rewarded for good behaviour with a -12dB A-Reverb return track input.

    MIDIs

    Bass is the first MIDI channel to be added. First the root notes of the chords are played, then figures are written around these to complement the melody. A single, low kick drum is next, one solemn beat to the bar, with a double kick evoking a heartbeat at the end of each verse (there is no chorus). Then, a piano part to complement the guitar backing. A low tolling tonic tubular bell, bang in the middle of every third bar. Then the rest of the orchestral parts: violins alternating spiccato and long, before finally overlapping with a quartet of French horns.

    Critical Response

    Initial comments from Paul's Facebook page:

    • Beautiful song. Beautiful melody 🎶
    • This is magnificent Paul... completely breathtaking! You’ve told this miner’s story and brought him to life so clearly. Everything about it is perfect.. lyrics, melody, vocal, production and the b&w video is inspired. BRAVO!!! 👏👏👏👏👏❤️❤️
    • Top class
    • Lorretta Lynn, Bryan Ferry
    Okay, the first one was actually from my sister-in-law, but still...

    Previously: Wash Away This Pain

    Next time: Midnight Sky Of Blue

    Sunday, 18 April 2021

    Wash Away This Pain (Paul O'Brien)

    Song written by Paul O'Brien. Guitar & vocals by Paul O'Brien.
    Additional instrument parts written & performed by John Michael Kerr.
    Sound production & captioning by John Michael Kerr.


    Instrumentation

    1. Video - Paul's original iPhone recording (audio not used)
    2. Vocals - Condenser mic through Behringer UMC204HD
    3. Guitar - Fender semi-acoustic
    4. Piano - Grand
    5. Violins 1 - BBC SO Discover
    6. Violins 2 - BBC SO Discover
    7. Violins Spiccato - BBC SO Discover

    Production Notes

    Revisited to remove phone audio.

    Critical Response

    From Paul's Facebook page:

    • WOW!!! Absolutely STUNNING!! You should SO have a record deal Paul 🙏👏👏👏❤️
    • get it sorted! 🙏

    Next time: Union Card

    Saturday, 3 April 2021

    Man With His Guitar - Paul O'Brien

    My Score Here

    I've dabbled previously with music recording in Audacity, and composing in MuseScore, but if you're ever going to learn some serious Digital Audio Workstation (DAW) software, then the middle of a pandemic is a good place to start. So when last Christmas my employer, a manufacturer of computerised spectroscopes, found their Chinese order book collapsing, and started applying a LIFO protocol to HR, I found myself in the ideal position finally to scramble up the learning curves of Ableton Live and the Reason Studios (formerly Propellerhead) Reason Rack.

    A Man, A Guitar...

    Let me introduce you to my school friend Paul O'Brien, aka Man With His Guitar. Paul has been singing as a hobby ever since I've known him, stopping only for meal breaks and milkshakes, over the past 45+ years. Last May he started uploading covers to his own YouTube channel, soon to be followed by an increasing number of his own compositions. The format of these videos is as simple as the channel name implies: Paul and his handsome Fender guitar, sitting in front of his phone, singing a wee song.

    Several factors in Paul's setup make him an ideal subject for a case study in learning music production. The most important one is that he can hold a note. I can't hold a note. Paul's talent in this area means there's always something worth preserving, enhancing, bringing out in one of his performances. Not only can he hold notes, he can let them resonate and inflect them with passion, vulnerability, irony, pathos, resignation - an impressive emotional spectrum.

    Paul's choice of covers, and more importantly his own compositions, range from steady rockers to soft ballads. This gives the producer a good breadth of material to work with, trying to find the best opportunities to add subtleties in the service of the song, while remaining resolutely in the background.

    Challenges?

    Of course there must be challenges, else what's to produce? Paul's performance philosophy can be summed up as "one take, warts and all". Which I find must be respected. Vocal talent can be an extremely fragile gift, and whatever gets you into the zone, deserves to be treated as indispensable. So if I was to produce his recordings, my source material each time would be that one video performance recorded on his phone, vocals and guitar coming together simultaneously through effectively one (stereo) microphone.

    Siri can be an interfering nuisance. I read last year about one techno DJ who found his recordings unexpectedly blank, because the ghostly AI in his phone had mistaken his music for road works in the street, and helpfully removed it from the conversation. Paul didn't quite disappear from his own videos, but it can't be productive to have such unknown levels of digital processing going on during your recordings. Added to that, Paul's soundtracks often included phone alarm and watch chimes, creaking furniture, a host of extraneous noises. One take, warts and all, indeed. The skill of pasting clips between parts of a song, to cover up a dinner gong, is quickly learned.

    Timing

    Something Paul adds to his work is an abundance of time variation. This takes many forms. Bars speed up and slow down, acquiring extra beats while a chord is hunted, a note is pecked, or a fingerpick inadvertently adds an extra digit. Emotional content contributes still more wow and flutter. Much of this is artistically valid, and in fact there have been times when I've had to give up trying to achieve any kind of synchronisation with the metronome, and just add instrumental parts playing along in variable tempo as if in live accompaniment. See Forever True below for an example of this.

    Normally however, I'll start by warping the performance to first get the bars into a steady tempo, then if necessary, do the same for individual beats, strums or string picks. This makes it so much easier to add accompanying parts, such as drums, bass, guitars, piano, organ, strings, brass, woodwind - there are examples of all of these in the table below. And if necessary, automation can be used in the final stages of production, to re-apply any tempo variations felt artistically valid and vital.

    Video

    Originally I would rip the audio from the video file, then warp that bar-by-bar to obtain the first track. Both Ableton Live and Reason have excellent warping facilities, at once visual and incredibly easy to use. Once I'd added whatever additional instrument parts it called for, I'd have a candidate audio mix, which seemed to be the destination. Then one day I learned Ableton can work with video clips just as easily, and almost as comprehensively, as audio ones, and started about stitching the original video back on to the newly produced audio. After a few times working like this, I got to that "duh" moment where I realised it's possible to skip the audio rip stage altogether, and work directly with the source video file.

    Note: with Ableton Live 10, video import and export was only available in the more expensive Standard and Suite editions. With the recent release of Live 11, it has now been added to the Intro edition too. Good times.

    The Songs

    Here is a list of the songs I've produced so far. For comparison, the originals are still available on Paul's own YouTube channel and Facebook page. Here I have only provided links to the final produced MP3 (audio) and MP4 (video) versions. Unless otherwise stated, these are Paul's own compositions, and his copyright.

    March 2021

    MP3 - MP4 - If You Could Read My Mind (Gordon Lightfoot cover)
    MP3 - MP4 - You're My Soul Concern
    MP3 - MP4 - Go Softly Into the Night
    MP3 - MP4 - When I'm Gone
    MP3 - MP4 - This Land
    MP3 - MP4 - Forever True
    MP3 - MP4 - It Has To Be Tonight
    MP3 - MP4 - Case Full of Broken Dreams

    April 2021

    MP3 - MP4 - Forever Young (Bob Dylan cover)
    MP3 - MP4 - Too Much To Say
    MP3 - MP4 - Tomorrow Belongs to Yesterday 
    MP3 - MP4 - Hurt (Trent Reznor / Johnny Cash cover)
    MP3 - MP4 - Keep A Light On In Your Heart
    MP3 - MP4 - This Road I'm On 
    MP3 - MP4 - Wash Away This Pain 
    MP3 - MP4 - Union Card 
    MP3 - MP4 - Midnight Sky Of Blue
    MP3 - MP4 - Stations Of The Cross


    In Future

    I've literally lost count of the number of times Paul has asked me to boost the vocals, which given the above setup, is of course almost impossible without simultaneously boosting his guitar. Not entirely impossible mind you, some gains can be made with filtering (pun intended), but it's certainly difficult and - at least on my budget - unsatisfactory (there are AI megabuck solutions offering stunning results). I think I might have talked him into giving me a secondary audio source by plugging a condenser mic and his semi-acoustic guitar into the left and right channels of a PC audio interface, and recording these into Audacity at the same time as doing his existing phone camera capture. It's still far from ideal; there will be crosstalk, particularly acoustic guitar pickup in the condenser mic, if not vice-versa; but it should be a great improvement on what we currently have.

    Now, this will obviously involve more work, and seems to signal a return to the process of working with ripped audio and re-stitching with the video component at the end. This will be even more significant should I decide to use the phone audio as an additional source for its ambience, since there will be ample opportunity to introduce unwanted phasing and echo effects - the trick will be to stitch so carefully as to keep only the wanted ones. Will report back here as soon as results are available for examination.

    Update (5 Apr 2021)

    Success! Voice in the left channel, guitar in the centre-right, which is just about as good a separation as I was hoping for, well done us.

    Stitching the warped AV components together has indeed turned out to be rather more difficult and time consuming than before, since the software couples to different sets of transients across the audio sources, due to ambience differences, microphone positions, etc. However the results are well worth the extra effort on both our parts, being at times almost as good as a full, two-take double tracking of the vocals, as well as a three-mic guitar setup - acoustic pickup, phone mic, and leakage through the cardioid condenser mic, contributing three distinct audio sources for the guitar. And when it becomes too difficult to match transients, there's always the option of dropping the audio component of the video down to a faint echo, or muting it completely.

    Thursday, 10 November 2016

    FLAC Forensics

    Frequency Fingerprints

    I was asked by a friend if it was possible to check whether some downloaded files were actually faithful to the original WAV format entities, or whether they had in fact been rehydrated from an unfortunate, lossy intermediate MP3 excursion. The files in question were FLAC compressions of the original 3½ hour, 42 track Analord series of electronic pieces by Richard D. James, most of which were only ever issued on 12" vinyl by the artist's now defunct Rephlex Records outlet.

    Update: My personal RD James expert informs me that these original 42 tracks were also released in lossless digital format on Rephlex, and that some (or all?) of the subsequently released additional, digital-only tracks were also added to these by Rephlex.

    I loaded the first of these files, SteppingFilter 101, into Audacity, and took a look at the frequency domain graph (Analyze|Plot Spectrum...). After a brief complaint about only being able to analyze 237.8 seconds of audio at a time, the result was this:


    Notice the slight uptick at the extreme right (high frequency) end, around 22kHz. This represents extraneous noise generated by the digital sampling process, which in this case appears to have been set naturally enough to the CD standard stereo setting of 44.1kHz. This effect will be present in any rip, at some frequency or other, and is of a different kind from the artefacts introduced by MP3 processing.

    Next, I used FooBar2000/LAME to convert this file to MP3 format, using the highest available quality, Constant Bit Rate standard preset, namely 320kbps CBR (actually LAME can handle non-ISO bit rates of up to 640kbps via its freeformat option, but very few MP3 players can handle such files).

    The result of this 320kbps conversion has a very obvious steep cutoff at about 20kHz:


    Any attempt to convert this back to the WAV format will preserve this telltale high frequency cutoff. Does this mean we can be confident that the source file represents a good, high quality, uncompressed rip from the original vinyl? I would say confident, yes; certain, well, that's another bottle of kippers. We haven't ruled out nonstandard MP3 or other shenanigans with this test alone, but those compression antics are at worst extremely unlikely.

    Saturday, 3 September 2016

    Sundry Surround Sound Recordings

    Planned Obsolescence

    At the time of purchase in May 2015, my current universal (DTS/SACD/DVD-A/Blu-ray) player, a Pioneer BDP450, cost me a featherweight £159. Just over a year later it's "unavailable", unless I'm willing to settle for a refurbished model from Ebay. Reasonably priced multichannel DTS/SACD and DVD-Audio players are becoming really hard to find, even from the manufacturers who invented these formats. At present the best available options appear to be:
    • PIONEER BDPLX58 (£449 at Richer Sounds)
    • CAMBRIDGE CXU (£799.95)
    • OPPO BDP105D (£1,099)
    • PIONEER BDPLX88 (£1,099)
    No wonder then that collectors of surround sound DVD-Audio recordings, and even more so those of multichannel DTS media or SACDs, are feeling increasingly under siege these days. For how much longer will we be able to play these purchases? How many more times will we be able to afford a new player, when the last one packs in and its perishing rubber wheels and belts and lasers can't be replaced?

    This is a partial list of my surround sound recordings by format. It will let me sit and grieve as first DTS, then SACD, then DVD-A, and finally (sooner than you'd think!) Blu-ray playback become impossible. Then I will at least be able to see at a glance each month, exactly what fraction of my collection has now become permanently unavailable to me. It's also a work in progress, since I have no intention of losing the bad habit of buying these wonderful recordings; currently I'm looking forward to the much-delayed Steven Wilson remixes of the early Roxy Music albums.

    Top 100+ Speciality Multichannel Studio Mixes

    This first table lists recordings where a studio engineer (usually Steven Wilson or Jakko Jakszyk ;-) has carefully pored over the source material, and arranged things in space to produce a curated, meticulously arranged, surround sound experience.

    Artist or ComposerAlbum TitleYearPhysical Media
    SACDDVD‑ABlu‑ray
    Ian Anderson Homo Erraticus2014✓
    Bach Bach Classics 17xx✓
    Bass CommunionLoss2006✓
    The Beatles Love 2006✓
    Beethoven Beethoven Classics 18xx✓
    Symphony No. 6 "Pastorale" 1808✓
    BlackfieldBlackfield V2017✓
    David BowieThe Rise and Fall of Ziggy Stardust...1972✓
    CaravanIn the Land of Grey and Pink 1971✓
    Eagles Hotel California 1976✓
    Hell Freezes Over 1994✓
    ELP Tarkus 1971✓
    Trilogy 1972✓
    Brain Salad Surgery1973✓
    Flaming Lips Yoshimi Battles the Pink Robots 2002✓
    Fleetwood Mac Rumours 1977✓
    Genesis Trespass 1970✓✓
    Nursery Cryme 1971✓✓
    Foxtrot 1972✓✓
    Selling England By The Pound 1973✓✓
    The Lamb Lies Down on Broadway 1974✓✓
    A Trick of the Tail 1976✓✓
    Wind & Wuthering ✓✓
    ...And Then There Were Three... 1978✓✓
    Duke1980✓✓
    Abacab1981✓✓
    Genesis1983✓✓
    Invisible Touch 1986✓✓
    We Can't Dance1991✓✓
    Gentle Giant Three Piece Suite 1970-2✓
    Octopus 1972✓
    The Power and the Glory 1974✓
    Handel Handel's Water Garden 17xx✓
    Gavin Harrison Cheating the Polygraph 2015✓
    Jethro Tull Stand Up (The Elevated Edition) 1969✓
    Benefit (A Collector's Edition) 1970✓
    Aqualung 1971✓
    Thick as a Brick1972✓
    A Passion Play 1973✓
    War Child 1974✓
    Minstrel in the Gallery 1975✓
    Too Old to Rock'n'Roll: Too Young to Die! 1976✓
    Songs from the Wood 1977✓
    Heavy Horses 1978✓
    King Crimson In the Court of the Crimson King1969✓
    In the Wake of Poseidon 1970✓
    Lizard ✓
    Islands1971✓
    Larks' Tongues in Aspic1973✓
    Starless and Bible Black 1974✓
    Red ✓
    Discipline1981✓
    Beat1982✓
    Three of a Perfect Pair1984✓
    THRAK1995✓
    Radical Action (To Unseat The Hold...) 2016✓
    Marillion Misplaced Childhood1985✓
    The Moody Blues Days of Future Passed 1967✓
    On the Threshold of a Dream 1969✓
    To Our Children's Children's Children ✓
    Seventh Sojourn 1972✓
    Mozart Mozart Classics17xx✓
    Mike Oldfield Tubular Bells 1973✓
    Hergest Ridge 1974✓
    Ommadawn 1975✓
    Five Miles Out 1982✓
    OpethStill Life 1999✓
    Deliverance & Damnation 2002/3✓
    Watershed 2008✓
    Heritage 2011✓
    Anthony PhillipsThe Geese & the Ghost 1977✓
    Wise After the Event 1978✓
    Slow Dance 1990✓
    Pink Floyd Atom Heart Mother (Devi/Ation, quad) 1970✓✓
    Echoes (Reverber/Ation, quad) 1971✓✓
    Meddle (Reverber/Ation, 5.1) 1971✓
    The Dark Side of the Moon 1973✓✓
    Wish You Were Here 1975✓✓
    Porcupine Tree Stupid Dream 1999✓
    Lightbulb Sun 2000✓
    Deadwing (2 copies, 1 signed) 2005✓
    Fear of a Blank Planet2007✓
    The Incident2009✓
    Riverside Love, Fear and the Time Machine 2015✓
    Roxy Music Roxy Music 1972✓
    Avalon 1982✓
    Schubert Schubert Classics18xx✓
    Simple Minds New Gold Dream (81-82-83-84) 1982✓
    Sparkle in the Rain 1984✓
    Once Upon a Time 1985✓
    Steely Dan Gaucho 1980✓
    Everything Must Go 2003✓
    T. RexElectric Warrior1971✓
    Tchaikovsky Tchaikovsky Classics 18xx✓
    The Nutcracker 1892✓
    Tears for Fears Songs from the Big Chair 1985✓
    Trondheim Solistene Divertimenti 2008✓✓
    In Folk Style 2010✓✓
    Rick Wakeman The Six Wives of Henry VIII 1973✓
    The Myths and Legends of King Arthur... 1975✓
    The Who Tommy 1969✓
    Quadrophenia 1973✓
    Steven Wilson Insurgentes 2009✓
    Grace for Drowning 2011✓
    The Raven that Refused to Sing 2013✓✓
    Drive Home ✓
    Hand. Cannot. Erase. 2015✓✓
    4½ 2016✓
    To The Bone 2017✓✓
    XTC Drums and Wires 1979✓
    Skylarking 1986✓
    Oranges & Lemons 1989✓
    Nonsuch 1992✓
    Yes The Yes Album 1971✓✓
    Fragile (2002 - Rhino) ✓
    Fragile (2015 - Panegyric) ✓✓
    Close to the Edge 1972✓✓
    Tales from Topographic Oceans 1973✓✓
    Relayer 1974✓✓

    Notice that most of the Yes titles are double entries (in fact Fragile is a triple): the DVD-Audio and Blu-ray editions of these are of course equally essential.

    The Loneliness of the Long Interval Musicologist

    The Year column is problematic. Every recording has its place on multiple chronologies; for example, the life and development of its composer, its conductor, and its performing artist(s). The difficulty is that different performances naturally emphasise disparate chronologies, and a single date field in a table or database struggles to accommodate these variations.

    For the historical study of musical development, the time stamp of primary interest is the date of composition. Sadly this is not recorded in typical media metadata, such as the ID3 tags on MP3 files. The "Year" recorded there represents the release date - when the particular edition was issued. Now, for most "popular" music (in the strict Amazon.com sense of "anything non-classical"), this is close enough to the date of composition; but for all of the recordings listed here, without exception, the release date for the multichannel edition is many years later than that of first publication of the original material, and the problem is only worse in the case of classical works.

    Generally I've tried to get as close as possible to the date of composition. That means for popular works using the year of first issue, and for classical, the historical year (or century, for compilations) of composition. Still there remain intractable inconsistencies. For example, all of the material on the Beatles' "Love" album was recorded and issued long before Cirque du Soleil went shopping for a soundtrack in 2006. Finally, there's Daniel Barenboim. When the focus of a classical recording is neither composer nor performer, but instead a famous conductor, then I use the performance date.

    Live Surround Sound Music Videos

    This second table lists live video recordings of musical performances that just happen to have a surround sound component, often limited to a feeling of ambience in the hall where the recording was made. These are the second class citizens of the surround sound community, and this collection listing will be incomplete.

    Artist or ComposerAlbum TitleYearPhysical Media
    DVDBlu‑ray
    AshTokyo Blitz2001✓
    Daniel Barenboim Knowledge is the Beginning / The Ramallah Concert 2008✓
    Neujahrskoncert 2009 2009✓
    Europakonzert 10 2010✓
    Mahler Symphony No. 9 ✓
    The Salzburg Concerts 2011✓
    BlackfieldNYC - Blackfield Live In New York City2007✓
    Dream TheaterLive at Budokan2004✓
    Score2006✓
    David GilmourRemember That Night 2007✓
    Led Zeppelin The Song Remains the Same1999✓
    Led Zeppelin2003✓
    OpethLamentations 2006✓
    The Roundhouse Tapes 2007✓
    Live at the Royal Albert Hall 2010✓
    Orphaned Land The Road to Or Shalem 2011✓
    Porcupine Tree Arriving Somewhere... 2006✓
    Anesthetize 2010✓✓
    Steven WilsonGet All You Deserve 2012✓✓
    Yes Symphonic Live2002✓
    YesSpeak2003✓
    Acoustic2004✓
    Live at Montreux 20032007✓
    Youssou N'DourLive at Montreux 19892005✓

    Monday, 16 May 2016

    Surround Sound Switch #7: Wrapping Up

    Spinning The Room

    This is a quick summary of the contents and conclusions reached in my recent series of six articles on the subject of Surround Sound Stage Rotation switch designs and prototypes. The series is about various ways of rotating the sound stage of a surround sound / home cinema audio system, so as to make any chosen wall or corner the focus of the action.

    Said action takes place in an arena I've dubbed the octoroom. This is a bit like a normal rectangular room, but with a satellite speaker in every corner, and another in the centre of each wall.

    Part 1: The Mother Of all Relay Boxes

    I start out by examining the ready-made solutions available in the market. This doesn't take too long, as there are none. The hopelessness of seeking help from the audio kit manufacturers is bemoaned.

    I spend most of our session together longing for an earlier time, when things like the MORB-1 were available in shops.

    Part 2: Rolling your own Commutator

    I detail my personal colour scheme for octoroom wiring, explaining its minor deviations from the relevant standards. Then it's on to another pipe dream, this time involving acres of pristine copper plated (or more likely brass, or other alloy) substrate. An imaginary comb made of brushes is used to illustrate the ideal to which our prototypes can hopefully converge.

    I spend most of our session together longing for an earlier time, when such commutators were available in shops.

    Part 3: Bulgaria (rotary switches)

    The ideal 8-pole commutator can be simulated by helically wiring a suitable stack of wafer switches. I discover 7P8T palladium contact rotaries for sale in Bulgaria, and buy them for research. They turn out to be ex-telecomms system components, too fragile, difficult to wire, and otherwise unsuitable for audio use. But they inspire a passive rotary switch design, which eventually becomes my first successful prototype.

    A new feature dubbed Mode 5 is introduced, for the specialist who needs to analyse custom curated surround sound music recordings. It allows a 5.x remix to be "stretched out" over the whole 7.x room, without adding in any sound processing by the receiver.

    Now that concrete prototypes are beginning to emerge, I describe a scheme for quickly and conveniently swapping them in and out of the home cinema system. The scheme is based on Bulgin 8-pin, cable- and panel-mounting, plugs and sockets.

    Part 4: Group Theory (toggle switches)

    The mathematical area of permutations teaches that a single 8PDT switch, suitably wired, can rotate our sound stage through any single angle that's a multiple of 45°. Such rotations can also be composed, or applied one after the other, simply by stringing two or more such switches in series, in any order. So, we can choose a suitable chain of three "basis rotators", say 45°, 90° and 180°, and by selectively turning certain ones on and off, achieve any multiple of the atomic 45° rotation.

    Eight pole toggle switches exist, albeit outside the unspoken, hobbyist budgetary scope of this series. But usefully, permutation theory also shows that a safe implementation of the 90° rotation can equally be achieved by splitting our 8PDT switch into two more readily and cheaply available 4PDT units ganged together, and that the 180° can similarly be reached by this means, or even by ganging together four DPDT units.

    What is meant by safe in this context, is that under failure conditions, when one or more of the component switches fails to operate, no damage other than a seriously mixed up surround sound image will be caused. Amplifier outputs will not become cross-connected, nor asked to drive two or more loudspeakers in parallel. Sadly, the same can't be said about the 45° rotation stage.

    There's a brief, unintelligible diversion, something about binary clocks, I dunno...

    I make two more successful passive prototypes based entirely on 4PDT toggle switches - first some big Hong Kong ones with screw terminals, then smaller switches with solder lugs. Each prototype contains a 90° and a 180° rotator, as well as the new Mode 5 feature, which takes up one further 4PDT switch for a total of five. The 45° rotator has been dropped temporarily, as there's no easy way to guarantee that its two associated 4PDT switches will always be operated simultaneously and kept forever out of the potentially destructive one on, one off state.

    Part 5: Relayer (electromagnetic relays)

    Essentially the same audio circuit can be transcribed from the toggle switches in part 4 to the 4PDT electromagnetic relays in this part. With the addition of a 12V PSU and a 4-bit hexadecimal thumbwheel switch, prototype number 4 - the first active device in the series - is born.

    The 45° rotator is reintroduced, since the two 4PDT relays that constitute it can now be guaranteed driven together and kept synchronised. Even under rare fault conditions, e.g. a relay coil burning out, the risk of damage can at least be mitigated by assessing which failure mode - amplifier outputs shorted together, or loudspeakers becoming paralleled up - is the less serious, and wiring the switch contacts accordingly. A free online circuit simulator is used to pre-verify the audio wiring schematic.

    I finally have a full 8-position, manually operated, prototype sound stage rotator.

    Part 6: Arduino (remote control)

    No sooner has it arrived, than the hex thumbwheel switch is replaced by an Arduino Uno, driving the relays and relay pairs through bipolar npn transistors. A wiring self-test program is written, seen operating in a YouTube video. This verifies again that all audio pathways are switched correctly, as the compass orientation rotates, and as Mode 5 is switched on and off.

    Home is an MB4 project box
    The test wiring is removed, and an IR receiver module is interfaced to the Arduino. Suitable IR codes are obtained by "sniffing" an old Sony BD player remote; these are then embedded into the code, and verified to operate as expected.

    Some speculation about future development occurs, but prototype number 5 feels like the logical end of this road. There's life after prototyping, of course. I still have to design a suitable custom PCB, using just the bare ATmega328P chip and a 16MHz crystal, so I can keep my Arduino Uno board for future projects. Still have to stick it all in a box. And so on and on...

    Acknowledgements

    Thanks to my wife for putting up with (a) so many odd deliveries of random munitions from Amazon, Ebay, Maplin (hi Scott!) and RS Components, not to mention international arms shipments from USA, Hong Kong, Germany and Bulgaria; and (b) the too many hours I spent locked away in the man-cave, playing with screwdrivers, soldering irons, and ticking devices bristling with hundreds of multicoloured wires.

    Special mention to Georgi, my Bulgarian rocket scientist colleague, for pushing me to the Arduino limit, and convincing me there would be merit in these investigations. Without his input, I'd have contented myself with a twisting plug and socket manual solution.

    The End

    Thursday, 5 May 2016

    Surround Sound Switch #6: Arduino (remote control)

    SparkFun Electronics Arduino Uno R3
    Previously:
    Mother Of all Relay Boxes
    Rolling your own Commutator
    Bulgaria (rotary switches)
    Group Theory (toggle switches)
    Relayer (electromagnetic relays)
    Adding remote control to the relay-based prototype can be fairly trivial, since quite often the work has mostly been done for us already by others. One such easy route is via Arduino and infra-red, for which many IR receiver modules are cheaply available. Also available incidentally are WiFi and Bluetooth modules for Arduino, not to mention the fully Wi-Fi integrated MKR1000 and Uno WiFi, so there's no shortage of options. But today, I'll just be looking at IR.

    Arduino pins driving transistors driving relays.
    The Arduino Interface

    Regardless of the connectivity solution adopted, the first requirement is for the Arduino device to take over operation of the four signals controlling the seven relays. At the moment these terminate at the thumbwheel switch, which can selectively operate one or more coils by connecting their lower ends to 0V. In the case of a relay pair, this results in a current of 150mA sinking through the switch contact - much more than an Arduino digital output can either sink or source (20mA continuous recommended, 40mA absolute max).

    The solution is to use a transistor, as shown in this circuit diagram, to amplify the current capacity between each Arduino output and its associated relay coil(s). Here I've used my old favourite, the silicon bipolar npn device; MOSFETs are another option. The relay drivers are on pins 2 (45°), 4 (90°), 7 (180°), and 8 (Mode 5). The four so-called freewheeling diodes (e.g. 1N4007), slung across the relay coils in reverse, protect the transistors from the back EMF generated when the highly inductive load is switched. Now when one of these four Arduino outputs goes high (+5V), current flows through a resistor into the transistor base, switching it on. This allows a larger current to flow from the +12Vdc rail through the relay coil(s) and the transistor to 0V. Any general purpose npn transistor with the following specifications will do:
    min DC current gain hFE ≥ 40
    max DC collector current IC ≥ 200mA
    max collector-emitter voltage VCEO ≥ 20V
    max total power dissipation Ptot ≥ 100mW
    The popular 2N2222 is one example of a suitable component, but note that its frequently cited European "functional equivalent" BC548 is actually ruled out by having too low a maximum collector current (100mA). Now let's choose an appropriate resistor value:
    Rmax = Vcc / (Imax / hFE) = 5V / (150mA / 40) = 5V / 3.75mA = 1.3kΩ.
    I'd probably recommend using 1kΩ or so for that extra 30% safety margin. If the base resistor value is too high, the base current will be too low to ensure the transistor saturates and remains outside its high dissipation, potentially destructive "linear" mode. By contrast, when in digital mode, the transistor is either fully off (collector current is zero) or fully on (collector-emitter voltage is essentially zero), so in each case, the power P = I * V ≈ 0.

    The IR Library

    The Arduino microcontroller development system has access to an excellent free IR control library, Arduino IRremote, by Ken Shirriff. Thanks Ken! This code resource both sends and receives infra-red signals. Many people have made use of this, including Jason Poel Smith, who very reasonably asks,
    Most of the buttons on a remote control are never used.
    So why not use them to control appliances and other electronics around your house?
    then goes on to do just that - repurposing any unused command on any of your IR remotes, to control an electrical outlet switch. He even includes a simple and easy-to-use learning mode, whereby a single additional button press is all you need to teach your electronics which new signal it has to respond to.

    The Command Set

    Our requirements are a little more complicated than controlling the state of a single relay, but not by that much. We have to drive three transistors to control the orientation, and a fourth for Mode 5. So, four digital outputs, rather than one? No big deal.

    Now for our UI commands. We'd like buttons to take us directly to a particular orientation, numbered maybe 0-7, maybe 1-8, or maybe mapped to the physical layout of a numeric pad - whatever you prefer. Two more buttons, to rotate from the current orientation by 45° increments, either left or right. A toggle, and/or two separate commands, to engage/disengage Mode 5. A reset button to set the orientation back to 0 and disengage Mode 5.

    Sketch

    Can't remember the last time the blog known as My Code Here contained any actual computer code, but anyway, here is the full Arduino sketch source for the project:

    /*
      RoomSpin
      Audio soundstage rotation switch for 7.x surround sound system with 8 satellites
      http://mycodehere.blogspot.co.uk/2016/05/surround-sound-switch-6-arduino-remote.html
      This code is in the public domain - created 6 March 2016 by John Michael Kerr
    */
    
    #include <irremote.h>
    #include <irremoteint.h>
    
    //#define TEST
    
    void setup()
    {
      setupRelays();
      #ifdef TEST
        setupTest();
      #else
        setupMain();
      #endif
    }
    
    void loop()
    {
      #ifdef TEST
        loopTest();
      #else
        loopMain();
      #endif
    }
    
    // Main program setup & loop
    
    void setupMain()
    {
      setupReceiver();
    }
    
    void loopMain()
    {
      long code = readReceiver();
      if (code)
        performCode(code);
    }
    
    // IR receiver handling
    
    const int pinIR = A5;
    
    IRrecv* receiver;
    decode_results code;
    
    void setupReceiver()
    {
      Serial.begin(9600);
      receiver = new IRrecv(pinIR);
      receiver->enableIRIn();
    }
    
    long readReceiver()
    {
      long result = 0;
      if (receiver->decode(&code))
      {
        result = code.value;
        Serial.println(result, HEX);
        receiver->resume();
      }
      return result;
    }
    
    // Command codes
    
    const long
      codeDigits[8] =
      {
        0xbeef0000,
        0xbeef0001,
        0xbeef0002,
        0xbeef0003,
        0xbeef0004,
        0xbeef0005,
        0xbeef0006,
        0xbeef0007
      },
      codeLeft = 0xbeef0008,
      codeRight = 0xbeef0009,
      codeMode5_ON = 0xbeef000A,
      codeMode5_OFF = 0xbeef000B,
      codeMode5_TOGGLE = 0xbeef000C,
      codeReset = 0xbeef000D;
    
    // Command codes for Sony BD (RMT-B119P)
    //
    //const long
    //  codeDigits[8] =
    //  {
    //    0x00090B47, // 0
    //    0x00000B47, // 1
    //    0x00080B47, // 2
    //    0x00040B47, // 3
    //    0x000C0B47, // 4
    //    0x00020B47, // 5
    //    0x000A0B47, // 6
    //    0x00060B47  // 7
    //  },
    //  codeLeft = 0x000DCB47, // Left arrow
    //  codeRight = 0x0003CB47, // Right arrow
    //  codeMode5_ON = 0x000E0B47, // 8
    //  codeMode5_OFF = 0x00010B47, // 9
    //  codeMode5_TOGGLE = 0x00066B47, // Blue
    //  codeReset = 0x000E6B47; // Red
    
    int compass = 0;
    bool mode5 = false;
    
    bool codeToMode(long code)
    {
      switch (code)
      {
        case codeMode5_ON:
          return true;
        case codeMode5_OFF:
          return false;
      }
      return !mode5;
    }
    
    int performCode(long code)
    {
      for (int c = 0; c < 8; c++)
        if (code == codeDigits[c])
          return rotateTo(c);
      switch (code)
      {
        case codeLeft:
          return rotateBy(-1);
        case codeRight:
          return rotateBy(+1);
        case codeMode5_ON:
        case codeMode5_OFF:
        case codeMode5_TOGGLE:
          return setMode5(codeToMode(code));
        case codeReset:
          mode5 = false;
          return rotateTo(0);
      }
      return 0;
    }
    
    int rotateBy(int eighths)
    {
      return rotateTo(compass + eighths);
    }
    
    int rotateTo(int eighths)
    {
      compass = eighths & 7;
      setRelays();
      return compass;
    }
    
    int setMode5(bool value)
    {
      mode5 = value;
      setRelays();
      return 0;
    }
    
    // Drive the relays
    
    const int pinCTRL[4] = {7, 8, 12, 13};
    
    void setRelayMask(int pin, int mask)
    {
      setPinMask(pin, compass, mask);
    }
    
    void setRelays()
    {
      for (int p = 0; p < 3; p++)
        setRelayMask(pinCTRL[p], 1 << p);
      setPinIf(pinCTRL[3], mode5);
      delay(100); // Let the relays settle.
    }
    
    void setupRelays()
    {
      for (int p = 0; p < 4; p++)
        pinMode(pinCTRL[p], OUTPUT);
    }
    
    // Low level I/O support
    
    void setPinIf(int pin, bool condition)
    {
      digitalWrite(pin, condition ? HIGH : LOW);
    }
    
    void setPinMask(int pin, int value, int mask)
    {
      setPinIf(pin, (value & mask) != 0);
    }
    
    // End of tab
    

    This listing shows placeholders for the actual IR remote codes generated by your remote. Run the program with the Serial Monitor enabled, then blast it with your own remote, making note of the hex code generated by each of your chosen command buttons. Then search my source for the string 0xbeef, and replace these hex constants with your own. The numeric keys (here numbered 0 to 7) are stored in order in the codeDigits array, and the command names following these should be self-explanatory.

    I'm currently using this prototype with codes for a Sony BDPS590 Blu-Ray player (remote control model number RMT-B119P), these are the codes in the commented-out section below the placeholders. Known affectionately to my wife and me as as "stubby buttons", this is a well-behaved remote - most buttons generate a single code followed by a stream of 0xFFFFFFFF, as long as they're held down. The only exceptions are volume up/down, mute, and the other TV buttons, whose output depends entirely upon which make & model of TV you've programmed it for. With other remote brands, be prepared to do a little C++ protocol tweaking to handle alternate and/or repeating code complications.

    Wire Test

    Last time I promised you a fully automated wiring test using just the Arduino Uno with no additional hardware. How are we going to achieve that with only 14 digital I/O pins available on the development board, when there are 19 or 20 terminations on our relay loom? Count them: 4 control inputs, and on the audio side, 7 or 8 inputs plus 8 outputs. Answer: by pressing the Arduino's six analog inputs A0-A5 into service. These work just as well as digital inputs, and bring the available total to exactly plenty. In fact I've already used A5 to interface the IR receiver module (pinIR in the code), rather than the default pin 11.

    Say we keep the existing pins 2/4/7/8 attached to the four coil controls, as in the diagram above. Now associate pins 3/5/6/9/10/11/12/13 respectively with the eight audio amplifier outputs. For test purposes these will take the place of the physical amplifier outputs in real life.

    Next, for the loudspeaker inputs, associate analog inputs A0-A5, operating in digital mode, with the first six, and pins 0/1 with the remaining two.  The IR receiver module must be disconnected from pin A0 during this test. Now all our test program needs to do is drive the coil controls with every binary pattern from 0 to 15, and for each pattern, walk a single bit (actually a logic zero) from the first audio amplifier output through to the last, checking that it appears only on the expected loudspeaker input pin, if any.

    Note the change in I/O terminology here. While designing the relay network, we called the amplifier signals inputs and the loudspeaker destinations outputs. That made sense from the viewpoint of the switch. Now in the Arduino software, from the perspective of the system testing the switch, our ins & outs are swapped around.

    Here is the source code for the wire test, which should be added as a new tab to the main code above. Then in the main sketch, remove the double slashes from the line //define TEST. Remember to undo this edit (and reconnect the IR receiver module) once the wire test is complete.

    /*
      WireTest
      A wiring test utility for the RoomSpin project
      http://mycodehere.blogspot.co.uk/2016/05/surround-sound-switch-6-arduino-remote.html
      This code is in the public domain - created 6 March 2016 by John Michael Kerr
    */
    
    const int
      pinIN[8] = {A0, A1, A2, A3, A4, A5, 0, 1},
      pinOUT[8] = {3, 5, 6, 9, 10, 11, 12, 13};
      
    int
      output,
      expected,
      actual;
    
    void setupTest()
    {
      for (int p = 0; p < 8; p++)
      {
        pinMode(pinIN[p], INPUT_PULLUP);
        pinMode(pinOUT[p], OUTPUT);
      }
      writeOutput(0xFF);
    }
    
    void loopTest()
    {
      for (compass = 0; compass < 8; compass++)
      {
        setRelays();
        for (int mask = 1; mask < 0x100; mask <<= 1)
        {
          writeOutput(mask ^ 0xFF);
          delay(50); // Let the outputs settle.
          readExpected();
          readActual();
          while (actual != expected); // Crash!
        }
        writeOutput(0xFF);
      }
      mode5 = !mode5;
    }
    
    void readActual()
    {
      actual = 0;
      for (int p = 0, mask = 1; p < 8; p++, mask <<= 1)
        if (digitalRead(pinIN[p]))
          actual |= mask;
        else
          actual &= ~mask;
    }
    
    void readExpected()
    {
      int mask = output ^ 0xFF;
      if (mode5)
        mask = useMode5(mask);
      mask <<= compass;
      if (mask > 0xFF)
        mask >>= 8;
      expected = mask ^ 0xFF;
    }
    
    int useMode5(int mask)
    {
      switch (mask)
      {
        case 0x01:
        case 0x40:
          return 0;
        case 0x02:
          return 0x01;
        case 0x20:
          return 0x40;
      }
      return mask;
    }
    
    void writeOutput(int value)
    {
      output = value;
      for (int p = 0, mask = 1; p < 8; p++, mask <<= 1)
        setPinMask(pinOUT[p], output, mask);
    }
    
    // End of tab

    There's one headache with using up all 20 I/O pins in this way. Serial communications normally proceed via Arduino pins 0 and 1. With these tied up, how are we to glean any diagnostic information form the wire test?

    My simple solution is first to add LEDs with series current limiting resistors to all twelve output pins (four relay drivers and eight audio channels). Now run the test, and jump into an infinite loop as soon as any unexpected result occurs. That's the function of this rather suspect looking line of code, with its barely noticeable empty loop statement:
    while (actual != expected); // Crash!
    All being well, these LEDs will flash binary patterns and masks, repeating one full test cycle every eight seconds. When the unthinkable happens, the LEDs become frozen, displaying in an unambiguous snapshot the state of all output signals, at the instant of fault detection. Yay diagnostics!

    Here's a short video of the wire test in action. It's a bit less dramatic than its title suggests. But if you've read this far, you know that already.



    In a past life, I worked with embedded systems and microcontroller projects, based on hardware such as the Motorola MC68HC705 series [pdf], for over 15 years (1980-1995). This is the first time I've used a high level language which I didn't have to design and implement entirely on my own. Okay, it's only C++ with a little preprocessor supplied syntactic sugar, but I'm still impressed. I like your brave new world!

    Future Expansion

    Hmm, so back into normal operation, and the Arduino Uno still has a bunch of those analog input pins free, eh. It's tempting to drive them with signals derived from the actual audio waveforms, suitably rectified and limited, then perhaps using some custom automatic gain control (AGC) code, translate those input levels to PWM brightnesses feeding a retro ring of eight front panel LEDs. When the audio is quiet, these LEDs could pull double duty by indicating the currently selected orientation.

    In fact that was the thinking behind the quirky output pin selections for the relay drivers and the IR receiver module. Since outputs PD3/5/6 and PB1/2/3 are capable of PWM operation, they're reserved for future LED driving duty. I'd be happy enough driving these LEDs in pairs just like the relays, but if you demand one LED per audio channel, you might want to reassign some I/O and use the Arduino Leonardo. That board offers an additional PWM output on pin 13, as well as extending analog input capability to several of the digital I/O pins.

    Any other additional features? Maybe we'd also like the switch to revert automatically to the default, powered-down state, after a few hours of inactivity - just so we don't accidentally leave the relay coils needlessly burning up the watts for weeks on end when not in use.

    Two Distinct Defaults

    Typically a switch like this will spends most of its life in just one particular orientation, with an occasional foray into a second, still less frequently a third, and so on. Obviously it's worth wiring the most frequently used orientation as the default one, which has been called "North" in my descriptions to date, and in which all seven relays are de-energised. Then for most of the time you can simply have the device unplugged or switched off, saving power and component life.

    Less obviously, the second most popular switch state might benefit from being stored in non-volatile memory, and selected automatically on power up. That way, whenever movie night, holiday projector time, or whatever other occasion rocks up, you need only power up, and the sound stage rotates instantly to the secondary setting, ready for the evening's entertainment.

    Such a fixed "secondary default" could easily be programmed with a few seconds' work. A better solution however might be to introduce a new command, allowing the current switch state to be saved in the Arduino microcontroller's non-volatile EEPROM memory with the press of a button, and subsequently, to be retrieved from there upon power up. Or to automate the process completely, write the state to EEPROM every time it's changed, so the switch effectively remembers its setting through a power cycle. Just be aware of the EEPROM erase/write limit of nominally 100,000 operations.

    The EEPROM storage requirements of this design are reasonably low, at one half of a byte.

    Next time: wrapping up.