Thinktank

Interesting times…

This week just gone, we not only had a state election here in Queensland, with a conservative government (LNP) returned to power… we also witnessed the US hold their federal election, and vote in a conservative party there too.

In both regions, the term supposedly is 4 years. Well, here I expect the 4 year term will be upheld… this has never been an issue before and while I do remember a time when our state parliament sat for a 3 year term, it never has been infinite.

Over in the US, there were rumblings along the lines of “we’ll fix it so you don’t have to vote anymore”. Make of that what you will.

Next year, Australia goes into federal election mode… While our mainstream conservative parties are nowhere near as right-wing as some of the minor parties (looking at you, FFP, ONP and KAP), and state politics is theoretically separate from federal, hearing Queensland LNP front-benchers contradict then opposition leader (and now Queensland Premier) David Crisafulli on issues like abortion really does feel like they’re echoing the right-wing governments overseas.

Of course, it was one of the right-wing minority party leaders, KAP’s Robbie Katter, that happened to toss that grenade into the mix… nearly de-railed the train entirely for the LNP. I think therefore this is just a taste of what we can expect next year: minor parties (especially conservative ones) throwing their smoke bombs into the debate whenever possible on all kinds of issues… and some of them drawing “inspiration” from overseas.

The previous LNP government wound up being a disagreeable mob that argued with everyone, Campbell Newman (who we had as local member here in the seat of Ashgrove) and his government were tossed out at the very next opportunity. I think they may have learned from that and will pull their heads in a bit more… we’ll see.

Their big platform was on youth crime, and their big headline remedy, “adult crime: adult time”, has been criticised as not having solved the problem anywhere else where it was attempted. There’s apparently some early intervention to try and address issues before they boil-over into major societal problems… that should have a positive influence… the efficacy of punishments though will need to be proven.

Federally… we’ve got different challenges now. The US threatening new tariffs will not only push up inflation in the US (a nice foot-gun you’ve got there, Trump), it’ll also spell trouble for Australian exporters, notably our mining operations. The rhetoric during this year seems to spell trouble for both the NATO and AUKUS alliances. If the US pulls out of these, Australia will be very isolated as the UK is on the opposite side of the planet and (thanks to Brexit) a financial basket-case.

A regression in the situation in Ukraine will make things unstable in Europe generally, if that spills over, the fact that we’ve got the UK as an ally may be meaningless as there’s a lot of ocean to cover for their aid to reach us. Closer to us is China and Taiwan, which is quietly simmering away… whilst Israel wages war with both Palestine and Lebanon.

Donald Trump’s rhetoric over the previous term does not endear a world of peace. Some have praised his manner of speaking as being “refreshing”… well it most definitely is different. Diplomacy is a game of subtle nuance. Always has been. I’m not sure shouty-shouty megaphone diplomacy will work. It didn’t work that well for Germany in the 1930s, and many today draw parallels between that time, and today’s US. The last US presidential debate between Trump and Kamala Harris gave us a pretty good peek as what we will probably get. Malcolm Turnbull’s “robust discussion” with Trump back in 2016 suggests as much too. For a few weeks I had this cartoon living rent-free in my head…

“Debating an idiot is like playing CHESS with a PIGEON… He’ll just knock pieces over then claim he won!” — my take on the US Federal Election 2024 posted to Mastodon. Yes, I am terrible at drawing people, but that does not stop me from trying my hand anyway. At least I didn’t use an AI!

Well, world leaders and heads of state alike, will be debating the pigeon for another four years.

Next year, it’ll be our turn in Australia. Federal parties will need to balance the urban and rural needs: this is an area where Queensland’s parties failed. Labor did really well in urban seats, but failed miserably in the regions. A similar pattern was seen in the US election, with most of those in rural areas, preferring the Republican party, whilst in urban areas, Democrats were favoured.

A party should not be solely representing just the regions or just the urban centres. They are being elected to represent both. Cost of living is a big issue right now, something a third world war will not improve. A world war might mean we in Australia are isolated, and unable to import a lot of things, making every day things a lot more expensive. So encouraging local production and level-headed diplomacy will be critical.

Healthcare is a big issue in the regions, especially for specialist services. As it happens, our food and minerals do not come from the CBDs of capital cities — so we really do need to be helping out there to make life more viable. This means hospitals should be aiming to provide what their patients need, not inflicting restrictive guidelines on people who have few viable alternatives.

Climate change will affect us all, urban and rural… we can’t rely on digging up former dinosaurs to fuel everything long-term… we’ve left it a little late to be constructing big nuclear plants. While smaller options exist (small modular reactors are used quite successfully on submarines), a big honking reactor the size of Tarong is a biiiig risk in Australia’s climate.

Yes, Europe has lots of them, but Europe built nearly all those decades ago, when they were not getting massive wildfires and 40°C+ temperatures. A small reactor that we can shut down, crane onto the back of a truck, and shift out of harm’s way might be useful for propping up parts of the grid in times of need. A reactor that is too big to move is a major risk in a flood or bushfire emergency, and we have had a longer and more frequent history of these than any part of the world that currently uses nuclear. Fukushima, despite the low number of people killed as a result of the reactor (most people in that disaster lost lives due to the tsunami), is not a blueprint for how to build a large reactor in a risky area.

Battery technology isn’t ideal right now, not sure I like the idea of dealing with bushfires that are lithium-enhanced… but lithium batteries are not the only option out there for fixed installations. This blog runs on dated but still useful AGMs. There exist other storage technologies which could be viable at scale and should be considered. A former manager of mine was keen on the Zebra battery, which is a form of molten-salt battery. I couldn’t source one for him in 2008, we ended up going with LiFePO₄ cells… but there is probably wisdom in using a battery that is fine with heat.

We’re likely to see a big influx of migration over the next few years, as conflict and hatred makes the planet overall a more dangerous place. We’re hearing the phrase “your body, my choice” a lot now, a phrase no woman deserves to have levelled at them, women are more than just brood stock.

Increasingly some governments have shown transgender attitudes as well, a group that does not choose their condition any more than a baby born without eyes chooses to be blind. Everyone has challenges, and everyone deserves assistance with their challenges whatever those happen to be. We shouldn’t be discriminating against people on the basis of the (sometimes unique) challenges an individual might face.

Neurodivergence also seems to be in the cross-hairs: if that ever gets imported into Australia’s mainstream politics, yours truly will be in the cross-hairs here! I’ve faced discrimination before (looking at you Hilder Road & The Gap State Schools).

Lots of people from these marginal groups will be on the move escaping discrimination. We need to do our best to ensure the same hate movement does not rise here: these are people that have a lot to give if given the opportunity.

Circling back to health for a moment too… COVID-19 still rages on, there was a pleasing-looking trend last month in Queensland hospitalisation statistics showing COVID-19 and Influenza cases well down a month or two back. Not zero, they’re not gone… but not as bad as they once were. Sadly it won’t stay that way. Over in the US, they’re talking of giving the portfolio of health to Robert F. Kennedy Jr, someone who seems keen to continue grinding Andrew Wakefield’s axe, and seems to be very much against current preventative measures for containing contagious disease. With H5N1 (bird flu) rearing its ugly head, the never really dealt-with and worsening COVID-19 situation over there, and diseases we thought we had beat like polio making a come-back… we may see some particularly nasty bugs hit our shores. Get ready for Pandemic 2.0.

So a lot in store for the next 4 years at least… I think Europe is going to play a major role in the medium term. They are already showing a lot of leadership over technical standards (we can thank the EU for universal charges on portable devices for example). Whilst it’s not all good news there (end-to-end encryption being a controversial issue), on balance they seem to be headed in a better direction than the US is right now. Here’s hoping cooler heads prevail and things settle down, but right now I think we need to buckle up for a bumpy ride!

My position on generative AI

As we enter 2024, one technology seems to be looming large over many facets of society. Back in the 1960s, the idea that a “machine” (“computers” were actually people who operated calculating machines) could “think” for itself and give “intelligent” answers was the stuff of science fiction.

Television shows like StarTrek and movies/books like 2001 popularised an ever-present voice-controlled assistant that could be hailed, and asked questions or given instructions. Most of these were benevolent (2001’s HAL being a notable exception).

Fast forward nearly 80 years, and we now have voice assistants from major technology vendors like Amazon (Alexa), Apple (Siri) and Google (“OK Google”). Microsoft tried to jump in on this too with Cortana in Windows 10, since removed. Alexa and Siri are allegedly bleeding their parent companies’ income as the novelty wears off… and so these technology firms are starting to look at what’s next.

The latest gold rush seems to be generative AI. This has been brewing for some time.

Many moons ago I recall mucking around with a markov chain plug-in that was embedded in Perlbot on IRC (no_body on the old Freenode network). Very crude, but it sometimes did generate somewhat coherent sentences. It was done for fun, ran on the scrap CPU cycles of an old PIII 550MHz server that also hosted this blog and acted as a web server. Nothing huge by any stretch of the imagination. No GPU in sight.

A few years ago, we started seeing articles about an AI system that could generate imagery. Fore-runners of the likes of DALL-E. Ask it to generate a beach scene, you’d get some weird psychedelic image which vaguely looked like a beach if you squinted right, but with odd things merged together, like a seagull merged into a railing or building. Faces were badly distorted, nothing looked “right”.

Unfortunately, I cannot recall where I saw the image I’m thinking of or what keywords to search that will summon it. Otherwise I’d show an actual example. (I think it was either on The Register or Ars Technica… most likely pre-pandemic.)

Fast forward to 2021, and yes, it could generate a vaguely believable image, but it still struggled with human anatomy. A good example of this is the faked Donald Trump arrest photo that was doing the rounds:

Donald Trump being arrested by police? No, this is an AI-generated image. (Source)

This was a big improvement on what came a few years before it, but it still had lots of visual defects.

This time last year, ChatGPT v3 was available to the general public, and it could passably converse with people. For a statistical model, it did a remarkable job of appearing “intelligent”, but ask it to perform some basic tasks, and it soon fell apart. Yes, it could generate code, but you’d constantly have to massage the prompt to get code that even compiled, let alone functioned the way required.

The big rub with all of this, is the extreme amount of computation required to render the result of a simple prompt. Whether the output be text, an image, audio or video… generative AI is often highly computationally expensive, requiring vast data centres crammed full with GPUs and special-purpose ASICs much like the cryptocurrency rigs of a few years ago. There are some small models that can run on your local computer. A top-of-the-line Raspberry Pi can just cram in some AI models with some trade-offs in accuracy, however you cannot train an AI model with such modest hardware.

Generating the models is the real sticking point: it requires vast compute resources, and in addition, lots of data. It’s Johnny 5 on steroids! Where is that data sourced from? More often than not, it is scraped from websites without authors’ consent. While some content is public-domain, there are examples where copyrighted material was used.

Yes, we can point and laugh when an AI hallucinates a watermark, but for the copyright holder or would-be user, this is really no laughing matter. Microsoft is already facing a lawsuit from The Times over Bing Chat (now Copilot) spitting out big chunks of copyrighted articles.

A human usually has a vague idea where they learned something, even if they can’t find it later… and based on that knowledge, they might have some idea whether such content can be legally used in some given context, or can at least ask. AIs typically do not tell you what source material was used in the construction of the output, nor is there any consideration given to whether you can legally use that material.

Some vendors try to make that your problem, MailChimp recently added an AI feature to its mailing list offering, but then made the user responsible for checking up whether the content it generated was appropriately licensed… and decided that your user-generated content was appropriate to feed the training of said AI engine.

It has been ruled in various courts that as purely AI generated content is not “human generated”, it is not eligible for copyright protection. (This ruling is why I was able to include the “Trump arrest” image above despite it not being “my work”.)

This is not the last we’ll see of this technology. AI is actually a very old term dating back to the very early days of programmable electronic computers, from ELIZA (which really was a testing ground for pattern matching, not AI at all!) and PARRY (which was the same idea expanded a little). It includes tools like expert systems. Anyone that’s dealt with open-source software will have seen one very famous expert system: make.

Having a system that can inspect a photo and then describe what is in the image along with reading out what text might be important, would be a game changer to the visually impaired. In this case, it’s simply describing what is there.

Having a text to speech tool that could be trained on recordings of the voice of someone who has lost their ability to speak (e.g. motor neuron), that the person could then use to communicate, would be a very noble use of generative AI.

The surviving members of The Beatles recently did this with the song “Now and Then“, taking old recordings of John Lennon’s demos, and basically doing some sophisticated signal processing to separate out the components so that a studio-grade recording could be produced.

The technology does have good uses. In both the latter cases, we’re not “putting words into the mouths” of these people, it’s their words, they chose them.

However, I think this year we’ll likely see its dark side, if we haven’t done already. Stephen Fry got a rude shock when he came across an audio book apparently “read” by him, except it was a book he had never actually read: it was the product of generative AI. Someone had trained a text-to-speech model on his voice, then fed this book into it.

Imagine someone using tools like that to dupe a work colleague into resetting a password and enrolling a new 2FA token over the telephone? Depending on where you work, that could have disastrous consequences.

For this reason, I’m particularly leery of systems that take audio or video as input. My workplace used to use Atlassian’s HipChat as a communication tool originally, and when that shut down, we migrated to Slack. At the moment it’s privacy policy and terms of service make no mention of the use of such tools. Zoom was forced to back down on AI use after a biiig user backlash. Microsoft won’t say how it is training its models, but seems hell-bent on jamming its Copilot everywhere it can cram it. They’re even talking of a new keyboard button dedicated for it.

For this reason, I flatly refuse to touch Microsoft Teams. Last time I used it (in my browser), it was for one particular meeting a couple of years ago… it picked up I had a headset, and used that for speaker audio, but when it came to the microphone, did it use the same place? Noooo… the line-in socket connected to an old Sony ST-2950F stereo tuner was more interesting!

Since then, it too has gotten the AI treatment, with little transparency on what that AI is trained on and what its functions are. It’s not clear what it is being trained on, and what the resulting data sets are used for. Furthermore, we’re to trust them to store such training data responsibly? The same mob that wrote code that accepted an expired and incorrectly signed digital certificate as an access-all-areas pass?

That said, the snake-oil salesmen are out in force, and the investors are going wild. We’re seeing ChatGPT-powered sales and service bots appear on all kinds of websites now (until they’re caught out). There are also lots of sites with AI-generated screed polluting search engine results. It’ll likely play a big part in the upcoming 2024 US Federal election. We’re in for a wild year I think.

I for one, do not use ChatGPT or its elk in my day-to-day work, and refuse to do so. My position on AI-infused tools like Microsoft Teams remains the same until such time as the AI feature is removed or its role better clarified.

I still have code up on Github as it was there prior to Microsoft’s purchase of that service: I don’t like that my code may be being used in this manner, however the worst case scenario is copyright infringement — removing my code from Github does not prevent this. I regard video and audio differently: as this can be used for impersonation, I am not going to willingly supply such a feed directly into a tool that may be training itself on it for purposes unknown to me.

Right now, LLMs (large language models) are approaching the “peak of inflated expectations” phase of the Gartner hype cycle. I figure they will die off before long before their actual utility comes to the fore. They may improve the accuracy of machine language translations, specialised ones might be able to give domain-specific advice on a topic (much like a fancy expert system), and they may be able to fill in the gaps where a human can’t be there 100% of the time.

They won’t be replacing artists, journalists, programmers, etc long-term. Some of us will possibly lose jobs temporarily, but once the limitations are realised, I have a feeling those laid off will soon be fielding enquiries from those wishing to slay the monster they just created. It’ll just be a matter of time.

Mastodon experiment: a few months in

A little while back I decided to try out Mastodon, deploying my own instance running as a VM on my own hardware. This was primarily done to act as a testing ground for experimenting with integrating with it, but also as a means of keeping up with the news.

The latter is particularly important, as I no longer have the radio on all the time. I might hear a news item in the morning, but after the radio switches off, I’m unlikely to turn it back on until the next working day. A lot of news outlets moved to Twitter over the past decade, but with that site in its death throws, the ActivityPub ecosystem is looking like a safer bet.

Not many outlets are officially using this newer system yet. There are a few outlets that do publish directly to Mastodon/ActivityPub, examples being Rolling Stone, The Markup (who run their own instance), STAT, The Conversation AU/NZ and OSNews. Some outlets aren’t officially posting on ActivityPub, but are nonetheless visible via bridges from RSS (e.g. Ars Technica) and others are proxies of these outlets’ Twitter accounts (e.g. Reuters, Al Jazeera, The Guardian, Slashdot). Others are there, but it’s not clear how the material is being mirrored or if they’re official.

There’s also a decent dose of satire if you want it, including satirical news outlets The Chaser and The Shovel, and cartoonists such as Christopher Downes, David Rowe, Fiona Katauskas, Jon Kudelka, David Pope, Cathy Wilcox and Glen Le Lievre.

As you can gather, a big chunk of who I follow is actually news outlets, or humour. There are a few people on my “follow” list whom are known for posting various humour pieces from elsewhere, and I often “boost” (re-post) their content.

Meta (who run Facebook) have made noises they might join in with their own Twitter-clone in the ActivityPub fediverse. I wouldn’t mind this so much — the alternatives to them doing this is: (1) the rest of us needing dozens of social media accounts to keep in touch with everybody, (2) relying on the good will of some mega-site to connect us all, or (3) forgoing being in touch altogether.

I tried option (1) in the early part of this century, and frankly I’m over it. Elon Musk dreams of Twitter becoming option (2) but I think the chances of this happening are buckleys and none. (3) is not realistic, we’re social beings.

Some of these instances will be ad supported, and I guess that’s a compromise we may have to live with. Servers need electricity and Internet to run, and these are not free. A bigger cost to running big social networks is actually managing the meat-ware side of the network — moderation, legal teams to decide how moderation should be applied, handling take-down notices… etc.

ActivityPub actually supports flagging the content so the post is not “listed” (indexed by instances’ search engines), private posts (cannot be boosted, visible to followers only), even restricting to just those mentioned specifically. I guess there’s room for one more: “non-commercial use only” — commercial instances could then decide to they forgo the advertising on that post, or do they filter the post.

ActivityPub posting privacy settings on Mastodon

I did hear rumblings that the EU was likely to pass some laws requiring a certain level of interoperability between social networks, which ActivityPub could in fact be the basis of.

Some worry about another Eternal September moment — a repeat of the time when AOL disgorged its gaggle of novice Internet users on an unsuspecting Usenet system. Usenet users prior to AOL opening up in 1993 only had to deal with similar shenanigans once a year around September when each new batch of first year uni students would receive their Internet access accounts.

I’m not sure linking of a site like Facebook or Tumblr (who have also mentioned joining the Fediverse) is all that big a deal — Mastodon lets you block whole domains if you so choose, and who says everybody on a certain site is going to cause trouble?

Email is a federated system, always has been, and while participation as a small player is more complicated than it used to be, it is still doable. Big players like Microsoft and Google haven’t killed off email (even with the former doing their best to do so with sub-par email clients and servers). Yes, we have a bigger spam problem than we had back in the 90s, but keeping the signal-to-noise ratio up to useful levels is not impossible, even for mere mortals.

We do have to be mindful of the embrace-extend-break game that big business like to play with open protocols, I think Mastodon gGmbH’s status as a not-for-profit and a reference implementation should help here.

I’d rather throw my support behind a system that can allow us to all interoperate, and managing the misbehaviour that may arise on a case-by-case basis, is a better solution than us developing our own little private islands. The info-sec press seem to have been quick to jump ship from Twitter to Mastodon. IT press is taking a little longer, but there’s a small but growing group. I think the journalism world is going to be key to making this work and ensuring there’s good-quality content to drown out the low-quality noise. If big players like Meta joining in help push this along, I think this is worth encouraging.

A crude attempt at memory management

The other day I had a bit of a challenge to deal with. My workplace makes embedded data collection devices which are built around the Texas Instruments CC2538 SoC (internal photos visible here) and run OpenThread. To date, everything we’ve made has been an externally-powered device, running off either DC power (9-30V) or mains (120/240V 50/60Hz AC). CC2592 range extender support was added to OpenThread for this device.

The CC2538, although very light on RAM (32KiB), gets the job done with some constraints. Necessity threw us a curve-ball the other day, we wanted a device that ran off a battery. That meant going into sleep mode periodically, deep sleep! The CC2538 has a number of operating modes:

  1. running mode (pretty much everything turned on)
  2. light sleep mode (clocks, CPU and power stays on, but we pause a few peripherals)
  3. deep sleep mode — this comes in four flavours
    • PM0: Much like light-sleep, but we’ve got the option to pause clocks to more peripherals
    • PM1: PM0, plus we halt the main system clock (32MHz crystal or 16MHz RC), halting the CPU
    • PM2: PM1 plus we power down the bottom 16KiB of RAM and some other internal peripherals
    • PM3: PM2 plus we turn off the 32kHz crystal used by the sleep timer and watchdog.

We wanted PM2, which meant while we could use the bottom 16KiB of RAM during run-time, the moment we went to sleep, we had to forget about whatever was kept in that bottom 16KiB RAM — since without power it would lose its state anyway.

The challenge

Managing RAM in a device like this is always a challenge. malloc() is generally frowned upon, however in some cases it’s a necessary evil. OpenThread internally uses mbedTLS and that, relies on having a heap. It can use one implemented by OpenThread, or one provided by you. Our code also uses malloc for some things, notably short-term tasks like downloading a new configuration file or for buffering serial traffic.

The big challenge is that OpenThread itself uses a little over 9KiB RAM. We have a 4KiB stack. We’ve got under 3KiB left. That’s bare-bones OpenThread. If you want JOINER support, for joining a mesh network, that pulls in DTLS, which by default, will tell OpenThread to static-allocate a 6KiB buffer.

9KiB becomes about 15KiB; plus the stack, that’s 19KiB. This is bigger than 16KiB — the linker gives up.

Using heap memory

There is a work-around that gets things linking; you can build OpenThread with the option OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE — if you set this to 1, OpenThread forgoes its own heap and just uses malloc / free instead, implemented by your toolchain.

OpenThread builds and links in 16KiB RAM, hooray… but then you try joining, and; NoBufs is the response. We’re out of RAM. Moving things to the heap just kicked the can down the road, we still need that 6KiB, but we only have under 3KiB to give it. Not enough.

We have a problem in that, the toolchain we use, is built on newlib, and while it implements malloc / free / realloc; it does so with a primitive called _sbrk(). We define a pointer initialised up the top of our .bss, and whenever malloc needs more memory for the heap, it calls _sbrk(N); we grab the value of our pointer, add N to it, and return the old value. Easy.

Except… we don’t just have one memory pool now, we have two. One of which, we cannot use all the time. OpenThread, via mbedTLS also winds up calling on malloc() very early in the initialisation (as early as the otInstanceInitSingle() call to initialise OpenThread). We need that block of RAM to wind up in the upper 16KiB that stays powered on — so we can’t start at address 0x2000:0000 and just skip over .data/.bss when we run out.

malloc() will also get mighty confused if we suddenly hand it an address that’s lower than the one we handed out previously. We can’t go backwards.

I looked at replacing malloc() with a dual-pool-aware version, but newlib is hard-coded in a few places to use its own malloc() and not a third-party one. picolibc might let us swap it out, but getting that integrated looked like a lot of work.

So we’re stuck with newlib‘s malloc() for better or worse.

The hybrid approach

One option, we can’t control what malloc the newlib functions use. So use newlib‘s malloc with _sbrk() to manage the upper heap. Wrap that malloc with our own creation that we pass to OpenThread: we implement otPlatCAlloc and otPlatFree — which are essentially, calloc and free wrappers.

The strategy is simple; first try the normal calloc, if that returns NULL, then use our own.

Re-purposing an existing allocator

The first rule of software engineering, don’t write code you don’t have to. So naturally I went looking for options.

Page upon page of “No man don’t do it!!!”

jemalloc looked promising at first, it is the FreeBSD malloc(), but that there, lies a problem — it’s a pretty complicated piece of code aimed at x86 computers with megabytes of RAM minimum. It used uint64_ts in a lot of places and seemed like it would have a pretty high overhead on a little CC2538.

I tried avr-libc‘s malloc — it’s far simpler, and actually is a free-list implementation like newlib‘s version, but there is a snag. See, AVR microcontrollers are 8-bit beasts, they don’t care about memory alignment. But the Cortex M3 does! avrlibc_malloc did its job, handed back a pointer, but then I wound up in a HARDFAULT condition because mbedTLS tried to access a 32-bit word that was offset by a few bytes.

A simple memory allocator

The approach I took was a crude one. I would allocate memory in fixed-sized “blocks”. I first ran the OpenThread code under a debugger and set a break-point on malloc to see what sizes it was asking for — mostly blocks around the 128 byte mark, sometimes bigger, sometimes smaller. 64-byte blocks would work pretty well, although for initial testing, I went the lazy route and used 8-byte blocks: uint64_ts.

In my .bss, I made an array of uint8_ts; size equal to the number of 8-byte blocks in the lower heap divided by 4. This would be my usage bitmap — each block was allocated two bits, which I accessed using bit-banding: one bit I called used, and that simply reported the block was being used. The second was called chained, and that indicated that the data stored in this block spilled over to the next block.

To malloc some memory, I’d simply look for a string of free blocks big enough. When it came to freeing memory, I simply started at the block referenced, and cleared bits until I got to a block whose chained bit was already cleared. Because I was using 8-byte blocks, everything was guaranteed to be aligned.

8-byte blocks in 16KiB (2048 blocks) wound up with 512 bytes of usage data. As I say, using 64-byte blocks would be better (only 256 blocks, which fits in 64 bytes), but this was a quick test. The other trick would be to use the very first few blocks to store that bitmap (for 64-byte blocks, we only need to reserve the first block).

The scheme is somewhat inspired by the buddy allocator scheme, but simpler.

Bit banding was simple enough; I defined my struct for accessing the bits:

struct lowheap_usage_t {
        uint32_t used;
        uint32_t chained;
};

and in my code, I used a C macro to do the arithmetic:

#define LOWHEAP_USAGE                                                   \
        ((struct lowheap_usage_t*)(((((uint32_t)&lowheap_usage_bytes)   \
                                     - 0x20000000)                      \
                                    * 32)                               \
                                   + 0x22000000))

The magic numbers here are:

  • 0x20000000: the start of SRAM on the CC2538
  • 0x22000000: the start of the SRAM bit-band region
  • 32: the width of each word in the CC2538

Then, in my malloc, I could simply call…

struct lowheap_usage_t* usage = LOWHEAP_USAGE;

…and treat usage like an array; where element 0 was the usage data for the very first block down the bottom of SRAM.

To implement a memory allocator, I needed five routines:

  • one that scanned through, and told me where the first free block was after a given block number (returning the block number) — static uint16_t lowheap_first_free(uint16_t block)
  • one that, given the start of a run of free blocks, told me how many blocks following it were free — static uint16_t lowheap_chunk_free_length(uint16_t block, uint16_t required)
  • one that, given the start of a run of chained used blocks, told me how many blocks were chained together — static uint16_t lowheap_chunk_used_length(uint16_t block)
  • one that, given a block number and count, would claim that number of blocks starting at the given starting point — static void lowheap_chunk_claim(uint16_t block, uint16_t length)
  • one that, given a starting block, would clear the used bit for that block, and if chained was set; clear it and repeat the step on the following block (and keep going until all blocks were freed) — static void lowheap_chunk_release(uint16_t block)

From here, implementing calloc was simple:

  1. first, try the newlib calloc and see if that succeeded. Return the pointer we’re given if it’s not NULL.
  2. if we’re still looking for memory, round up the memory requirement to the block size.
  3. initialise our starting block number (start_nr) by calling lowheap_first_free(0) to find the first block; then in a loop:
    • find the size of the free block (chunk_len) by calling lowheap_chunk_free_length(start_nr, required_blocks).
    • If the returned size is big enough, break out of the loop.
    • If not big enough, increment start_nr by the return value from lowheap_chunk_used_length(start_nr + chunk_len) to advance it past the too-small free block and the following used chunk.
    • Stop iterating of start_nr is equal to or greater than the total number of blocks in the heap.
  4. If start_nr winds up being past the end of the heap, fail with errno = ENOMEM and return NULL.
  5. Otherwise, we’re safe, call lowheap_chunk_claim(start_nr, required_blocks); to reserve our space, zero out the actual blocks allocated, then return the address of the first block cast to void*.

Implementing free was not a challenge either: either the pointer was above our heap, in which case we simply passed the pointer to newlib‘s free — or if it was in our heap space, we did some arithmetic to figure out which block that address was in, and passed that to lowheap_chunk_release().

I won’t publish the code because I didn’t get it working properly in the end, but I figured I’d put the notes here on how I put it together to re-visit in the future. Maybe the thoughts might inspire someone else. 🙂

One year on in the Russia-Ukraine conflict

It was about this time, news was a-buzz with the talk of tanks lining up on Russia’s western border, then crossing over into Ukraine in a conflict that was meant to be over in a little over a fortnight.

Time must move slow for Vladimir Putin — 12 months in real time and they’re still at it! So that’s approximately one “Putin Day” equates to approximately 26 real days for the rest of us. (Some would argue the conflict actually began in 2014 — I guess there’s some merit in that opinion, but things really began heating up 12 months ago.)

I’ve actually learned a lot about the place. Okay, “a lot” is a relative measure, what I actually know could be scribbled onto the back of a postage stamp with a thick permanent marker, however I am picking up tidbits here and there.

12 months ago, I actually had to frequently correct my spelling — I kept missing the “i” (i.e. “Ukrane”). I wasn’t aware Chernobyl was actually on Ukraine’s northern border with Belarus (or that Belarus was even their northern neighbour). I might’ve heard of Moldova, but wasn’t sure where it was, I had not heard of the disputed territory of Transnistria. Nor did I realise they shared their western border with Poland.

Over the last 12 months I’ve slowly become a bit more familiar with where some of their more major cities are: Lviv in the west, the port cities of Odesa, Mykolaiv (and the general Kherson area — watermelon territory) and we heard lots about Mariupol, particularly the steelworks there. Dnipro and Luhansk in the east, Kharkiv and Sumy in the north-east… Kyiv up in the north.

Point me to a blank map 12 months ago and I wouldn’t have had much idea where those places were, but I have a vague idea now.

I could spot Cyrillic writing before this conflict but couldn’t read any of it. Today while I can’t identify the language, I’m starting to be able to pick out individual letters and recognise the odd word. Various news articles have covered various aspects of the Ukrainian culture. Of course, the before-and-after photos that pop up from time to time showing what was, and what’s just been pulverised by Russian shelling reveal a lot of ornate buildings that are now little more than rubble.

Okay, so little things… very basic facts. The depressing thing is it’s taken a bloody war to even gain a modest familiarity with these things. I have a fear of flying and have no passport, so there’s practically zero chance of me visiting that part of the world.

I guess there was no real necessity for me to really understand the geography of the area pre-conflict, it would have been a personal interest thing if I had done so. Whatever happens though, I think the rest of the world will have to be there ready to help pick up the pieces and help Ukraine re-build.

I wouldn’t be doing business with any businesses based in Belarus, Democratic People’s Republic of Korea (aka North Korea), Eritrea, Mali, Nicaragua, Russia or Syria… and I’d think twice about “no-limits” Russia supporter China.

If the governments in those places change their tune on this conflict, then we re-evaluate, but it’s a fact that supporting business there helps support that country’s government, which only positively-reinforces their current behaviour.

Sadly, with North Korea firing test missile after test missile into the sea, and China eyeing off Taiwan (and its proximity to the Mariana Trench — it’s just about chip fabrication) with jealous eyes — one can only wonder what the next few decades have in store for us.

The real scary thing, I don’t think we in Australia can really count on our allies. The United Kingdom is an utter basket-case post-Brexit and the United States is actually looking very much less united with every passing day as the society there slowly edges towards a race-fuelled civil war.

Methinks we need to start looking at doing things on our own soil, “global economy” looks like it’ll be taking a back seat for a little while!

A stereo/binaural tactical headset: part three

So, last time I 90% finished the headset I’m likely to use at horse endurance ride and other “quiet” emergency comms events in the near future. The audio quality (at least on receive) sounds great. From what I can tell between hand-helds, the transmit audio sounds good. It’s quite comfortable to wear for extended periods, and while my modifications do muffle sound slightly, it’s perfectly workable.

There are just a couple of niggles:

  1. the headset uses a dynamic microphone, thus is not compatible (microphone-wise) with the other radio interfaces I have
  2. I used solid-core CAT5 which is sure to develop a fault at some inconvenient moment
  3. the cable to the connector is way too short

CAT5 was fine for a proof-of-concept, but really, I want a stranded cable for this. Being a dynamic microphone, it’s not necessary for it to be screened, and in fact, we should not be using unbalanced coaxial-type cable like we’d use on an electret microphone. That brings up another problem: interfaces designed for an electret will not work with this microphone — the impedance is too low and they’ll supply a bias current which needs to be blocked for dynamic microphones.

Right now I use a DIN-5 connector, but this is misleading — it implies it’ll connect to any radio interface with a DIN-5, and that my electret headsets will plug into its interfaces. At most I can listen with such a set-up, but not talk. The real answer is to use a completely different connector to avoid getting them mixed up. I decided whatever I used, it should be relatively common: exotic connectors are a pain to replace when they break. My criteria is as follows:

  • As discussed, common, readily available.
  • Cheap
  • Able to carry both speaker and microphone audio in a single connector so we don’t get speaker and microphone mixed up
  • Polarised, so we can’t get a connector around the wrong way
  • Ruggedised
  • Panel and cable mount versions available

Contenders I was considering were the 240° DIN-5 (I bought some by mistake once), 5-pin XLR and mini-XLRs, and the humble “CB microphone” connector. Other options I’ve used in the past include the DIN-7/DIN-8 and DE15HD (aka “VGA” connectors). DIN-7/DIN-8s can be fiddly to solder, and are overkill for the number of contacts. Same with DE15HDs — and the DE15HDs do not like moisture!

In the end, I decided the CB microphone connector seemed like my best bet. Altronics and Jaycar both sell these. I don’t know what the official name of these things is. They were common on radio equipment made between the mid-70s through to the late 80s — my Yaesu FT-290R-II uses an 8-pin connector, my Kenwood TS-120S uses a 4-pin. They’re pretty rugged, feature a screwing locking ring, and have beefy contacts for passing current. Usually the socket is available as a panel-mount only, but I found Altronics sell a cable-mount version (and today I notice Jaycar do too). If someone knows a RS/Mouser/Element14/Digikey link for these, I’ll put it here.

The big decision was to also consider how to wire the connector up. As this is “my own” standard, I can use whatever I like, but for the sake of future-me, I’ll document what I decided as I’ve forgotten how I wired up DIN-5’s before. I did have it written down, but misplaced that scrap of paper. I ended up quickly opening up a connector and taking this photo to refresh my memory.

A photo of an actual headset connector, showing the connections.

To wit, I therefore shall commit to public record, exactly how I wired this thing, and propose a standard for dynamic microphone headsets.

The current (left) DIN-5 pin-out, and my proposed “CB microphone” pin-out — both looking into socket

Some will point out that yes, I’m creating yet another standard. In my defence, mine is aimed at stereo headsets, which traditionally have been two separate 3.5mm phone jacks. Very easy to mix up. Some might argue that there exists a new standard in the form of the 4-pole TRRS connector, however not all interfaces are compatible — at the time when I devised the DIN-5 connector, I was using a Nokia 3310 which did not like having the microphone and speaker connected to a common pin.

Keeping them separate also allows me to do balanced audio tricks for interfacing electret microphones with radios like the Yaesu FT-857D which expect a dynamic microphone. For this; I need 5 contacts — left/right speaker, speaker common, and two for the microphone. There are 5-pole TRRRS connectors, the TP-105 is one such example — but they’re not common outside of the aviation industry where they are used.

For the cabling, I’ve cut the CAT5 cabling shorter, and spliced onto the end some 4-wire telephone ribbon onto each side. That makes the headset cable a comfortable length. I began by first soldering the “CB microphone” connector, choosing colours for the speaker and microphone connections and wiring it up in a “loop”, before cutting the far end of the loop, stripping back insulation and tinning the wires. I used a multimeter to decide which was the “left” and “right” connections — then these were spliced with some heat shrink.

After a quick test on the radio, I sealed it up using some hot-melt glue. This should prevent the solder joints from flexing and thus prolong the life of the connection.

I might look at a small J-FET or BJT adaptor cable that will allow me to use this headset in place of an electret microphone headset — as it’d be nice to be able to just plug this into the tablet to listen to music or use with VoIP. I’ve got extra line-mounted sockets for that. Not sure if it’s viable to go the other direction — I’d need a small battery to power the electret I think, that or a bypass switch on the PTT cable to allow me to power an electret microphone.

That though, is a project for another day.

A building-block for DIY Bluetooth audio devices

I’m a late adopter of Bluetooth, having previously tried Bluetooth in its earlier days, hearing something that sounded like my music was being fed down a drain pipe, and deciding that Bluetooth was rubbish… it wasn’t until I bought a Logitech H830 headset that I found that Bluetooth can actually sound decent… moreover when I bought the Logitech Zone Wireless, that bi-directional Bluetooth can also sound decent.

Now, the Zone Wireless is fine if I’m in the office, or out walking somewhere. It’ll fit underneath the coolie hat if I decide to wear that, otherwise it works with a cap just fine. BUT, if I’m camping or at a WICEN event, I’m often wearing a full-brim hard hat. The headband on the Zone Wireless is a problem.

I really wanted a Bluetooth device that could be put on a lanyard, and I just plug in a regular common-garden variety wired headset. The closest I can get to this is a motorcycle headset — as these have to accommodate a wide variety of helmet styles, the radio module and the headset are actually separate components, and so conceivably, I can make my own compatible adaptor to plug in. Then, it wouldn’t matter… want to wear the hard hat? No problem, I already have modded earmuffs with a headset. Want to use it on the bike? Sure, plug the helmet straight in. Or am I in the office again? No problem, normal headset.

It’d also be nice to share that wired headset with a wired audio device… prime example here is a radio transceiver. Yes, there are devices that will make those do Bluetooth… and there are radios that have Bluetooth. I had one of the latter: Yaesu VX8-DR … it’s Bluetooth was next to useless… idiosyncratic and unreliable.

I see the Sena SR-10 mentioned in a few places as a way to “Bluetooth-enable” a two-way radio… but aside from being pricey, I see three complaints being raised: unreliable/slow pairing, intermittent darlek-like distortion on transmit and a noticeable connection delay on incoming signals.

I pondered doing my own… and I’ve slowly amassed parts to do exactly that. But, the other day, I stumbled on another option: Altronics sell a CSR8635 Bluetooth module. This advertises the ability to talk to two Bluetooth devices, and wideband voice. CSR’s own datasheet seems to give some hints as to how it can be used.

One catch, is the pads on this device are a 1mm spacing — so mounting this on some perfboard is going to be a big challenge. I prefer the minimalism of a module like this over a Raspberry Pi Zero W… a lot less to go wrong, and likely much better battery life.

Demise of 4KQ: one week on

So, it’s been 8 days since we woke up to the non-stop sports yap-trap that we were promised would be coming on the 1st July. Not that I heard much of it. I made a point of staying up and listening to the last of the old station before it went. The final few hours of the broadcast were ad-free and the final things heard on the station were:

  • Don McLean’s American Pie
  • The Beatles The End (from their album, Abbey Road — minus the secret track Her Maj)
  • crickets sound effect — fading out to silence

Then, shortly after… it cut over to the new mob. They just had a playlist going for the first 6 hours, with the cut-over about a minute into Survivor’s Eye Of The Tiger. I put the radio on mute shortly after and got some sleep… at 5AM they were still playing music, but with occasional cut-ins with various announcers mentioning what was coming after 6AM. When 6AM rolled around, I listened for a minute, then switched off for good.

The old website changed to being just a blank page.

Radio personality moves

Not sure where everyone has gone, but here’s what I do know:

  • Bob Gallagher, who some might know from 97.3’s breakfast program, and who chaired 4KQ’s last 4 morning on air… moved over to 4BH.
  • Vanessa Gibson (apologies if I have spelling wrong, I’ve never seen it written), who was one of the more promenant morning news readers at 4KQ has stayed with the 693kHz frequency on SEN-Q
  • 4KQ’s breakfast crew have moved to 4BC — an odd match if ever I saw one given that trio’s love for music and 4BC being a talk-back radio station

Station changes

4BH have switched formats to a “classic hits” format like the old 4KQ with a subset covering 1960 ~ 1989 (inclusive). I say subset because 4KQ in their final days were already playing Seal Crazy (released 1992), Natalie Imbruglia Torn (1997) and Savage Garden The Animal Song (released 1999).

Whether they’re playing any of Brisbane’s “historic” bands remains to be seen.

4BC’s program seems to suggest they’re still sticking with their “news talk” format. Maybe music in the mornings, then the gab-fest begins.

97.3 still don’t acknowledge the existence of anything prior to 1980.

River 94.9 is still a very weak signal into Brisbane — if you’re in the right spot you can get them but otherwise they’re practically inaudible. Odd, since they share the tower at The Knobby with VK4RAI, and I both hear that and can work that repeater quite reliably with far less power than what River 94.9 would be transmitting. Clearly they are still beaming west, and what we hear in Brisbane is just what’s coming off the back of the beam.

How things have changed for me

Well, from my perspective… that Friday morning was quite disorienting. You get used to the time-calls and regular news updates which give you an idea of how time had passed. I put my own music on that morning… and yes, was a minute or two late for my workplace morning stand-up because I wasn’t watching the clock!

A week on, and apparently I’ve broken one of my own music listening records according to Last.FM:

I had gone from listening to just 17 songs in total (most of those would have been the Friday afternoon), to over 1300. In the last 6 weeks of 4KQ I actually stopped listening to a lot of my music: I figured there was plenty of time for that once they went — I wouldn’t have 4KQ to listen to much longer, enjoy them whilst you’ve got them.

I also didn’t do any channel-hopping: previously if Abba came on (it’s a long story, but basically you didn’t want to be found listening to that group in a late 90s high-school), I’d switch stations or switch to my own music, sometimes for hours.

At mid-day I’d ordinarily flip over to Triple-M Classic Rock as they have a Essential Vinyl show which is often an interesting deep-dive into a particular iconic album from past decades, and is often interesting from the perspective of getting to know songs from an artist I might not otherwise know much about. Obscure entities like Buckingham Nicks (basically the precursor to the modern Fleetwood Mac) are in my shopping list thanks to that show. Just like a lot of my present collection can be tracked back to special features put on by 4KQ as well.

This last week… I didn’t do any of that. So where my music listening might’ve at most started at around 10:00AM or later… now basically I’ve been listening to my own music collection from 5:00AM through to to around 7:10PM. I have a cron job that manages it:

# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
0 5 * * * ( pulsemixer --unmute --id $( pulsemixer -l | grep -F qt-dab | awk '{ print $4 }' | sed 's/,//g' ) )>/tmp/unmute.log 2>&1
0 5 * * * pidof strawberry > /dev/null && env DISPLAY=:0.0 strawberry -p
0 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -36dB )>/dev/null 2>&1
10 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -33dB )>/dev/null 2>&1
20 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -30dB )>/dev/null 2>&1
30 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -27dB )>/dev/null 2>&1
40 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -24dB )>/dev/null 2>&1
50 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -21dB )>/dev/null 2>&1
0 6 * * * ( /usr/bin/amixer -c Generic -- sset Master -18dB )>/dev/null 2>&1
10 6 * * * ( /usr/bin/amixer -c Generic -- sset Master -15dB )>/dev/null 2>&1
0 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -15dB )>/dev/null 2>&1
10 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -18dB )>/dev/null 2>&1
20 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -21dB )>/dev/null 2>&1
30 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -24dB )>/dev/null 2>&1
40 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -27dB )>/dev/null 2>&1
50 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -30dB )>/dev/null 2>&1
0 19 * * * ( /usr/bin/amixer -c Generic -- sset Master -33dB )>/dev/null 2>&1
10 19 * * * pidof strawberry > /dev/null && env DISPLAY=:0.0 strawberry -q
10 19 * * * ( /usr/bin/amixer -c Generic -- sset Master -36dB )>/dev/null 2>&1
20 19 * * * ( /usr/bin/amixer -c Generic -- sset Master -192dB )>/dev/null 2>&1

The amixer calls were there before, and would control the volume. qt-dab would sit on the desktop and receive 24/7. Now, strawberry sits on the desktop, and I’m using its CLI to start and stop: strawberry -p to fire things off in the morning, then strawberry -q to finish playing that last song before going silent.

It’s got a lot to be desired… maybe if I get creative with a text-to-speech engine, I might get some time-calls and a bit of news headlines to replicate some of what I’ve lost, although it’ll be a very poor substitute to what I had on the old station. It might just be “good enough” though… it’ll give me a time reference.

My feelings on this

While I’ve been able to largely “replace” 4KQ on my own stereo… I’m still a bit peeved by the whole experience. There’s a lot of music that’s very hard to get / impossible to get, that they used to play. Railroad Gin’s You Told The World, Do Ya Love Me and The Academy Rock being three that used to play on 4KQ… but so far have proven unobtainium. Other bands like New World, Moscos and Stone, among others… are similarly buried somewhere in record company vaults, never to be seen again.

We’re just left to fight over what few second-hand albums exist in circulation… or pirate.

As to the mess that started this: so the ACMA have a rule that limits the number of radio stations a company can control. Fair enough, they want to promote diversity, and having all the eggs in one basket does not help this. I get where the ACMA is coming from.

Here, There & Everywhere own the Australian Radio Network, who until this year, owned 4KQ. They also own 97.3. Some bright-spark at HT&E saw dollars in buying up rival network Grant Broadcasting who owned various regional stations such as River 94.9 (Ipswich) and Hot Tomato (Gold Coast), and merging them into ARN. That meant ARN were now over the threshold.

That decision to chase the dollar, on the surface of it, seems to me to be nothing less than a complete slap in the face to the Brisbane radio listenership and the staff of 4KQ, the latter of whom had given their working lives to the station. 30 years for a single announcer to work a shift is an Australian record that 4KQ and Laurel Edwards broke. This is how HT&E pay her loyalty. I think that speaks volumes.

Plans now

Immediate plans

The morning crew I used to listen to are back on air on Monday, so perhaps I’ll set up the radio for 4BC, and see how they go.

I expect there’ll be quite a few gaffs from a trio that have been used to saying “4KQ” and “32230693” for decades (Laurel Edwards has been doing that on-air longer than anyone else). Mark Hine got so used to saying 4KQ he accidentally (as ground announcer) blurted “… on Classic Hits 4K-” to the audience at The Gabba… cutting himself off when he realised which workplace he was at.

It’ll be interesting to see how they work music into their news format. That’ll be a deciding factor as to whether I continue listening after the morning stand-up, or whether I switch to my own music until the next morning.

Radio station ideas / aspirations

So to be clear, I’m not going to rush into starting up something myself. While I do have some music knowledge, and that’s probably the subject about running a commercial music radio station I would rate as being strongest — my knowledge has gaps so large a sperm whale could swim through in comfort! If that’s the state of my knowledge in that field, this does not bode well for other critical-knowledge areas.

Really I’d need to team up with people who have some media experience. I have some technical knowledge, but there’s a big difference between a 100W SSB amateur radio station which is small enough to be bicycle-mounted, and a honking big 10kW broadcast MW AM station. I’d also need very deep pockets to commission said station.

Requirements for digital-rights management being imposed by the PPCA make Internet streaming impractical. That would basically just leave DAB+. There may be room there… seems channel 9B has a little more space than 9A does, but who knows? I’d have to ask, find out what their fees and technical requirements are. Then, I’d have to then figure out what the going rate was for advertising slots, and work out the finances from there.

I don’t know how the music needs to be obtained at this point. I’m guessing purchasing MP3s from legal sources (the same that we might as individuals) may be acceptable since they’re fundamentally the same recordings — and we’d have a separate content license that would cover their broadcast. This is a guess though, I might be wrong.

It’s a big job — and not one I’m particularly suited for. I’m happy to sit back and let someone who knows what they’re doing go ahead and do it.

The idea of such a station would be a very loose copy of 4KQ in so far as we’d be playing similar music. Not the same, because to be honest I actually do not know what songs were “hits” in this city. I have some recollections of what I’ve heard, but likely this is just the tip of the iceberg.

I did manage to grab some feature playlists (e.g. Sizzling 70s, Easter Count-down, all-sorts… etc) from 4KQ before the site went offline. Those, when de-duplicated, amount to about 3500 songs, about 70% I already had. I can’t publish these as they belong to the Australian Radio Network (I have contacted ARN about this but not heard anything — I’ll take that as a “no, do not publish”) … but nothing stops me picking through the listings and incorporating the artists mentioned into my library where see them. If I see collections that are readily available, I’ll make note of them here.

What would the format look like? Well, musically it’ll be a mix of the heavier rock that you’d hear on stations like Triple M, and the softer stuff of 4KQ. Not exclusively focused on Brisbane hits, as I don’t have a record of what was popular… I just have a “rough idea” of what artists were popular, and would likely work on that basis. That might change if someone who does have records of this came on-board and could basically guide me on this or take on the music-director role properly.

The first days would likely be ad-free as we try to build up an audience and attract advertisers. Those booking advertising slots would have to organise their own recordings since we wouldn’t have studios to help them with that. The station would be “automatic”: no announcers, news, weather… just music, and later we’d get ad breaks in to help pay the bills and start building up a revenue stream.

If revenue picked up enough, then maybe we could organise to hire studio time and do pre-recorded shows, or perhaps live ones if we can figure out how to link studio and transmitter.

Some ideas for shows that’d work pre-recorded:

  • Classic Artists Today: a look at artists we know from the 60s~90s that are still producing music and what they’re doing these days… for example Jeff Lynne is still doing music with Electric Light Orchestra, The Who and Manfred Mann’s Earth Band did a few new songs in the early part of this century, Fleetwood Mac are still active.
  • Sunday Spotlight: a deep dive into an artist’s work (e.g. a show about George Harrison would start with his role in The Beatles, but then cover solo work and his work in The Traveling Wilburys; Graham Gouldman might cover his early songwriting for The Hollies, The Ohio Express then his later work with 10cc, solo work, and his team-up with Andrew Gold in Wax; Brian Cadd could have enough material to fill several hours I think with Axiom, The Groop and solo work, along with producing for other artists).

This is better done by someone who knows what they’re doing, and I know right now, that is not me, certainly not as a solo act. I suspect this will be at least a year off, likely longer if it happens at all.

A lot will depend on demand. I have a day job that’s paying the bills, there’s no sense of rushing off from that into the great unknown, no matter how much I might feel like a career change after some 20+ years connection with (and subsequent frustration with) the IT industry in one form or another! Time will tell.

Building a broadcast station: initial due diligence

So, recently I started giving consideration to building a station… starting of course with how the station might broadcast to an audience. This is in no way a sign that I’ll actually go and do it: to survive I need about AU$30000/year (yeah, I have low overheads at present) and I doubt a dinky little radio station is going to make me that much money.

That said, this is an industry I know little about, so it’s hard to know what the finances would look like.

Content licensing

Irrespective of how the broadcast is done, a station like 4KQ will need a content license for the music broadcast. Not just music though, news updates and even the weather are potentially in the scope of content licenses.

These can be negotiated with individual holders in some cases. I know for small narrowcasting services you can obtain a license through OneMusic, however looking at their offerings they don’t seem to cater to broadcasting services. Turns out there is one that does: the Phonographic Performance Company of Australia.

What this would all cost is a complete unknown.

Radio Broadcasting

The above only lets you use content in a broadcast, it doesn’t let you actually transmit anything on any radio frequency. For this, two things are needed (in addition to the broadcasting equipment). Both come from the ACMA:

  • Broadcast station license: This doesn’t cover transmitters, this is merely the right to have a radio station servicing a given geographical area, irrespective of how it reaches that area.
  • Apparatus license from the ACMA.

I’m not sure whether this is true of DAB+, the transmitters themselves are operated by Digital Radio Broadcasting Pty Ltd, it could be that the stations “piggy-back” on their license the way the do on the actual transmitter itself.

If we did decide to commission a transmitter, that’ll get expensive fast. I don’t expect much change out of AU$1M, in fact, even that may not be sufficient! Then there’s running costs: a 10kW class-B transmitter PA stage will need at least 12-15kW on signal peaks and it will want it now! So likely, 3-phase power is needed, and with a beefy local energy store to smooth out those sharp peaks.

An AM transmitter will also occupy a decent-size land area. If you want an idea; have a look at the 4QR/4QG site or 4KQ’s site as examples. That size area does not come cheap.

Internet broadcasting

This looks to be, in the short-term, the cheaper option if we aim to start small first. We still need the content license, but potentially there are fewer unknowns in the costs. The interesting bit is the content license requirements, specifically I had a look at the forms needed to apply for such a license… this question stuck out:

“What security measures will be in place to prevent downloading or stream ripping?”

This is a tricky-one. In terms of technology my first choice would be something like icecast to manage the audio streams, but this is trivially ripped (possibly using nothing more exotic than wget).

DAB+ can be ripped trivially — qt-dab has both a “frame dump” and an “audio dump”; the former gives you the raw HE-AAC frames, the latter gives you decompressed PCM audio. The same tool can even rip the whole multiplex, recording every single station simultaneously (all 28 stations for the Brisbane DAB 1 multiplex).

Fundamentally, our ears do not hear digital signals, they only respond to analogue pressure waves (travelling through a gas or liquid). To listen to a “digital” station, it must first be converted from whatever on-air format it’s in to a plain uncompressed audio stream, passed through a digital-to-analogue converter, then amplified to electrically drive a speaker transducer which converts the electrical signal into the sound-pressure waves that our ears respond to.

Those sound pressure waves are not protected from being converted back to an electrical signal, having that electrical signal sampled through a analogue-to-digital converter and captured by a storage device.

Years ago, yes, I had some pirated music, and this included a copy of Cold Chisel’s Khe Sanh (I now have a legally purchased CD of that song, and the MP3 no longer exists on my equipment), in which you could hear someone gently placing a microphone in front of a speaker and nudging it forward. That method works whether the source material is a Victorian-era wax-cylinder phonograph recording or a Blu-ray disc. It would also work for any streaming service you care to mention.

Indeed, most of the listening devices feature headphone sockets or Bluetooth interfaces — it is entirely possible to sample the analogue or digital electrical signal without the acoustic conversion. Most computer sound devices feature a “monitor” port you can record from, and there’s nothing stopping you plugging in a device that advertises itself to two hosts as a USB Audio class device, piping audio from one to the other.

Yes, there’s signal degradation doing that, but this does not matter in a piracy law suit: it could be downmixed to mono and downsampled to a 2kHz sample rate with a 4-bit resolution, and still be a copyright violation.

So I wonder what “counts” as a security measure. No doubt this was a request put in by the record companies who seem to forget the above limitation. Maybe services like Listener and iHeartRadio have some tricks up their sleeve… who knows? Firefox seems to see iHeartRadio like any other website, and of course, to pipewire, Firefox is just like any other pulseaudio client, so stream ripping is very doable.

Also interesting was the question of: “How will access by countries other than Australia be restricted?” We seem to live in a world where VPNs don’t exist or are 100% detectable by the hosts. If I can stand up a VPN server, and “dial” into it from my tablet from any sufficiently-open Internet connection on the planet: practically anyone can. In doing so, it would look like I’m streaming from my home Internet connection, not from the real connection.

Funding the costs

So, for a station to “stand on its own feet”, it would need to find a revenue stream that pays for the above. The way most do it is through advertising, and there are groups like Commercial Radio Australia that cater to that. No idea what they pay broadcasters, but I’d imagine it’s a function of service area, number of listeners and the listener demographics.

This is hard to know in advance. The station I’m looking at as a model targeted the 40+ market (noting that I myself am not in that age bracket). Some of this group will be less technically inclined to do Internet streaming unless there’s some sort of dedicated streaming client available through their device’s software repositories. Integration into smart speaker voice assistants is a desirable feature to some this group, but many I’ll bet are listening the same way they’ve done for decades: traditional radio broadcast.

I think a “new” Internet-only station is going to struggle justifying the same fee for an advertising slot as an established 75-year old broadcast station.

Asking for donations might be another avenue, but having done work for a few charities in my time, this is definitely not an easy way to raise funds. Staff would essentially be volunteers: this would be at best a side-hustle for me and anyone else that joins me in this venture.

Subscription services for Internet broadcasting could work, but then you’re competing against the likes of Spotify, Deezer, Bandcamp, et all… that’s tough going! They don’t make much, and pass even less on as royalties. Plus, the listeners will likely demand more than just an advertising-free experience, they’ll probably want music-on-demand, which is a whole different class of content-license, and would have to be factored into the subscription fees.

Time will tell on the above, but that at least gives some thought as to what I’d be up for if I decided to take this thought-exercise further.