Browsed by
Author: Joe

Intro to Pulse Width Modulation (PWM)

Intro to Pulse Width Modulation (PWM)

In this episode, we cover the basics of Pulse Width Modulation (PWM), and use an Arduino with quick-and-dirty code as demonstration.

PWM is useful when we need to modulate a load output (e.g. motor, fan, light) that takes in a specific voltage supply, and just lowering the input voltage may not be appropriate or desired.

Below is the Arduino sketch featured in the video. I copied this Arduino code from my kids’ schoolwork, because I gave them this same lesson earlier in the school year for (computer) science class.

Source available at GitHub

Would you buy a car with the hood welded shut?

Would you buy a car with the hood welded shut?

This post’s title question is a quote from Red Hat Linux founder Bob Young, emphasizing the benefit of open source software allowing you to inspect and modify your software tools.

This hood was “welded” shut by the clone tool using GIMP.

Let’s take some creative license with the car analogy.

Would you buy a car that has the battery riveted into the chassis? Let’s say doing so frees up the engine bay a little and allows for a larger battery than the standard cubic 24F battery since its custom shaped into a body member cavity. I would wager most folks would balk at this design choice knowing that batteries expire within a few years and would rather be able to replace the battery without also needing to swap out the front quarter body panel.

Would you buy a car whose engine has the water pump, alternator, A/C compressor, and power steering accessories welded into the engine block instead of conventionally bolted on? While we’re at it, turn them all internal facing so they’re driven by a sealed chain. Let’s propose that permanently fusing these accessories into the engine at the factory nets some performance increase and allows the car designers to shave 3 inches from the engine bay and give that space gain into the passenger cabin. I can almost guarantee someone living in Florida, USA during a humid summer season being told their A/C compressor is broken and has to get a whole new engine put in isn’t going to care as much about the few HP or foot-well room bought by the “fully integrated” engine design.

Now, my examples focus more on the hardware serviceability side of things. But it is important nonetheless because such measures preventing you from maintaining your systems within practical reason have encroached gradually over time with little protesting.

Non-user replaceable batteries have proliferated across most contemporary smartphone offerings, thereby placing a hard limit to use life as service life of Li-Ion batteries is just a few years regardless of use duty. Batteries internally glued to the chassis has been a feature on several higher profile laptop models, making repair a potentially dangerous undertaking.

RAM modules soldered onto the motherboard instead of installed into slots isn’t exactly a new invention — I saw it on a couple lower-end Intel-486 based desktop computers back in the mid-1990s. As those models were marketed for institutional use, my guess is it was due to budgetary reasons. Modern laptops that use soldered RAM will claim it helps thin the chassis (whether or not it matters to the target clientele). Granted, for some slim focused ‘s’ notebooks the tradeoff may be warranted, but is odd when an productivity oriented, unashamed thicker ‘T’ notebook uses soldered RAM. Although RAM failures are quite rare these days, a non-replaceable module is yet another unnecessary system failure point.

Back to my fully integrated engine thought from earlier, soldered RAM (and soldered CPU) may be a non-issue for the appropriate target audience who might be more willing to scrap the entire system of either of those parts started acting up. However, bundling the non-volatile data storage within the weld is asking for trouble no matter the end user. Within such a system, if the main board becomes inoperable for whatever reason (bad power rail, water ingress, exposure to leaked battery acid, etc) the user data is not retrievable. Not only that, SSDs themselves are a consumable component with a finite (although usually long) erase/write life and also not immune to controller silicon failures.

Its easy to envision the not so pleasant future where even though you purchase computing hardware, you really only lease them. The ‘just don’t buy it’ doesn’t always cut it because its not just one offending company, nor is it limited to computer hardware.

The debate on right-to-repair may be promising, but it is a complex discussion with many intricacies that can trip up most legislative bodies who are distracted by the lobbying parties of interest while (hopefully) balancing the reach of government.. Impactful and straightforward, yet non-draconian directives may be hard to come by. How do you go about mandating design for serviceability at the legal level with non-ambiguous verbose? Is it “serviceable” if a board or module can be swapped out, or is the requirement satisfied only with schematics, firmware, and access to vendor specific custom chips?

The mitigation options readily available for preventing computing failure fallout includes redundant data backup/recovery measures, and fallback computing systems at the standby.


Nordic nRF52840 DK Bluetooth SoC Evaluation Board

Nordic nRF52840 DK Bluetooth SoC Evaluation Board

In this episode we will have a quick overview of the nRF52840 Bluetooth SoC and Evaluation board.

The video segment discusses Nordic Semiconductor nRF52840 SoC, which is the top end offering of the nRF52 family of Bluetooth integrated SoC. A demonstration of the evaluation board and sample application is also presented.

Nordic has a strong market share in the embedded low-power Bluetooth connectivity space, in no small part due to their silicon offerings as well as developer support via their InfoCenter documentation andDevZone forum.

The featured evaluation board is a reasonable priced platform to get started investigating Bluetooth connectivity and designing peripheral circuits to integrate with the system for platform prototyping.

Get wired for speed

Get wired for speed

Disclaimer: As an Amazon Associate I earn from qualifying purchases

For home and/or office networking, wireless is convenient and as Wi-Fi standards evolved the performance has progressed. Despite technological advancements, wireless networking still lags behind wired gigabit Ethernet in practical use.

Here’s my mobile battle station just a few feet away from the network router connected via WiFi.

The Dual Band WiFi Router claims “Up to 300 + 867 Mbps” over the AC WiFi, with an asterisk. Real practical in-situ results as shown using WiFi AC equipped laptop.

And the same laptop across the house with the same configuration (unplugged power adapter) but attached to Ethernet.

Gigabit adapter on laptop attached to network switch connected to one of the gigabit ports on the router.

The link speed of the Ethernet connection is always 1 Gbps. The WiFi link speed fluctuates for whatever reasons and for me the reported link speed changes significantly when active vs. idle.

Even if your internet service speed is less than gigabit, local network access between computers for file/media shares, automated backup, and the like also benefit from 1000 Mbps transfer capacity. Over SSH/SFTP I usually see around 95-100 MB/s transfer rate copying large files between computers.

Got the need for speed? Good. Here’s an easy quick start:

  1. Obtain a Cat5e cable of desired length.
  2. Attach one end to the one of the gigabit ports on the router
  3. Attach the other end to the gigabit LAN port on your computer. –If your sleek ultra-thin laptop lacks an RJ-45 port, consider a USB-c Ethernet adapter or USB to Ethernet adapter

Do the same for another computer and you should be able to move bits between them much faster than over WiFi.

If all your computers are in the same room as your router, or you don’t mind having wires run and taped along the hallway, you’re good here. Read on if you want to possibly put in a clean and tidy installed network run within your home

**Usual disclaimers of your own risk and responsibility apply in regards to working on your own home or with permission from property owner. Only you or your hired contractor can judge the most appropriate work actions for your home configuration.

To run Ethernet throughout your home, you’ll want to start off with a Cat5e Ethernet Cable Kit that for a reasonable price should gets you a bulk supply of Cat5e cable as well as connectors and handy tools.

Your kit should include a bag of RJ-45 connectors, a crimping tool, and a cable tester.

You have to know your home to figure how to approach your home wiring runs. I can go over what I’ve done in a few scenarios.

When I lived at home when we still had carpet, an easy and minimally intrusive method was to tuck the Ethernet cable underneath the baseboard behind the carpet edge, and terminating the ends with an RJ-45 Jack and installing it within an RJ-45 surface mount box.

Tuck the cable out of sight. Be cautious of the nail strip holding the carpet in place.

A Fish Tape tool can help continue a cable run underneath a carpeted doorway.

In another home, a wood flooring project was the perfect opportunity to run network cabling within the expansion gap between the flooring and the wall.

In our present dwelling with wall to wall tile flooring already installed in half of the house, I ran the wiring through the crawl space.

With a stud finder, I was able to plan out the drop locations and cut out some drywall, drill some holes through the sub flooring and pulled the cables through.

I then finished off the wall with a low voltage mounting bracket, terminate the wires with the RJ-45 jack and installed it within a nice looking wall plate.

With a pair of known good Ethernet cables you can test the end-to-end connection jacks with your kit cable tester, as well as testing the custom length node cables you’ll make with the leftover bulk cable, crimps, and crimp tool.

To fan out your connections from the wall jack or wall mounted box, run a cable from the wall to a network switch, then attach the computers in the room to the switch.

With a small outlay for hardware and time commitment, you can enjoy years of reliable network connectivity within your home/office for work and leisure.

Addendum: If you do plan to cut holes within your non-new build home, be prepared for any surprises. Like, this gent and some of his buddies were hiding behind the wall I cut open.

Be well lit on your video calls

Be well lit on your video calls

Disclaimer: As an Amazon Associate I earn from qualifying purchases
Photo by Sam McGhee on Unsplash

In the era of video conference calls, practically every work desk has become a mini-studio setup equipped with web cameras and headsets interfaced with an array of collaborative platforms. Lighting, despite being just as important to your presence presentation, often tends to be an after-thought as evidenced by silhouetted faces and harsh shadows among your meeting’s gallery view.

Of course, with physical space permitting you could look into some Softbox Lighting Kits to Zoom your way to the Most Photogenic Teams Player. Indeed I have found such lighting kits fun to use and are of great value, but understandably might not be appropriate for a smaller dedicated workspace.

At minimum for overall reduced eye strain is to have a desk lamp to illuminate your general working area, as well as doubling as a light source for your video feed.

I tend to favor the articulating arm kind of lamps as they can be positioned downward to a specific area of interest to aid in minute tasks like PCB assembly or focused reading. OR to borrow from photography practices, can be aimed towards the ceiling to produce a soft bounced light effect. The gentler, well defused lighting avoids that “deer in the headlights” look from having a major light source pointed straight at you.

A more directed video light can be used to fill in the shadows that naturally occur on your face while on camera. This compact, yet versatile Neewer kit has been my battle station’s MVP.

This video light is USB (USB-A) powered and with its minimal power draw should work with practically any computer or mains USB port/charger. The included tripod is height and tilt adjustable.

Best of all, the light output is dimmable via an in-line controller to let you dial in the fill light to match ambient conditions.

Unless you’re going for that streaming gamer vibe, or just going to use a software superimposed background effect, you won’t want to forget about background lighting if your room is dim during your conference. An overhead light can be switched on if needed, or positioning a floor lamp in a corner to help.

Cheers to improving your presented image while reporting out your project progress and status in the morning, and showing off the kids brightly in the evening family call.

LPT: If you’re using a computer for work, One is None

LPT: If you’re using a computer for work, One is None

About a year ago I had a conversation with a professional friend about our work arrangements at the time, and what we’d do in terms of bench setup if we each were to do full-time independent consulting and contracting. Almost immediately we unanimously agreed on having two (2) computers.

The rationale is pretty obvious: loss of use of computing tools for design and development is a major risk to revenue when you’re the invoicing party. However, being stuck in the water when your only corporate issued rig gives up isn’t fun either.

I was reminded of that think-storm session earlier this week, right in the middle of a rather intense sprint.

Fortunately, it’s still able to boot after entering Startup Settings and toggling an option. But I have to do it every time now.

Luckily, this halting-on-boot laptop wasn’t the only computer I have for development, because otherwise it would have been very inconvenient in the project support, and a potentially major hassle should major servicing be required during COVID-19 shelter-in-place.

I experienced no loss to productivity because I perform most development with another computer that is my daily driver. On the table next to it is my secondary computer, which while not identically configured, can stand in with the same tool chains should need arise.

Of course, a sound data backup and recovery plan is always necessary and most people (hopefully) have that in mind, especially as some computer models tightly integrate storage modules rendering recovery difficult when the system fails to operate. Redundancy in workstations and other important tools may not often be in the forefront of thought, but is an important consideration. Even if you’re able to pick-up a new computer from the store within the hour, it may take a day or so to load up your software tools to get back to being productive.

It took me a few months to determine the most appropriate redundant systems strategy. At first, I had thought of keeping two mostly identical computers but realized quickly that one of them would most likely collect dust. Two exact setups are also potentially vulnerable to same-time failure if for example, the OS vendor pushes out a faulty automatic update.

I presently settled upon maintaining complementary platforms that are able to either host cross-platform tools natively and/or virtualize operating environments that can be replicated. This way, the computer resources all get utilized on a regular basis and have enough overlap should one fail at an inopportune time.

Virtualize your Virtual Meetings

Virtualize your Virtual Meetings

Q1-2020 has featured audio-video conferences in the spotlight. While the benefits and value of remote collaboration is greatly acknowledged and appreciated, there are some privacy and security concerns that come along for the ride.

Photo by Brooke Cagle on Unsplash

What video conference/meeting vendors do with account access and account data once on their platform is really up to their practices. However, for concerns regarding what the vendor client tools might do in regards to residual background processes or adding additional unwanted software packages, you have some mitigation options through containment.

  1. Dedicate a computer for conference meetings.
    • Vendor clients have no access to local data on your primary workstation due to air-gap.
    • Yet another computer to own and maintain. Won’t allow you to directly share content you might need on your primary workstation, unless you go through setting up network file sharing which is not without its own concerns.
  2. Dual-Boot: One computer but two disks/partitions. Similar pros/cons as dedicated computer.
  3. System Virtualization.
    • Can run in parallel within your workstation in it’s own container. No to (relatively) low hardware cost. Can share content with your host workstation through VM filesharing.
    • Your Performance May Vary. Definitely will want to do some preflight testing and have a backup ready to go should system fail to perform adequately during a call.

For our discussion, we’ll focus on virtualization. Before we continue…

THE DISCLAIMER: The contents of this article are intended for your personal use on your privately owned computing tools. Please adhere to your company’s policies and usage specifications for software, subscriptions, and computer tools provided to you for company use. DO NOT use this guide to circumvent company IT policy. Don’t blame me if Nick Burns your Company’s Computer Guy becomes angry and sarcastic with you. Other usual at-your-own-risk, no warranty, no liability disclaimers also apply.

Oracle Virtualbox is a free virtualization software that runs on Windows, Mac, and Linux hosts. It allows you to setup a virtual computing environment and allocate CPU, Memory, Video, storage, USB, file, etc resources to expose to the virtual …box.

For “Guests”, that is, the operating system running inside your container, Virtualbox supports several systems. However, Linux is free and easily accessible. I suggest Linux Mint.

A note on versions: The procedure in this article uses a Linux Mint 18.3 XFCE Host, using VirtualBox 5.2, and running a Linux Mint 18.3 XFCE guest. For whatever reason, the GUI presented in VirtualBox 6+ doesn’t play well with my 4k/UHD display, and Mint 19.3 apparently needs a Video Controller option that is only presented in VirtualBox 6+ to work correctly.

Download and install the VirtualBox software, and the associated extensions package. Then download the Linux ISO of your choice.

In VirtualBox, press “New” to create a new system profile.

Give your new system a name, set the type to Linux, and select the closest “Version”, then press Next.

Select “Create a virtual disk now” and press Create

Be sure that VDI is selected, and press Next.

I’ve only ever used “Fixed Size” because I have the Need for Speed

For your ‘physical disk’, give it a name/location, and size it just a little more than the minimum system requirement.

Wait for the virtual disk to be created. If the disk is created on an SSD, it won’t take long.

In the left panel of the VirtualBox utility, right click on your newly created system and select “Settings…”

Select “System” in the left pane, and within the “Motherboard” tab, give your virtual system at least 4 GB (adjust more or less, now or later, depending on the performance you are achieving, or available physical memory).

If you don’t have that much physical memory to allocate, now might be a good time to fill in that extra RAM slot on your computer, or swap out to higher density modules.

Within the Processor tab, give it as many ‘processors’ you have in the green range, again: more or less depending on performance. This is an allocation setting, meaning the VM will use up-to the specified value.

Select “Display” in the left pane, and within the “Screen” tab, tune the Video Memory if needed.

The minimum green value might actually work just fine.

Go to the “Storage” pane selection, select the virtual optical device, then expend the menu to choose a disc image.

Navigate to the Linux ISO you downloaded earlier. Then Press OK

Just showing the USB Controller setting here. I think it defaults to USB 2.0 (EHCI). If your webcam is choppy within the VM, try changing this to USB 3.0, if supported on your computer.

If your host machine is Linux and you can’t assign USB devices to your VM, be sure that your user account is added to the ‘vboxusers’ group.

Close out the settings dialog. Press Start to launch the VM. It should boot up with a “BIOS”, then boot from your Linux ISO.

Press Enter on the keyboard to go. You may to click in the VM window first. –To free the keyboard/mouse from the VM if it locks inside the VM, press the right CTRL key on your keyboard.

The LInux Live CD image should complete booting monetarily into a GUI system. Let’s test that your webcam works.

Open a terminal window, and type in

sudo apt-get install cheese

then press enter

From the VirtualBox menu bar, go to Devices->Webcams and select your webcam to attach to your VM.

Launch the Cheese from the Applications Menu

Verify that your webcam works. If it’s choppy, shut down the VM and try changing the USB setting from earlier, and try it again.

Close out the Cheese utility.

While we could just go conferencing with the live image load, you’ll have to reinstall application with every instance. Instead, let’s go ahead and install the OS to our virtual disk. Couple click on the Install icon on the desktop inside the VM. The Installer will launch.

Select your language

Check the box to install third-party software.

From here, just go with the defaults and press Next/Continue to install the system. We’re only using this VM for conf calls so this is good enough configuration.

When the installer finishes, it’ll prompt you to reboot. Go ahead. Press enter when it says to remove the boot image, and the VM will restart into the installed system.

Once rebooted into the installed system, pull down the “Devices” menu from the VirtualBox menu bar and select “Insert Guest Additions CD image…”

Double-click on the “Home” icon to open the file browser, select the mounted CD image. Right click in the file area and select “Open in Terminal”

In the terminal, enter

sudo ./VBoxLinuxAdditions.run

Follow the prompts to install the Guest Additions package. When finished, restart the VM.

With the VM restarted, you should be able to resize the VM by resizing the running Virtualbox window, and/or setting the screen size from the menu.

Its generally a good idea to run system updates right after a new install. Double click on the blue (i) shield in the lower right notification area to bring up the update manager. Follow the prompts to update the utility and system packages.

From here, you can certainly use the installed Firefox browser to access web resources, download and install Chrome if you wish, and access conference via web browser.

For WebEx, the limited testing I did with my account indicates positive potential.

For Zoom (yea, yes I know…), well I had some stability issues running within the browser within the VM earlier and ended up first resorting to using browser on the Host side (real) computer. Ultimately I ended up running their desktop client so I could see all videos (gallery view) at the same time…then uninstalled it.

I did install the Zoom application within the VM for next Zoom meeting. You can find the download on their website.

Once installed and launched, you get option to join meeting.

Virtualization is quite nifty for containerizing not only for running dodgy conference applications, but its also good for multi-platform testing and computer consolidation. VirtualBox is certainly not the only player in VMs (see VMware and Parallels) and you have your choices in Host and Guest systems.

Is your shop’s email address promoting your brand, or someone else’s?

Is your shop’s email address promoting your brand, or someone else’s?

Online web presence is a requiem for practically every business big and small. Dutifully, that includes establishing a proper web site and appropriate domain name to represent the business.

Oftentimes however, I observe small businesses such as favorite mom & pop dining establishments, or real estate agents, go through the effort of setting up [business_name].com for a web site address, only then to use an email address such as [business_name]@[POPULAR_FREE_EMAIL].com

It certainly works, but definitely could be better. –Potentially worse for professional image if the email goes to an uhm “legacy” internet service provider host. It would be great to setup contact email addresses to use the same domain name. Fortunately, it’s not too hard to accomplish, without having to run your own email server or migrate your existing email accounts.

What you’re going to look for is “Email Forwarding” or “Email Alias.” Once setup, what this will do is the domain will receive any emails addressed to “name@example.com” and forward it to whichever email address destination you’ve set. So even if you use Gmail, Yahoo, Hotmail, or AOL email, you can print your business cards and other promotional materials with an @your_business_name.com email address.

Where to find this setting will depend on your current configuration.

a) If you contracted with a consultant to manage your online presence and have a turnkey service agreement with them, by all means contact and let them know you want an email address at your domain to forward to your usual email address. You can still continue reading below as reference to what your consultant might do.

If you’re managing things partially or fully on your own, then either of these will likely apply:

b) Your domain is setup with a registrar and it points an IP address to a server hosted with another provider – chances are you’re using your registrar’s default DNS server. Somewhere within your host-records configuration there should be an option for Email Forwarding or Alias. If you’re unsure, look through the registrar’s support knowledge base or contact the support team

c) If you go into your registrar’s domain setup and you don’t see these DNS options, your domain might be setup to use a non-default nameserver. This may be the case if you’re using the same company for domain and hosting where they have you setup with their “web hosting nameserver”. If the web hosting side presented you a cPanel control panel, you might find the email configuration there.

So far, you can receive emails addressed at your forwarding alias.

No matter what, if you’re writing emails from your Gmail/Yahoo/et.al account, the email headers will show that it is originating from Gmail/Yahoo/et. al.

However, you can set your email account’s “Reply-To” address to your domain forwarding email address. This way, when someone replies to an email, your ‘name@your_business_name.com address will be in the “To:” field. In Gmail, its under Settings->Accounts and Import.

Now, when you go to draft emails, you should get a drop-down option in the “From:” field.


Send some test emails between yourself, maybe get a friend to test it out for you as well to make sure all works as expected. Now you can have consistency with your web address and email address.

New to full-time remote work? Mind these two words.

New to full-time remote work? Mind these two words.

If you’re reading this in March of 2020, you might be working remotely if your type of work permits such work arrangement. Generally the “work from home” conjurers up the image of sitting in bed, on the living room sofa, or at the kitchen counter. For those who work from home on an incidental basis (say, just to care for family illness), opening up the laptop and punching away at the dining table between clearing the dishes is passable for the limited time.

For remote work on a regular basis, it is in your and your productivity’s interest to setup a dedicated workspace.

While nice, a spare bedroom turned into a home office is not necessary. And even so, it’s not the bulletproof distraction-free environment as Professor Robert Kelly can confirm. Just a place that you can set aside for ‘exclusive work use’ is sufficient if it can contain the tools and instruments you need for being online, and that space can be left alone when not working.

Generally a proper desk or an available table positioned at a slightly less trafficked part of the residence will do. (The mahogany table in the dining room that’s only used on Thanksgiving and Christmas would qualify). Adding a low bookshelf can add a virtual wall to enclose an otherwise open space if necessary.

Photo by Kari Shea on Unsplash

The two immediate benefits of a dedicated workspace is

  1. It presents an opportunity for physical separation when working/not-working.
  2. The bench setup is not shuffled around due to other normal home events such as meal times.

The physical separation is important as its really easy to be distracted from work, or not fully unplugging after quitting time. In addition, you being in the dedicated workspace signals others in the home that “you’re at work”.

Often is the case that work projects don’t finish at end-of-business-day and continue the next work day. While you’ll prudently power-off instruments and stow away potentially hazardous items while off of work, the dedicated workspace saves you from daily full setup and tear-down so you don’t have to start every morning unpacking the office station.

If you’d like some ideas: here’s my current battle station, which happens to be in a corner of an otherwise unused guest bedroom:

It’s not always this tidy…

–As you can guess from the nature of this site, my work involves (small) electronics, firmware, and software.

If you’re tight on space, or just need more room, you might consider a closet office such as my other setup when I used to run two stations.

Adoption and office-culture acceptance of remote work has historically varied but trended upwards in past years. Recent global events have pushed the remote work arrangement to the forefront, and various research has indicated mutual benefits for companies and staff.

As working remotely is now in the spotlight, lets join together show the world that as the sh!t. hits the fan, we can still get sh!t done!

For more tips on successfully working from home, check out:


Getting Python to Play the Piano

Getting Python to Play the Piano

Disclaimer: As an Amazon Associate I earn from qualifying purchases

During a recent visit to Costco, the kids and I walked past the KAWAI pianos on roadshow display. We were admiring one of the models that was fully acoustic on the instrument side, but had some embedded electronics and firmware that automated music playing by mechanically actuating the keys.

The nice sales gentleman made his pitch that it’s value in entertaining without requiring an actual piano player. The model on display was $18,999. Considering that I look like a broke college kid most days and our cart contained other low-cost items, I’m hoping the sales gent was being somewhat joking in a deadpan manner and not expecting us to actually place an order on the spot. Plus, I had earlier remarked to my daughter that the price of the piano was just as much as my daily driver sedan.

But it got me to recall that our more modest digital piano is equipped with a USB (USB to Host) port. I was able to confirm after quick documentation review that the USB port presents itself as a MIDI device. I found a USB A/B cable and attached it to the nearby Linux laptop. The OS detected it just fine without requiring any additional drivers or manual kernel module loading.

To anyone at Yamaha reading this, THANK YOU for building devices with standard interfaces without requiring proprietary software or connectivity hardware. For that, you rock.

I spent the next few days downloading MIDI files of various popular music arranged by random folks, and piped them to the piano for play-by-instrument using Rosegarden, which is a music composing and editing program. How well a song performs depends on the arrangement, and the nature of the song’s genre contributes as well. (popular 90s era Latin Pop/Dance sound amazing)

For those unfamiliar: compared to a sound file (.wav) that contains a pulse-code sequence to represent a audio signal, a MIDI file is essentially a sequence of instructions to command an instrument device (physical, or software emulation) to play notes/sounds with prescribed voice and other parameters as well as set instrument controls.

But in my quest for semi-unattended playback, I wanted something that I could just load a playlist and go. I didn’t find such a program, so I went ahead and drafted up a Python script.

The relatively basic script scans the directory for MIDI files into an array, randomly sorts the array, and then calls ‘aplaymidi’ program that comes with Linux with the MIDI port number and file name to play. It features some filename character escaping and very little robust error case handling. But it does catch CTRL+C to gracefully (as best it can) quit out of the loop.

The script runs on the laptop as expected. But because it’s Linux + Python, it also runs on a Raspberry Pi.

I had a moment of pause wondering if the plug-and-play would indeed work on the Pi since it’s ARM based vs. x86/x64, but it was for not because it detected just fine.

Here’s the script running on the Pi, invoked from an SSH terminal shell, since I’m running the pi headless (no monitor or keyboard/mouse attached)

It is truly amazing that I can attach a $35 computer and “upgrade” a lower cost instrument with feature(s) found on models costing hundreds or thousands more!

With the GPIO pins on the RPi, I could certainly attach some hardware buttons and handle events for Play/Stop, FF, and Prev. –For another time, or I’ll leave it as an exercise for you the reader.

Addendum: As with most software projects, the same objective could have been accomplished with other solutions (in this case: shell script, perl, etc) but 1) I wanted to expand my python-fu, and 2) Python is the cool language/tool of this writing. Not that I’d universally suggest everyone to chase every fad and trend, it does help to keep up with available options and general marketshare. If given the chance to work on a lower risk project, I do encourage you to try out and evaluate new or new-to-you tools to solve the problem rather than always using your go-to choices.