Close
0%
0%

TWEACMAN: a sample scrubber & WAV audio player

A pocket-sized digital reel-to-reel with exquisite tape-like control of sound over time

Similar projects worth following
TWEACMAN is a pocket homage to my first Teac and my first Walkman. It's a music player-wither. Playback any part of any song at any speed, any pitch, any direction, with effects, or scrub it manually with your finger. It uses a nifty new kind of analog rotary encoder that translates subtle finger movements into digital sound on a budget.

The RV112-FF
The RV112-FF

Lately I'm really enamored of these RV112-FF dual 360-degree potentiometers from Taiwan Alpha. Really they are analog rotary encoders; they give a really precise and subtle finger interface to digital instruments. Most rotary encoders this precise cost a lot more and are big complicated weird components. These look just like normal pots, and they almost are. Each unit has two separate potentiometers arranged 90 degrees apart. By combining A/D readings from those two pots with a bit of trigonometry, you can calculate the absolute angle of the shaft around a complete rotation. Just like a standard rotary encoder -- but unlike a standard potentiometer -- you can spin the RV112-FF around and around forever. No matter where you twist it, the reading is reported as an absolute floating-point angle from 0 to 360 degrees.

To show off these nifty knobs I made TWEACMAN, a two knob pocket-sized sample scrubbing toy. Like an old-school reel-to-reel tape deck TWEACMAN plays WAV files from a SD card at speeds from 0.001x to 1024x, forward or backward, or you can twist a knob to scrub your recording back and forth across a virtual play head. There's a few other audio tricks available as well, and a handy Bluetooth interface you can use from your phone.

I built this project around SparkFun's ThingPlus RA6M5 board, which features a Renesas RA6M5 MCU. In 2026 we've got a crazy number of options for miniature ARM-based dev boards! The Think Plus RA6M5 has a handy feature set for the kinds of musical toys I like to make. 

  • The board exposes six of the RA6M5's 12-bit A/D converters, with which I can read up to three RV112-FF knobs. (An ESP32 can only read one RV112-FF with its two A/D channels.) 
  • The RA6M5 also has two 12-bit D/A converters with their own integrated output amplifiers; together they make a respectable medium-fi stereo audio output. 
  • It's also got an onboard capacitive touch controller, with two touch pins exposed on this board so I can give my circuit board two buttons without extra parts. 
  • There's a floating point coprocessor so I can do all my audio work in floating-point with no performance penalty. 
  • And there's another Renesas chip on this Thing Plus board, a DA14531MOD, with which I can serve up a more sophisticated wireless interface. 
  • The board also includes a complete battery management system so my device can be powered by a single 3.7v LiPo cell, rechargable by a standard USB cable.
The complete circuit

Renesas provides a complete development kit for the RA6M5, but I often prefer the Arduino environment for my MCU projects because of its vast set of open-source libraries and its great online community. SparkFun provides a port of the official Arduino Renesas core that adds support for this particular board. All my code from this project is open-source and Arduino-compatible.

But the truth is, I can't really call this "my" code because my AI intern Claude did all the heavy lifting. I mainly wrote specs, reviewed Claude's work, made the major decisions and did QA. Working this way is a profound change from how I've developed technology for most of my life. It's both humbling and empowering. Claude and I are doing work in days that used to take me weeks to complete by myself. It's a rush! 

  • 1 × Thing Plus RA6 SparkFun mini development board hosting the Renesas RA6M5 MCU and DA14531MOD BLE transciever
  • 2 × Taiwan Alpha RV112FF Lovely hi-res analog rotary controller in the form of a dual 360-degree potentiometer

  • PCB TIME!

    Mykle • 3 days ago • 0 comments

    Let's get this sucker off the breadboard and onto a real PCB! I talked Claude through documenting our circuit in a KiCad schematic, designing the PCB outline based on a casette tape silhouette, specifying the touch pad dimensions, the placement of the knobs and the ThingPlus, and some of the other art. I placed the rest of the components by hand. I also did the routing; Claude is incredibly capable at every other tech task I ask of him, and he was great at designing symbols and footprints, but he doesn't (yet) have the human knack for routing PCBs.

    Online PCB houses send back a minimum of 4 boards. I often try to build an enclosure out of the extras. I designed this board so I could stack another copy on on top of it, flipped in either direction, using screws and spacers which I vaguely assumed I'd be able to find. That's why the screw holes are all symmetrical across the horizontal center. I added access holes for pressing the reset and USRBTN buttons with a pencil, and then I duplicated those holes across the center line as well. Then I put a QR on the board pointing to the webUI page, and added a couple artsy flourishes. Once everything passed inspection, I sent off the finished gerbers to a PCB fab service. 

    While waiting for the boards to come back I went absolutely overboard adding features to TWEACMAN:

    • independent pitch and speed controls 
    • sample trimming
    • echo
    • hi and lo pass filters
    • a USB disk mode for loading samples, 
    • sample set management 
    • various easter eggs

    Claude makes it way too easy to add features!  Fortunately Claude (specifically Opus 5.5) is also very responsible about creating tests to verify his work, and all of our extra development uncovered various subtle bugs.

    THE BUILD: It's always exciting when the PCBs arrive! 

    The design only uses through-hole components, so it's straightforward to solder. 

    LOW PROFILE: I wanted to minimize the height so I could fit another PCB over the top as a lid, leaving enough of the potentiometer shafts expose that the knobs would still fit. The ThingPlus mounted in its sockets was going to be the tallest component on the board. So I used these Samtec low-profile headers and sockets to connect it, instead of the normal kind. That saved me about 4mm of vertical space, but the ThingPlus still looms over the rest of the circuit from a 15mm altitude.

    OOPS: Here's a thing I would do differently: I left the solder mask off this lower trapezoidal area because i wanted the ThingPlus LEDs to be able to shine through it, and because I didn't want any copper too close to the BLE antenna, and also for artistic reasons. But at some point during routing I ran this one un-masked lead right up next to the pins on the bottom of the board. That was a klutz move. I had to be verrrry careful here not to create a short-circuit while soldering those sockets! 

    CAPACITOR NERDING: Here's the main board, all soldered up and about to be tested. In this revision I put a film capacitor on the left output channel and an electrolytic capacitor on the right, to see if I could hear any differences in audio performance between them. They're both directly in the audio path, and audiophiles love to argue about such stuff. But I found no significant difference, certainly no audible difference. The film cap is cheaper and will last longer, so that's what's on the BOM.

    THE STACKUP: I'm still trying to figure out how best to screw this all together ... here's one way, using 20mm and 25mm M3 screws, spacers and washers and nuts. The screws are 5mm longer in back than in front; I think it's a bit easier to use TWEACMAN if it's raked forward a bit. 

    Initially I used a single 25mm screw per corner, running down that middle hole that's not filled in this photo. It worked on the tabletop, but it coupled the touch pads to the top and bottom boards. When I held it in my hands I kept accidentally triggering it from the bottom. So I moved...

    Read more »

  • Scrub-A-Dub

    Mykle • 11/05/2026 at 04:45 • 0 comments

    With the rest of that working, we got to the fun part: scrubbing audio with a knob. Doing this well in the digital domain demands a smoothly-controllable hi-res rotary controller, and the RV112FF delivers!

    The sensitivity of the scrub knob is quantized to some even number of turns per sample. That lets me spin it in a rhythmic circle and find the downbeat with the same gesture every beat. Fun for parties!

    NOISE PROBLEMS: Because we had already figured out how to read the knobs, read the buttons, read files and play audio, building this sketch was pretty easy. Mainly we needed to start measuring the angular speed of a knob instead of its position, but that's a well-understood math problem.

    However, while testing the sketch I immediately observed some issues with the knob readings that the previous tests hadn't shown. There was bad crosstalk: turning one knob seemed to cause the other one to move in the opposite direction. And then we also heard "ghost-scrubbing" -- little tiny movements of the scrub knob when I wasn't even touching it. This seemed to be due to the large amount of noise we got from the ADC readings on our breadboard. 

    That all cropped up when the circuit was still on the breadboard. So at first I was going to write off all of these problems as breadboard noise -- the jumpers picking up miscellaneous EMF, and the connections being sub-optimal compared to solder joints. I hoped that it would go away when we put the circuit on a PCB.

    But then I realized I could ask Claude to write me a custom signal scope, feeding noise measurements to the Arduino Serial Plotter as we tried various experiments.
    Plotting RMS of the noise in our zero-to-4096 results from four 12-bit ADCs. After reducing noise three ways (below), there's hardly any noise left to measure! Mostly we're seeing the internal noise of the resistive tracks in the pots, which is why four wipers at four different positions have four different baselines.

    With this tool were were able to test various noise-reduction theories. That's how we discovered that the SparkFun core's analogRead() method sets a default sampling time of 220ns, whereas the RA6M5 datasheet recommended that we should spend 600ns or longer per sample. It seems our ADC peripheral was sampling all four ADC channels in quick succession without enough time for its internal testing capacitor to recharge, thereby dragging measurement artifacts from one pin to the next, causing crosstalk. Our RA6M5AnalogTuning library now tweaks some registers to increase that sampling time and switch on a capacitor-recharge delay. Both of those fixes are handy hardware configuration options of the RA6M5 ADCs; no CPU cycles, wait loops or interrupts were required. This completely eliminated the crosstalk.

    Everything pointed to the ghost-scrubbing being noise on the scrub knob ADCs, misinterpreted as tiny movements of the knob. We found we could significantly reduce that noise with 4x oversampling in software. That cut angular jitter by more than half. So we added setOversampling() to our RV112FF library. And then I installed those 100uf capacitors between each pot pin and ground. They were intended to filter noise, and they might also have helped the ADC capacitors to recharge faster. They cut noise quite a bit further. Those two techniques together reduced measurement noise from an original +-6 down to about +-1.5 on our 0-4096 (12-bit) integer ADC reading.

    And then it turned out I was right about breadboard noise too. The soldered PCB version of TWEACMAN is 3x quieter than the breadboard version. On this board ADC noise is completely conquered and we are able to read our knob positions to the total resolution of our 12-bit ADCs!

    THESE WEIRD KNOBS: RV112FF pots have standard 6mm D-shafts, for which you can find a wide variety of festive knobs online. I struggled to scrub audio smoothly with the tiny knobs I had at home, so I tried these larger ones from Mouser:...

    Read more »

  • The Need For Speed

    Mykle • 11/02/2026 at 22:58 • 0 comments

    The specs on the RA6M5's SD card peripheral are impressive. SD cards have gotten faster and faster as cameras and other digital media tools have gone up and up in resolution. I wanted to see just how fast this board could read, and since knobs and audio were already working on the breadboard, I decided to mock up a variable-speed music player. This is what evolved into TWEACMAN.

    I ordered a SD card with what I thought were decent specs (microSDHC 120MB/s A1 Class 10 UHS-I) and we wrote a sketch to read WAV files off the card and stuff samples through the DACs as fast as we possibly could. The specs of the card and the RA6M5's SD controller together suggested we'd be able to stream audio at 25MB/second. Which is just meaninglessly, ridiculously fast: with such throughput, even if we had 192khz stero samples on the card, we would be able to play them back at 32 times normal speed.

    But actual measurement showed we could only get about 2.2MB/s read speed. With that, we could, for instance, play 44.1khz mono samples at "only" 25x speed. Reverse playback was even slower, only about 13x backwards. And to reiterate, those speeds I'm calling slow are ridiculously fast! It's not like you're listening to music at that point, you're just playing with squeaky little high-speed zip noises.

    But I like those zip noises, and I also like my personal collection of stereo 48khz samples which, being more than twice as dense as 44.1khz mono, played back at less than half that speed. And I was curious. So Claude and I started investigating, with a series of test programs to measure performance at various levels and check our theories. This is exactly the sort of tedious work that I, a human being, would usually put off. But Claude is happy to chase that stuff! And we found some improvements:

    • The core's SD block device driver sends one read command per requested 512-byte sector to the underlying FSP SDHI driver from Renesas which talks to the hardware. That caps every read at about 2.17 MB/s, however large the request, due to read command overhead. So Claude wrote a new SD driver, FastSDCardBlockDevice, while I mixed myself a martini. This block driver can ask the underlying hardware driver for up to 64 sectors (32kB) per command. That got us up to 18.5 MB/s when streaming, respectably close to the theoretical limit, giving us playback speeds of 109x forward, 86x backwards. That was the most major fundamental improvement.
    • But to make that work we also had to turn off a buffering layer in stdio that was splitting reads into 1kB chunks. However, switching off that buffering exposed a bug (we think?) in the Renesas SD driver! Misaligned DMA transfers (i.e. using the chip's DMA controller to copy from or to a buffer that's not 4-byte aligned in memory) were garbled; the SD driver includes special code to prevent that ... but it wasn't working. It's now addressed in our custom RA6M5FastSD library; we read into an aligned buffer and then memcpy on to whatever other unaligned buffer wants the data. That's slower than a pure DMA copy, but it's drastically faster than the SD transfer itself.
    • Reverse playback was further constrained because the filesystem block structure is fundamentally forward-chained, so each reverse seek needed to find its new location by seeking from the front of the file. This got slower the farther from the front we were seeking. There is a feature in the library, FF_USE_FASTSEEK, that would remove the backward FAT walk. But that wouldn't be part of our SD block device driver, that's the filesystem driver that sits on top of it. We'd have to modify the core files to turn it on, and modify the core FATFileSystem wrapper to use it, and that seemed like an even grosser hack than the gross hack that we used to shoehorn in our customSD driver. (#define PRIVATE PUBLIC !) 
    • We could also just cache our own map of the blocks as we read them. But we left both of those projects for later, because ...
    • I just wasn't satisfied with a...
    Read more »

  • Touchy Touchy

    Mykle • 11/01/2026 at 19:20 • 0 comments

    The Capacitive Touch Sensing Unit (CTSU) in the RA6M5 handles scanning a set of pins and returning a 16-bit analog capacitance measurement for each pin. To sense a finger touching a probe we need to observe the difference in capacitance when touched vs not touched, but the not-touched capacitance can float around a lot depending on subtle environmental factors like humidity, sunlight, temperature and so on. So we read regularly to maintain a rolling average, and try to detect major sudden changes as touch events.

    Arduino has libraries for bit-banging this sort of thing, but that consumes a lot of cycles and requires just the sort of carefully-timed measurement that the interrupts in various Arduino libraries can screw up. So having this dedicated hardware peripheral is a real luxury. Apparently there's a 144-pin version of the RA6M5 chip that support up to 20 touch sensing pins. The 100-pin version on this Thing Plus board supports 12 pins in theory, but only three of those touch sensing pins are actually exposed.

    Existing support for this particular Renesas CTSU under Arduino is slim. There is one library: R4_Touch by delta-G, https://github.com/delta-G/R4_Touch - which was designed for the Arduino Uno R4. But its interrupt-and-DMA approach wasn't compatible with our SparkFun Arduino core. I prefer to save interrupts for time-critical stuff like audio anyway. So we wrote RA6M5CapTouch, a polling-based scan library for the RA6M5, included in our repo today and soon to be available in Arduino. It offers a simple blocking API, scan(), and a slightly more complicated non-blocking API for the time-conscious.

    Touch events plotted by CapSenseDemo

    Our CapSenseDemo sketch plots the measured capacitance and the moving baseline for each pin. The measurement returned by the captouch peripheral is an abstract 16-bit value that's roughly linear to the capacitance, but can be affected by our scan rate, temperature and humidity. Noise levels in this measurement was initially about +-40 per scan. You can just barely make it out on the orange lines in the above plot. Compare that to our touch events that move the measurement by +-12000, and you can see that noise reduction isn't really a problem here. 

    Still, that noise can be reduced! This could matter for some situation where the capacitive probes are less sensitive -- like if you had a really long cable run between the board and the probes, so the base level of capacitance was really high compared to the added capacitance of a touch. That's not really a problem I'm having, but it's still interesting to know that we can reduce the noise figure with either software oversampling or setting a longer measurement time per scan in hardware. In our CapTouchDemo you can send 'a' to toggle the software averaging, and '+' or '-' to adjust the hardware measurement length.

    Both techniques get about the same improvement, at the expense of measuring less often and therefore increasing latency. The software version is actually slightly better for the same amount of time spent. With 16x oversampling we can reduce noise by more than half, while still measuring at 159hz, which gives 6.4ms latency on a touch event. I tend to think anything under 10ms is fine for human interaction with a musical instrument. I sure can't detect that delay when I press the button.

    Toggling software oversampling with 'a'

    With smoothing enabled in the library, we can accurately sense not just touch but proximity. In fact, it appears this ThingPlus board is already 90% of the way to being a working Theremin! We explored this idea with a simple CapTouchTheramin demo sketch that converts the captouch readings into pitch and volume values fed to a simple sine oscillator.

    It works, barely, but it's not super-playable because the touch pads on my PCB were specifically designed to not be good antennae. All the action is with an inch of touching the probe. We could bolt on some more antenna-shaped screws or something...

    Read more »

  • Hello Knobs!

    Mykle • 10/26/2026 at 23:03 • 0 comments

    For starts, we wrote the RV112FF decoding library for Arduino and an AudioKnobsDemo to test it. In that demo the two knobs on our breadboard sweep two audio oscillators across the audible range. When they get close together you can hear a beat frequency between them. 


    ATTENTION: when you install and run this sketch (and plug in some speakers) you will have to crank the knobs a few times before you hear anything at all on the audio jack. That's because the sketch first needs to calibrate them. These low-cost pots have some manufacturing variations and aren't always perfectly as described in the datasheet. They might have a slightly shorter range than all the way from 0 to 10k ohms, and the two tracks might not be perfectly 90 degrees apart, and you might have other circuitry between the pots and your pins that alters the range. So before the library can give an accurate reading on a RV112FF it needs to measure the maximum, minimum and true offset angle. We can measure all that in two turns of the knob, and calibrate around it. 

    KnobsDemo.ino gives an example how to manage this in your sketch. Until the knobs are calibrated their angle will read -1, but don't test for that. Instead call isCalibrated(), and ignore the results of read() until isCalibrated() returns true. Once a knob is calibrated it will stay that way until power-off. (The smart thing will be to save that calibration info to non-volatile RAM and load it at startup; we'll get to that soon.)

    This sketch doesn't just make audio waves -- it can also make squiggles on your screen! If you turn on the Arduino Serial Plotter you'll see it plot a bunch of signals. For each pot (knob1 & knob2) we plot the raw A/D value for both wipers, the calculated angle in degrees, and the calculated pitch. Eight values in all. Above you can see a plot of all of them at once. It's kind of pretty, but hard to read. The next plot is simpler:

    This is a plot of just the two wiper readings in knob 1 (blue and red), showing some details of these signals as I turn the knob slowly by hand right after a reboot. You can see that the two pots' readings are 90 degrees apart, and each pot sweeps a value from 0% to 100% and back. (Inside the pot, on each track the supply current is fed to the center of the track and grounded at both ends, unlike a standard pot which feeds current at one end of the track and grounds the other end.) Notice how the sketch starts to report the angle measurement (pink) once isCalibrated() returns true, which happens after the shaft has turned a bit less than two full rotations. That's one complete turn to find the maximum values, and a second time around just to be sure.

    Our RV112FF library reports the absolute position of these rotary encoders as an angle from 0 to 360 degrees. Sweep past 360 and you're back to 0. But sometimes we might want more degrees than that! Our MultiTurnKnob library built on top of RV112FF lets us count how many degrees the rotor has spun since the count was reset, similar to how Arduino's PJRC Rotary Encoder Library counts turns of a rotary encoder. The accumulated angle is a signed float, where negative values are counter-clockwise. With this, we can map our accumulated angle onto any other parameter. For instance, we can map four complete twists of the knob (pink, above) to an oscillator sweep up and down the audible frequency range (blue).

    The slight wiggly-ness in this plot is due to slight wiggly-ness in my fingers; it's not due to noise or the components. There is some noise in the ADC readings though; you can see it if you turn off everything but one potentiometer reading and wait for the plotter to zoom in on a single line. If you pull out the associated capacitor next to the potentiometer you can see just how much additional noise those caps are filtering out. There's also a smoothTau parameter in the RV112FF constructor that lets you set a high shelf to reduce jitter digitally -- this...

    Read more »

  • Initial setup

    Mykle • 10/24/2026 at 16:20 • 0 comments

    My development setup: my M1 Mac Mini running MacOS 26 with the command line developer tools installed. I installed Claude Code and the latest Arduino release (2.3.10), then asked Claude to install SparkFun's Arduino core for the Thing Plus. That two-step process is explained here: first get the official core for the Portenta through the board manager, then download the RA6M5 package from Sparkfun and move it into place.

    I also gathered all the datasheets into a directory where Claude and I could read them: That includes the RV112-FF pots, the RA6M5 MCU datasheet and user manual, the bluetooth chip, and Renesas' capacitive touch design guide. Because I don't really like to use the Arduino GUI I had Claude set up a Makefile-based command line build system for me that uses arduino-cli under the hood to compile and upload firmware. We still used the app for its built-in Serial Monitor and Serial Plotter.

    Here's how I plugged it together on the breadboard: 

    Eech, what a salad. The four A/D pins are wired to the wipers of two RV112-FF dual pots, the two D/A pins to a STX-3120-3B audio jack, and the two touchsense pins into two thrown-together touch probes made from scraps of header and perfboard.  (Before I made those I used slices of carrot as touch sensors; they worked perfectly on the first day, but they slowly dried up and stopped working at all by day 4.) 

    I had to pry the bottom +- power rail off of my breadboard to be able plug these pots in, because they have little PCB-clutching toes on them which don't want to be added to the circut and don't line up with the breadboard holes anyway. With that rail out of the way they hang over the bottom edge of the board as shown. One could maybe bend their toes back with a needlenose plier instead, and then return them to position at build time, if one needed to plug them into the breadboard at some other position.

    What else? There's a power switch to ground the EN pin, which shuts down the board (mostly). There's power and ground to the tracks of the pots, and some 100nF caps between the pot wipers and ground, optional but recommended, which filter out high-frequency noise to get more precise readings. There's also an unused second power switch and a bunch of excess spaghetti I should have maybe cleaned up before the photo shoot. Below is a much clearer diagram you can follow to set up the same circuit on your own breadboard:

    With all of this hooked up and installed, we were ready to plug in the USB cable and say Hello World ...

View all 6 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates