Show older

I got a MIDI app on my phone and connected the electro-sax with a USB OTG cable - the latency is much lower! It's definitely low enough to be fun to play now.

So that means I have to delve into linux audio again. I might just revert from Pipewire back to Pulseaudio just to see what effect it has.

So far in my attempts to improve the sensitivity of my breath sensor, I've managed to make it worse.

The first cardboard prototype had a range of 0.38V, or 77 counts in an Arduino's 10-bit ADC. Ideally it'd be more than 127 for a completely step-free MIDI reading.

The 3D printed prototype got me 18 with the nitrile glove membrane, or 31 with a white balloon. Not great. Hopefully the sensor I designed it for will arrive tomorrow and I'll be able to try it out.

I also got a BMP280 pressure sensor, which should be able to be polled fast enough to get useful readings. That might be an avenue worth pursuing as it can be in quite a small chamber!

Hmm, not doing great with the BMP280 pressure sensor. It works really nicely for detecting a change in pressure, but it doesn't seem to be very good at going back to its original zero point.

So in the screenshot you can see the lows are at different points each time I stop blowing. I assume it's doing something clever, but whatever it is it makes it less useful to me.

The best breath sensor I've built is still the original LDR-based one, with a difference between "not blowing" and "blowing hard" of 77 counts.

I could tell that its response was slow, though. So now I've measured it!

Going from LED off to on, the response time is 30ms. From on to off it's 100ms. Luckily that's the ok way round, and normally it won't be varying by so much.

I'd like it to be faster but it's probably an ok solution for now.

Time for a slightly more scientific test of the TCRT5000 based solution. This is the reflective IR sensor with an IR LED and phototransistor.

So far it looks like I can make this good enough by correctly setting the distance between balloon and sensor, and the LED brightness.

I might also test the effect of changing the (current limiting?) resistor next to the transistor, because I've never really got my head round transistors.

It looks like I found the sweet spot for this sensor. With this setup it's 14-16mm from the membrane. My measurement of the distance is bad so I'll still need some adjustability.

I found it was best to set the current-limiting resistor for the LED so that the "non-blowing" voltage was about 4V - maximising the sensitivity.

Not sure why the distances needed in the datasheet are shorter than mine - they're using a mirror to reflect the beam so I'd expect it to be longer.

I tried changing the resistor on the phototransistor and it didn't have much obvious effect on the max breath sensitivity, so I'll probably leave it at the original 4.7K.

The electro-sax now has transposing! You press a key combination to activate transpose mode, and then play the key you want to transpose to. So if I want to play alto sax music in the right key, I play Eb and then press the octave key to lock it in. It seems to work well!

It needs a few octave keys so it can play in the correct octave, but that's fine for now - an octave off is still better than attempting to tranpose in my head.

The electro-sax sensor distance tester looks pretty cool. This will let me vary the distance between the membrane and sensor in a more controllable and measurable way than my cardboard prototype.

Look mum, I did a science!

This is using the new sensor distance tester. It made it so much easier to do this experiment properly.

It looks like my previous conclusion was about right - 13-15mm between sensor base and membrane is about the right distance.

The good news is that with that distance, I get a range of ~270 ADC counts between "not blowing" and "blowing as hard as possible". That's great - it can easily be mapped into MIDI's 127 breath velocity values.

Here's the new breath sensor design mounted to the electro-sax cardboard prototype. It's a lot nicer to play! I can do staccato notes now!

Latency continues to be a problem on my computer, but at least I can be sure it's not on the Arduino, as it works fine with my phone.

I tried switching back to Pulseaudio (from Pipewire) to see if that would reduce the MIDI/audio latency I'm seeing with the electro-sax. Haven't measured it yet but it doesn't seem like it made much of a difference.

Hopefully that's an indication that it's not on the (complicated) audio side and instead on the (slightly simpler) MIDI side. Better not be something fucky with USB.

Just to compare audio latency, I'm trying out a live USB of Ubuntu Studio. It looks like without doing anything, that cuts my latency from 150ms to 93ms. And changing my headphones to my front panel output instead of my USB DAC cuts it further to 24ms.

That's still not amazing, but it's a world of difference from being unable to play properly.

Switched back to the Arch install and changed headphones to the front panel output instead of the DAC. I got ~60ms latency. Still playable.

So why is the Audioquest Dragonfly's latency so bad?

Some more progress on the updated breath sensor. It's still quite bulky, but at least with the longer mouthpiece I won't be bumping my nose into it!

Will try this for a while before deciding whether it needs a fake reed - the positioning of the air inlet might be enough to make it feel close enough to a real sax.

The sensor holder is supposed to stay clipped to the body of the sax, while the rest can be unclipped for cleaning.

The actual clips are not very well designed for 3D printing in terms of layer orientation, so we'll have to see how that goes. They may not be very durable.

Ok that didn't last long!

Might just make it screw on instead in the next version because that's easy

There's something weird going on with the new sensor - when blowing gently the reading from the sensor actually goes down!

Here's a graph of the readings as I gradually increase from not blowing to full speed. It dips down at the start. That's not good!

I'm guessing it's because I added a slight "bypass" between inlet and outlet, and the flowing air has a lower pressure that actually pulls the balloon towards it.

For reference, here's the previous sensor. You can see because the air *must* move the balloon to flow from inlet to outlet, there's a significant jump when I start blowing.

I think that's the better way to go!

I spent a bunch of today trying out different combinations of software and hardware to figure out the best latency I can get.

I'm really not sure how to present the info so here's a table. It looks like I can get latency as low on Arch as I can on Ubuntu Studio (without tweaking Jack). The lowest latency synth is Yoshimi, but Qsynth is good. Pulseaudio seems to be lower latency than Pipewire.

I suspect a good chunk of the remaining latency could be on the Arduino side, so I'll have to measure that next.

New electro-sax breath sensor is attached. It looks pretty good but unfortunately it's kinda bad :(

It has the thing where if you start blowing suddenly the note is really quiet. I'm really not sure why. Got to figure out the actual cause.

The feel of the mouthpiece is good, but I need to be able to twist it to an angle for it to feel right. Aligned with the sax means I need to twist my head.

Maybe this is the cause - the response is really non-linear. It jumps very slightly above the 0 point, then sits level as I keep blowing more, then suddenly jumps up before increasing linearly.

The other graph is me playing a piece - it looks alright to be honest, so maybe it's not the non-linearity, it's something in my program?

Taking a break from breath sensing to try out the Teensy. The built in touch sensing is very neat!

I might use this with an analog multiplexer to make a touch-sensitive version of the electro-sax

A bit more playing around with touch sensing on the Teensy. It's a little stripboard keyboard which can only play a C arpeggio! It only uses one touch sensing pin along with a 4067 analog multiplexer to get 16 touch inputs.

That's enough for all the keys currently on the electro-sax, plus two more octave keys and... I dunno, two more to do something.

It didn't take long to build a touch-sensitive version of the electro-sax! This is definitely nicer to build than soldering a key matrix with diodes, but the analog sensors aren't quite as nice to deal with on the code side.

The key thing is that it works! I'm not actually sure whether I prefer the buttons or the capacitive sensors. I need to tweak the sensor calibration a bit before I'll be able to tell.

On this one I added a second octave key so there's now both "octave up" and "octave down". So it has a way of getting to the lowest notes that would typically use pinky keys. It's still missing the high end that's normally done with your left palm, so maybe it needs a third octave key.

I'm not convinced by the touch buttons on the electro-sax, and I had a few microswitches laying around, so what about using those for the keys?

I 3D printed some little button assemblies and a frame to hold 4 of them in place. I didn't try a print-in-place pivot on the buttons - instead there's a hole to insert a small bit of filament.

The action of the switches is quite smooth, and maybe low enough pressure to be usable. It's worth a try.

Deleting and redrafting lost the images the first time >:(

I'd post the switch assembly design from FreeCAD, but it won't start properly since the last update.

Recompiling FreeCAD got it working again. Here's a cross-section of the button holder design. The pink and green parts are printed in one go, the grey part is the microswitch.

There are a few issues with this design. It's a little scratchy where the layer lines of the two parts rub together, and it varies from print to print.

The microswitch is mounted to stripboard glued to the bottom, which is not great because the glue is all that stops it falling off. Ideally it would be held by some plastic.

Another problem is that the prints are failing a lot, because the on the right, the pink part only has a tiny surface touching the build plate. Looking at it, it doesn't need that much of a fillet, so I'll reduce that and hopefully it'll work.

It was hard to tell from small test sections whether the microswitch-based buttons actually felt good for the electro-sax. So I put together another cardboard prototype!

The verdict: Once they're mounted on an echoey box, these keys are way too clicky. Like distractingly clicky. It's also not nice having the activation at the start of the stroke. On a real sax it's mostly at the end.

Also black was not a good filament colour choice for parts I actually want to take photos of.

I'm not gonna wire these keys up into a proper matrix to try them out. They already feel worse than the touch buttons or original Gateron switches.

I liked the convenience of wiring the touch buttons - just a single wire to each key, and I could have up to 16 wired to the multiplexer. No need for a matrix or diodes.

I think it would be good to try hybrid buttons - moving mechanism but capacitively sensed. It sounds like it'd have the nice feel of proper keys but the ease of wiring for cap sense.

First attempt at a hybrid button for the electro-sax: It feels pretty nice! It'll be closer to a real sax in that the activation is at the end, when the valve finally closes.

This is a mod of the microswitch design to add nice surfaces for copper tape. The Teensy capacitively senses on the bottom part, and your finger makes contact with the top part.

It can actually sense whether you're touching as well as whether you've pressed, which might be handy!

I improved the hybrid button design a little. The return stop now doesn't push into the case, which should remove the rubbing against layer lines that I was feeling.

It's also got a longer travel, which should be closer to a real sax (that may or may not be a good thing).

Time to print it and find out what's wrong with it!


The new button design works just as well! The feel is definitely better, although I still need to make some adjustments as my tolerances were too loose.

I might also tweak it so that it's angled slightly upward by default instead of being flat. The 6mm travel is maaaybe a little more than is needed to feel right, too. I might bring it down to 5mm just to reduce the height.

· · Web · 2 · 0 · 2

It's been a while since I attempted digital sketch rendering, so I drew up some form ideas for the electro-sax on paper, then took a photo and added colours in Krita.

It took a very long time - I need lots of practice!

I'm getting the hang of FreeCAD's Link functionality - here's the finger buttons mount with the new hybrid buttons linked in. It's not yet set up as a proper assembly with mates - they're just positioned by coordinates.

Here's a few generations of the hybrid switch design. The latest design adds a slope, so that the capacitive sensing copper tape is parallel to the tape you touch, when the switch is closed. I haven't tested it yet, but it should make it more sensitive.

These new thinner silicone o-rings are much better for the return spring. It's enough to pull the button back up, but provides a lot less resistance to pushing the button down.

A new full electro-sax prototype in progress. This has the new hybrid capacitive/mechanical switches. Just pressing these, it feels like some (like the side buttons) might need stronger elastic to feel right.

The hybrid switch prototype is ready to play! And as expected, it still needs some tweaks.

Firstly, the button travel is too long. I made it match my real sax, but it doesn't feel right. I think something shorter would feel nice and responsive. The side buttons in particular need a MUCH shorter travel.

Secondly, the cop-out octave button I put on the back really isn't working for me. It needs to be squeezed in towards the sax body, instead of pushing upwards.

Other than the long travel and bad octave button, it feels really nice! The keys feel nice and tactile, although they could do with a more solid end position. Currently the "bottoming out" is kind of mushy.

They're definitely less pleasant for other people to hear than the touch-only prototype, though!

Fixed my two biggest problems with the electro-sax. The side buttons now have a shorter travel and stronger O-rings so they feel great. The octave keys are back to being parallel with the back of the sax, and the shape works pretty nicely.

I also added some buttons on the back for triggering calibration and for transposing.

It still needs some work to save the calibration to the EEPROM. I think the keys are definitely too noisy too - could do with a bit of cork or something.

The new electro-sax hybrid touch buttons vary too much to use a single value for the threshold for each. That meant that I needed (wanted anyway) to implement saving the calibration to EEPROM.

Turns out that was pretty simple, and now I don't need to recalibrate all the buttons and the breath sensor every time it's plugged in.

I've noticed a problem with changing octave in the electro-sax. Because the buttons and notes are just on/off, you have to perfectly time your octave key press/release with your note key changes.

If you don't you get a little "blp" as it briefly plays a note of the wrong octave.

I think the non-mechanical octave buttons make it harder to time it perfectly, because they're different to the finger buttons.

It's something that an acoustic sax just automatically deals with, because you have to change your mouth shape as you change notes. You can't (easily) accidentally play the wrong octave, the sound just gets strangled. So it's easier to make octave changes smoother.

I finally made a new breath sensor that's *better* than the first one! It feels nicer and the modulation is even a little better.

Also the wiring comes out the bottom which is a lot neater. No more wires getting in the way of seeing the music!

I'm not sure this is the final shape I'll go with but I *do* think it looks pretty cool!

Here's a rough schematic of the electro-sax's internal wiring:

I think it'd be a good idea to add some feedback LEDs for the three calibration buttons, so you at least know whether the press was registered. Maybe also a "cancel" button in case you only accidentally hit them.

It's been a while since I worked on the electro-sax, but I'm back at it. I wasn't happy with the octave buttons, which were just capacitive buttons and hard to time right. They needed a mechanical element like the finger buttons.

Some quick sketching helped me figure out how I wanted to do this. It could also be 2 of the finger buttons facing each other, but that just didn't seem very nice to me.

The prototype feels good on its own, I'll have to get it mounted to the sax to figure out if it's right.

Update on the hybrid thumb buttons for the electro-sax: They feel good! The way they pivot is very similar to the one on an actual alto sax, so it feels right.

The only problem is that the activation point is too late - on a real sax it's near the start of the press, here it's near the end. I can either make the travel shorter or make it more sensitive to presses in software. The latter approach is easy but has the risk of making it too sensitive and registering phantom presses.

I'm still working on the electro-sax project, just very slowly. I settled on using mechanical buttons with capacitive sensing because they feel like a real sax. Now I'm opening back up to other options that would be less susceptible to interference.

I've bought some conductive silicone to try something like a membrane keyboard. Got some small magnets and Hall effect sensors on the way. I could make contact between two battery springs, but I'm not super keen on it and they're kind of expensive.

Hall effect sensors seem quite neat for electro-sax keys. I bought some unbranded 49E ones and they seem very low noise compared to my previous capacitive sensing. Right now it does mean that I have to use analog pins on the Arduino, so I'd still need a multiplexer to have enough for a full sax.

I like the idea of adding a per-key threshold with a comparator and a potentiometer. That way it's just on/off signals going between keys and microcontroller.

There are 13 keys (currently) and 16 IOs available on a Pro Micro. That leaves me enough free to use one analog pin for the breath sensor and there are still a couple free for buttons. Maybe I should make those the i2c pins just in case I need an IO expander.

Alternatively, maybe I could get the comparators to trigger transistors, and scan them as a matrix? That would get me down to 8 IOs used for keys. It's more comfortable but adds extra parts to each key (and I'd need to figure out how to do that!)

This is the kind of thing I'm thinking of. The green trace is the hall effect sensor output, going from 4.5V when the magnet is far away to 2.6 when it's close.

There's a threshold set with a potentiometer (represented by R1+R2) and the two are compared by a comparator. It goes high when the button is pressed down.

Now I think I just need to get the comparator to switch a MOSFET which would be part of a matrix.

I'm not entirely sure about the multiplexing for the last bit. Any thoughts?

I tried out the conductive silicone. Cut some interlaced fingers in a piece of copper-clad board and laid the silicone on top. Even just the weight of the silicone is enough to make good enough contact to overcome the Arduino's internal pullups.

I'd be a little bit concerned about debouncing (without introducing too much latency) but this seems like a nice simple solution for the main finger keys on the electro-sax!

Show newer

@gbrnt Links are super useful. Use them all the time in my designs. I end up modeling sub-systems in a single FreeCAD file, and then I link larger assemblies together. I also often use separate files for CNC work, linked back to the original design.

Which assembly workbench are you using? I've had pretty good luck with Assembly 3.

@fortifieduniverse I'm not using one at all yet, so thanks for the recommendation!

@gbrnt Sure! I tried Assy4 and Assy2, and Assy3 made the most sense to me. I end up using like 3 different constraint types 98% of the time. Assy3 looks complicated (because it's super powerful) but once you figure out the small, happy subset, it's pretty straightforward.

If I can do anything to help with the learning curve, let me know!

@gbrnt I wish I could do more than extrude a cylinder in freecad.

I'm following your project in awe (not just for freecad)

@signaleleven I was kinda like that when I first started using it! Even though I'm familiar with using CAD, something about FreeCAD still feels kind of alien. It's mostly just a matter of practice.

@gbrnt yeah I need to follow more tutorials. It's just not something I can dedicate a lot of time. And I got severely spoiled by Fusion 360.

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!