The Science Lab


In an effort not to clog up to stop clogging up the ‘what did you create today’ thread like I normally do, I figured I’d make a separate thing here for people like me who are rapid-firing stupid / fun shit all the time that doesn’t quite constitute as a “listen to this song I made” post.

TL;DR: Are you doing weird shit with or without your DAW / pants on? Post it here (I want to see it in action!). Explanations and Q/A’s are encouraged, as always :smiley:

My PC couldn’t keep up with the science on this one, maybe my laptop will fare better. Brief explanation: Sonic Pi is controlling VM without the DAW in the middle this time. So every note, LFO, clock signal, etc was something I coded up in Sonic Pi and then piped into VM. I’m not sure how it works so well, either


This thing (the Mega) isn’t supposed to handle MIDI (or really any HID-emulation), but I figured out a workaround. Not exactly sure why you’d need 8 potentiometers plus a rotary encoder, but it’s kind of funny that you can put it in a jar when you’re done with it :smiley:

The best use might be 8 macros, but I’m considering expanding this idea to weird sensors instead. If anyone has a suggestion (IR, touch, magnet) I’ll make it happen :smiley:


So much yes. :grin: im drunk af right now fyi…


Did you use Hairless MIDI or flash the firmware to something with support? I know there’s several ways to skin the bear on 328 chips regarding the HID/MIDI thing, but it’s been a while since I looked into it. You can also just use a 5-pin MIDI out to skip USB to Serial, but it means having something on the other end that’ll accept it.

If you’re going to keep heading down the rabbit hole, you might look into ATMega’s 32U4 boards, as they do HID out of the box and you can load Serial to MIDI code alongside it which makes it pretty simple (it’s entirely possible you already know this having jumped through the hoops, if so - sorry :smiley: ). The Arduino Leonardo is a good one with lots of I/O, but you can get cheaper, smaller boards (Pro Micro-style) and multiplex them together for a ton of controls.

Years ago (very early 90s) I had an oscillator bank hooked up to optical sensors that I played with a flashlight (which was pretty neat on a dark stage). Might be fun to try reading something like that.

Capacitive touch sensors are lots of fun and super useful, but a linear softpot as a ribbon controller can get really wacky.

Looking forward to see what you come up with next!


Yeah, I went the straight-up lazy way with Hairless MIDI and the included library. Unfortunately the library was a bit outdated and needed a few changes, but thankfully I was able to get it up and running. Everything seems to work pretty accurately with it, though, so I’ll probably use that and LoopMIDI (which is also how I got Sonic Pi working) quite a lot going forward.

I actually do have a Leonardo that seems to work 90% of the time, but it’s a blatant Aliexpress counterfeit so sometimes it just fails to upload sketches. I haven’t had it tank on me during operation, but sometimes it’s a serious fight to just get something to upload. I do have some groovy shields for my Picos though, so if I run into issues with this janky setup I’ll probably just start using those more :smiley:

Damn, that gives me a great idea – MIDI theramin :smiley: . I bet something commercial like this exists already, but I literally hadn’t thought to try it until you mentioned playing with light!

Also if you (or anybody else!) wants my version of the library that’s working with the current version of Arduino, I get this feeling the mods will be fine with me uploading it here


I believe that’s just a Theremini with a pitch quantizer (optional, of course) and a CV to MIDI converter.


I might actually have 2 photoresistor modules, this could be a really interesting place to start. My original idea was to just control the pitch with that, accompanied by a constant note out or something, but I need to actually revisit how they work before I pretend like I can emulate one with this janky rig :smiley:

Seems like something that could also be incorporated into a free-running sequencer, if all else fails :relaxed:


I’d love a copy of that library if you don’t mind sharing it!

Hairless was my first foray into ATMega/MIDI land, too. I like that there’s chips in the line that do that thing we want, but I wish there were more of them and/or they were advertised better, but I guess audio isn’t really their bread and butter…

My Leonardo hasn’t ever had issues with sketches, but it’s a ‘real’ Arduino, maybe that actually makes a difference. But tbf, I haven’t really done a ton with it either, so maybe it’s a problem across the line and I just haven’t messed with it enough.

As another alternative, I’ve almost pulled the trigger on a couple of Teensy boards - they’re a little pricey but at least an order of magnitude faster and might be cool for some DSP (which I think it supports on-core) or the overhead of multiplexing, though I haven’t really looked at what kind of code is already out there and don’t know how much I’d want to roll my own.


I’d love to hear it if you try it, but my guess is it’ll be disappointing. I think maybe the magic of the theremin is that it’s analog so you’re not bound by discrete steps. I may be way wrong here because I’ve never tried it (and again, let us know if you do!), but I think 127 intervals will probably kill the sweet glide and pseudo-unpredictability/wildness of it. I’d worry it’d just sound like an oscillator, unless maybe you bound it to a single or double octave range (which now that I think about it might be fine?)

To that point, I’d love to see some sort of SoC MIDI 2.0 implementation - my guess is that jumping up to 32-bit/4 billion steps would probably get close enough to analog to mimic it, and to me it opens up a whole world of “fuck CV, I can just use MIDI” stuff that’s really intriguing. I haven’t looked into the MIDI 2.0 spec or implementation - I wonder if it’s something that would be doable on an embedded system like a ATMega.

Anyway, sorry that got long :smiley: I don’t get to stretch my music/programming/DIY muscles in a conversational way much lol. Keep the cool stuff coming!


That’s actually hilarious on my end, because even my most ‘expensive’ boards are just clones. Most of them take a few tries to upload sketches which can hold up progress and make me antsy sometimes, but I’m sure at some point I’ll just have to get an OG (or maybe like a Sparkfun / Adafruit) just to see if there’s a significant difference. There’s a possibility that they’re all just a bit finicky, too.

I actually keep hearing people online talk about Teensy boards, so I need to check them out. Some that I have seen so far that looked really interesting were those Daisy Seed boards, which I think pretty much have a built-in DAC / ADC and are ready to interface with Pure Data out of the box (IIRC, if I’m not confusing them with the more expensive Organelle). Stuff like that is crazy, and I’m kind of hoping boards like that get more popular, affordable and maybe even cloned quite a bit in the future.

I know nothing about MIDI 2.0 (honestly, I keep learning new things about 1.0 because I’ve really never experimented with it up until a few weeks ago), but that would be pretty amazing if someone made a serial bridge for it. I posted the video below, and a slew limiter sorted the quantizing issue, so whether going straight from MIDI to CV is cheating or not is in the eye of the beholder :smiley:

I’m going to pull that library out and upload it ASAP!


[](http://Video link)

I don’t think YT shorts embed here (I didn’t mean to make a ‘shorts’ video), but here’s the theremin lite. Definitely needs some expansion, maybe even some more random sensors, but it works!


The modified library ^. Apparently their copyright allows this, so that’s cool


You did the science! :smiley: The sound without the slew limiting was what I was thinking it’d sound like, but fixing it in post is totally legit and sounds great. And iirc a slew limiter is just a linear LPF so it’d be easy to implement in hardware if you weren’t going into software. I’d say that setup’s a win for a first try. If you want to keep chasing that sound, I’d suggest adding another sensor for volume - in my experience it’s the interplay of volume and pitch that moves it from “interesting noise-maker” to an instrument.

Thanks so much for the library! I’m swamped with non-fun work crap right now but I’m going to try it out as soon as I have a chance.

The Teensy stuff looks cool because they’ve got a lot of power to play with, though I think it’s honestly overkill for something like a controller unless you want to add in…other things? I don’t know what it’d be, but there’s a lot of cycles to play with. The whole ATMega chip line seems to be enough for controllers and is mostly just limited by inputs, and is dirt cheap if you don’t get the fancy kits. I feel like the Teensy stuff is probably better suited for synth or DSP where you would actually use the extra oomph.

It really seems like the rest of the shit on the board is as or more important than the processor - A/DC, memory, I/O, etc. Like the Daisy is just an ARM chip at it’s heart, but everything surrounding it looks specifically set up for audio which is super cool. If you’re super-DIY overachiever, most of that stuff could be added as breakout boards, but I ain’t got time for all that. The Daisy really looks like a sweet spot for getting everything you need in one go. My only concern is it seems like a limited ecosystem so there’s not a ton of external documentation or code to riff off of (their github is nice but doesn’t seem to be actively updated).

I guess the next step further would be a Raspberry Pi. I have a couple but they’re spoken for doing house and work stuff and haven’t really messed with audio on them. They also got stupid expensive during the pandemic and I wasn’t going to pay $200 for something that has a MSRP of $40. But I have seen some really cool projects for them, like Zynthian, which might be a good platform for development.

The whole other direction would be bespoke DSP chips like the Analog Devices SHARC or Spin’s FV1 that does multiple MAC instructions per cycle for fast FIR and parallel effects (Strymon uses SHARC, I believe, and it’s hard to argue with those results). AD also has a newer SoC line called SigmaDSP that has a graphical editor similar to MAX/MSP or PD, which sounds pretty neat. Problem with all that stuff is it’s expensive to get into for one-off hobby things.

I know all the Mutable Instruments modules used Cortex-based STM32 chips specifically because of not wanting people to have to buy into expensive ecosystems, and I have a bit of “If it’s good enough for Braids and Clouds…” going on lol. On the other hand, Emilie spent a lot of time writing low level code and custom bootloaders to eek every last bit of of those things, which is farther than I’m likely to go.


Huh. Limit the range to an octave or two so that you have finer control and I think this would be pretty neat. A theremin is kind of a commitment with the two whole hands and all. But make it one or two fingers and it could be a neat accompaniment instrument or like a modwheel addition/replacement.


That definitely is a bit of a roadblock for DSP stuff; even the one I mentioned is nearly $99 IIRC, so having a few on hand starts to become a bit of a splurge. And then, god forbid you want to use your design in physical-module form, and by that point you’re looking at like $300 just for one full setup.

Another interesting way (in theory) would be to do it all on breadboards, Ben Eater or Look Mum No Computer-style. I could see the cost of components maybe being worth it just because of how reusable they are, and kind of keeping your own DIY modules around just as a cool learning experience. Just because I’m poor and get a bit obsessive, this actually doesn’t sound like a bad deal, although I could see others with less time on their hands just wanting a breakout or shield that handles all of that.

I’m a bit curious about those Raspberry Pi clones lately, too. Some of them seem to nearly rival a 4 for about $30-$45 on Amazon, and strangely the only complaint people seem to have is that they’re a little tricky to get up and running. Obviously this won’t be worth it if the Raspberry Pis actually come back down to their original MSRP, but they might be pretty decent in the meantime. Also, some of these seem to have more GPIOs and development features than the Pi 4, which could really make things interesting.

I will also have to google some of the others you mentioned, because this is a whole new world to me. Having a MAX-style editior would be absolutely amazing for projects like this!


Great suggestions! I’m pretty unimaginative, so you are a crucial part of the science lab :smiley: . I still need to conduct research on how a theremin actually works (I still can’t spell it without spelling suggestions, lol), but you’re both right that it needs another component (that other photoresistor, I’m sure it’s around here somewhere!) to control the volume, velocity, etc.

I’m not sure if using a lamp will increase the range from where it starts detecting darkness or not, but I need to experiment in other lighting environments. My wife is a bit fascinated by theremins as well, but when I moved it to another room for her to check it out, the values got all fucked up due to the different lighting. I can’t imagine what the people who engineer instruments for the rest of the world have to go through!

I’m also a bit dumb on the hardware end, but it seems like a stronger resistor should actually allow for more precision (in my brain, it sounds like the opposite would be true). I didn’t measure the photoresistor’s value itself yet, but I’m sure it’s pretty weak and that could be a contributing factor to the lack of sensitivity.


I habe nothing to add…

Just wanted to say this thread is so much awesome


I thought this one was going to be stupid, but thanks to a happy accident it went in a totally different direction. Originally it was supposed to just ‘note off’ everything when the button wasn’t being pushed, but looping through the available notes didn’t seem to shut them off (looks like a CC 120+ ‘panic’ will do it for future reference), so I just went with it and turned it into a MIDI painter. Pretty weird, possibly useful.

It definitely needs a master kill-switch on the hardware end, now that I know it’ll actually respond to one, but otherwise :smiley:


Damn, this loopback shit is really versatile. I’m not addicted though, I can stop anytime :smiley:


All the hardware talk leads me back to the same discussion I have with myself - what’s this shit for? What am I actually going to do with it? Is it just for me to learn about and play with? Is it something I want to keep forever and use as a music tool or am I going to tear it apart in 6 months when I really need that 10k pot or inductor in there?

Then the details of those internal discussions follow… do I care how big the components and board are? Do I really want to box up a $100 Pi or should I spend hours hand coding something to work on an ATMega? How many musical projects could I have finished in the time it took me to solder all that crap? Did I just manage to build something that costs twice as much as the retail equivalent? Is any of this shit useful to me when I have a computer right here that can do 99% of it?

And I don’t have answers to much of that. I guess it depends on the day and how much coffee I’ve had. But there’s a limit to how much rabbit hole I’m willing to fall down over ‘developing’ something, and it’s death by 1000 cuts to go from building out something in PD/Max/Reaktor to a Pi running Linux to loading someone else’s code onto a Mega to custom coding something for a SoC.

I guess my tl;dr is, at least for me, answering some of those questions points me in the direction of what sort of hardware I want to consider and what I’m willing to rule out for my own sanity and focus.

Regarding the perfboard/stripboard options, stripboard is perfect for transferring from breadboard because it’s the same connected rows. In my experience it works just fine.

There are cheap and reliable ways to etch your own PCBs using a laser printer and crap you can buy for a few dollars at Home Depot. Layouts can be done in KiCad, which is free. That’s obviously a whole different branch of DIY, but it does open up options for making one-off boards, especially if space is a consideration. It also lets you make/modify PCBs from existing ones online like here and here, which is pretty cool.


*** Massive nerd shit ahead ***

This depends on the circuit after the resistor. Photoresistor is just a variable resistor that changes the magnitude of the incoming voltage and nothing else, just like a wiper pot. If it’s at half mast, you get half the total resistance (10k * 0.5 = 5k ohm). What that does to your signal depends on the rest of the circuit.

What’s your circuit topology? Are you using the photoresistor in a voltage divider? If not, you should try that as they tend to be easier to tune.

Assuming a voltage divider, it’s V.out = * R2 / (R1+R2) - there are calculators for this online

Consider: = 5V, R1 = 100k, R2 = Photoresistor with a range of 1k to 10k

V.out_max = 5V * 10000 / (100000 +10000) = 0.45 V
V.out_min = 5V * 1000 / (100000 +1000) = 0.05 V
V.out_diff = 0.4 V

so in this case the static resistor completely dominates the equation and you get a voltage range of 0.4V. This is small enough that you’d likely to to amp it when it comes out of the divider.

Changing the R2 static resistor is going to have a big effect on how your photoresistor operates. = 5 V, R1 = 1k, R2 = Photoresistor with a range of 1k to 10k

V.out_max = 5V * 10000 / (1000 + 10000) = 4.55 V
V.out_min = 5V * 1000 / (1000 + 1000) = 2.5 V
V.out_diff = 2.05 V

Dropping down from 100k to 1k means a ~2V range, or a 5x increase in voltage change.
(note this is a novel case for voltage dividers, where R1 = R2, you get half voltage)

And here’s with what amount to a pull down resistor and the photoresistor dominating: = 5 V, R1 = 100 ohm, R2 = Photoresistor with a range of 1k to 10k

V.out_max = 5V * 10000 / (100+10000) = 4.95 V
V.out_min = 5V * 1000 / (100+1000) = 4.55 V
V.out_diff = 0.4 V

Dropping down from 10k to 100 bounces you back to the same 0.4 V range with of 100k, but on the top end of the voltage.

So the question is what happens when you bump the knob (or shine slightly more/less light)? You now have max_res * 0.4999. You have a 49.999 ohm resistor instead of 50. If you have a 10k pot, you have a 4999k resistor. Does changing the voltage by 0.001 ohm even register in the rest of your circuit?

I’d see if you can figure out what the range of the photoresistor is (this should be easy with a multimeter or a little test circuit). Then tune a voltage divider with different static resistor values to get a range that works for what you want to hear.