
I’ve been playing around with my simple sound toy and I hit a weird issue which I’m glad to say I finally solved….
The sound toy will play clips of Bob or Paul from the wonderful Gone Fishing programme. Yeah, yeah, I know it’s copyright but this is purely a personal project and is just a vehicle for learning.
Weirdness
Once I sorted the GPIO pin issue (see previous post) and finally got the Adafruit Rp20240 to play a WAV file, I thought I was home free. Fool I am!
My next task was one I’d been putting off, I was going to have to wade through all 7 (seven!) series of Gone Fishing and to select a set of clips I wanted to embed in this toy.
I wanted around 25+ clips; but after playing around with the sample rate (lower sample rate, smaller file size, squeeze more in the flash memory) I realised I could have more than that.
The issue was then one of workflow.
I started off by watching a few episodes and then noting a few phrases per episode that I liked. However, when you stop and think about it, this doesn’t work for two reasons:
- I’d have to go back and get the WAV sample(s)
- A few phrases per episode?! Including Christmas specials, there have been 49 episodes! So really I need less than one clip per episode.
I needed to re-think things!
My new plan was to watch the episodes on my laptop, and somehow record the sample I like straight away. Also, I would need to LOVE the clip – I was not short of footage or episodes to get through. And I certainly didn’t need more than 40-50 samples on the toy.
There are some nerdy ways of going about recording audio from a video you are playing on the on the computer but, to save the amount of thinking I had to do, I elected to go back to an app I’d used before, many moons ago: Audio Hijack.
With this tool, I could watch episodes on my laptop, and quickly record snippets.
Yeah the snippets may well need a bit of editing but what the heck?
I found that the mac desktop had a built in ‘trim’ facility to help me trim the clip down, which was great, but it created a problem.
The Problem
The problem was that if you use the ‘trim’ facility built into Mac Finder, it messes with the WAV header, which then mucks up the code.
Trust me, I am doing you a favour by not talking you through how I painstakingly found this out, but it did involving viewing the WAV files in hex!
In fairness, as happens a lot, with a bit of time to mull, I smelled the rough direction of the problem. The (ChatGPT) code (that has already caused me issues – see previous posts!) had hard coded offset values for the WAV file headers – errrr….yeah, that’s not very brittle is it?
Editor’s note: it was very brittle.
Long story short (again!) using the Mac Finder ‘trim’ messed up the headers and the offest.
Answer? Use Audio Hijack to capture my raw clips, and then use Audacity to trim the clips and to export.
Oh, and my other learning was that exporting to a sample rate of 11,025 Khz is a good compromise between quality and file sizes.
So, back to reviewing Gone Fishing!
p.s. I have also started the very early stages of looking into how to design 3D stuff for another project I’m working on.