FBXL Social

I like the idea of making a DIY midi saxophone. Just a very basic one to make some noise

I'm guessing the hard part is measuring the breath. You could measure pressure, but if you're simulating a real sax it would have air passing straight through. I'm not sure the pressure would change much?

@gbrnt You could use a hotwire anemometer to measure the windspeed!

@angelostavrow Yeah that would be super cool - maybe overkill? I wonder if it's enough to just measure the pressure. That would mean you can save your breath!

@gbrnt To measure pressure, I *think* you'd need a closed volume — whereas a sax is a flow-through instrument, right? Like blowing into a test tube vs. blowing through a straw.

@angelostavrow Yeah - although it looks like people have done it blowing into a closed volume, so maybe it doesn't feel that weird? I think I'd have to try it to find out.

Hmmm

Long pastry packaging with buttons stuck in it, next to an alto saxophone

@gbrnt Sorry to disappoint you, but I believe it counts as a clarinett so long as it's burnable. 🙃

@friend Good point, but I don't have a clarinet to put it next to

I added a basic breath sensor to the pastry saxophone. It kinda works! The response of the breath sensor is quite slow - I think I need to use something stretchier than a nitrile glove. It doesn't feel sensitive enough to do staccato notes or anything yet.

I didn't get dynamics working with the USB MIDI yet, but on/off breath control works well

Pastry box saxophone with a new black box at the top end The black box - there's a straw coming out of it to use as a mouthpiece

The breath sensor works like this guy's video: https://www.youtube.com/watch?v=es92GqYBge0

The black tape all over it is to block out light - I found it was making a big difference to the readings.

Some quick sketches for a 3D-printed version of the mouthpiece. I can sandwich a membrane between two halves and make the whole thing a lot smaller.

Page of pen sketches of different ideas and views

The volume of air inside is smaller, and I'm hoping that means that the response to changes in pressure will be faster, enabling me to do quick staccato stuff.

Here's a first draft of the mouthpiece half - this should work ok. The other half with the sensor should be quite simple and can wait until tomorrow.

FreeCAD screenshot of mouthpiece part based on previous sketch

@gbrnt wait, is that ? The default blue background is a telltale.

@normandc Yeah it is! I did change the default background but for whatever reason it wasn't working for me, so I changed it back.

I've started printing the mouthpiece and designed the sensor half of the breath sensor. This uses a TCRT5000 IR reflectivity sensor, which shines at a diaphragm clamped between the two halves.

When you blow into the mouthpiece, the diaphragm expands towards the sensor, increasing the amount of IR that's reflected back into it.

The sensor half of the breath sensor. You can see there's a circular baffle inside to block light from outside. The two halves stacked together. Maybe I should have designed the mouthpiece the other way up - I might hit my nose on the sensor block! Cross section of the air passages in the sensor - green for inlet from the mouthpiece, red for the outlets from sensor chamber and the mouthpiece side.

@gbrnt @normandc Interesting project! I wish I could sketch as nice as you do. I've to power on much earlier blobpats

Aaaand version 1 of the electro-sax mouthpiece is sort of assembled! It seems like it'll work but I won't be able to test it until the actual sensor arrives at the end of the week.

The two halves 3D printed in green, assembled with screws and a nitrile glove membrane

Electro-sax is just a way cooler name than midi sax

@gbrnt it's a whistle lol

what are the tiny holes for, tuning?

@piggo They're the footprint for the sensor, so I can just have the legs sticking through and solder some stripboard on the outside.

@gbrnt Next up: MIDI Vuvuzela

@eric Haha it's about as playable as that right now!

Dynamics now work! I'm using the breath velocity value from the cardboard breath sensor to set the MIDI breath controller value, and mapping that to volume in the synth. I'm sure there's a much more complex and nice-sounding config that can be done, but this is cool!

It needs to be a bit more linear, but that just means making some sort of calibration curve for the sensor. That can wait until I've got the 3D printed one working.

I've put the code up on https://gitlab.com/gbrnt/electro-sax

There's currently a latency problem - I need to check whether it's on the Arduino end or on the computer end. The breath sensor has some extra latency - I think that comes from the current prototype but I'm not entirely sure.

The end-to-end latency of the electro-sax is definitely too high right now. It's recommended to get it below 10ms (if you can) and here it is at 160ms.

That's enough that when you're doing something like a run of short notes you do one too many because the sound hasn't caught up yet.

Let's see how much I can improve this just by changing Jack settings. Not sure how Pipewire comes into this.

Audacity screenshot showing sound of key going down at 33.386 seconds and sound coming out of speakers at 33.546 seconds

@gbrnt I'm glad I'm not the only one who still used Audacity... I was told it was outdated, but it's the only workstation that makes sense to me

@evandornbusch What do other people recommend? I haven't seen anything else for basic audio edits

@gbrnt Mostly GarageBand and other free DAW's, but none of them make any sense to me, not like Audacity makes sense to me.

@evandornbusch Yeah it seems a bit complicated to use a DAW for quick audio recordings and stuff. I am using LMMS for the MIDI side of this though.

@gbrnt I got a lot of recommendations for LMMS, Ardour, GarageBand, and Waveform.

@evandornbusch They all seem like they're going for a different kind of vibe to Audacity

@gbrnt I'd agree. What kind of sounds or music do you make? I've been making notification sounds I want to get onto some PinePhone OS's.

@evandornbusch I've done notification sounds in the past, and occasionally edited the audio track of videos (noise reduction, adding music, etc). It's just my go-to program for any kind of audio editing or recording.

In this case it was the first thing I thought of for measuring the timing of the key going down vs the sound coming out of the computer.

@evandornbusch I used to play the sax but it's too loud for me to not feel awkward getting back into it, now that I have a lot of neighbours. So the electrosax is a nice way of practicing quietly.

@gbrnt I don't suppose you could let me check our your favorite self-made notification sound for some inspiration? All of mine involve chirps in the several kHz tone and I've been told they're very unappealing to the average person.

@evandornbusch Sorry, I never managed to come up with something I liked much! The best I've got is a ding sound in my pomodoro timer: https://github.com/gbrnt/pomodoro.py/blob/master/timer_done.wav

@gbrnt I think it's lovely! I am creating a collection of tones and sounds if you ever need one for an open source project.

@evandornbusch Now I think about it I might not even have made that sound! It might have been from freesound.org. I remember trying to make a good ding sound but not whether I managed it.

@gbrnt I would like to offer up my dings for any future projects you may have: https://drive.google.com/drive/folders/1nE7y9TrQn2IoWsYPzqwa-F8iS9TJaE7J

@evandornbusch ヽ༼ຈل͜ຈ༽ノ raise your dingers ヽ༼ຈل͜ຈ༽ノ

@evandornbusch I love your filenames!

@gbrnt Thank you so much! I'm really happy that you like them <3

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.

@gbrnt are you using ?

@evandornbusch Yep, with the "Fluidsynth MIDI Synthesizer" app. The first soundfont I tried didn't respond to breath pressure so I'm looking for one that does.

@gbrnt This app is so cool already!

@evandornbusch What MIDI instrument are you using it with?

@gbrnt I have a Soundbrenner Core I am working on getting to beat to the beat of music. This helps me understand the bluetooth MIDI pathway.

@evandornbusch That looks really handy! (pun intended?)

@gbrnt
The 14 year old version of the CAD software we used up to last October had a light blue background by default. The newer version has an almost white one. I've gotten used to it, and switched FreeCAD to a similar background. I dislike dark themes and backgrounds.

- Tooted on Mastodon's default dark UI 😉

@normandc On my work Solidworks I go for a mid grey background, and a macro that toggles it to white for taking screenshots. Mid grey didn't work so well in FreeCAD because it's too close to the default part colour!

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!

@gbrnt might need to either use a custom AREF or add an amplifier to the signal

@cinebox Yeah that'd do the trick, custom AREF would probably be enough. I think the phototransistor-based sensor that's arriving soon should improve it enough though

@gbrnt
I changed the default part colour in FreeCAD to random! 😀

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.

Graph of pressure over time, showing it goes up when I blow, and down when I stop. It looks good other than that the "not blowing" pressure keeps going down!

@gbrnt If you leave it for 8 hours, does it level out at a certain point?

@gbrnt Seems like it would be usably accurate only if the air pressure changes happen at strictly regular instances.

@sj_zero Probably, even in a few minutes I can see it leveling out. The problem is I was hoping to use it to detect whether to play a note or not, and that's hard when the baseline keeps changing.

@gbrnt I'm just wondering if the issue has to do with it being a brand new sensor and if you cycled it a few hundred times it might mellow out.

@AskChip Which isn't likely when using it as an instrument! I'm sure there's some software magic that could be done to handle the changing baseline, but I don't feel like doing it!

@sj_zero Huh that might be worth a try! I'll leave it connected and test it again tonight

@gbrnt It looks very much like the result of a leak somewhere. the waveforms all drift up when low, and down when high for any period of time.

@gbrnt
perhaps the pressure exceeds the 1.1 bar maximum of the sensor, and that's throwing it off somehow?

@AskChip There's an intentional leak, the chamber is essentially a tube with a flow restriction at the outlet. So when I stop blowing it should always be the same pressure inside (ignoring atmospheric pressure variations)

@till I *think* the values on the graph are millibars so that's not happening, but I could be wrong there.

@till Millibars times 100 or something

@gbrnt Based on the graph, any blowing at all is vastly more pressure than the baseline, so it should be easy to programmatically compensate for the sensor drift.

@yngmar It's easy when you're doing on/off blowing like I was in the graph, but I'm guessing it's harder when you're trying to play a piece of music with dynamics

@yngmar Blowing softly just looks like the sensor is gradually drifting upward

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.

Screenshot of oscilloscope traces showing LED trace in orange and slower LDR trace in yellow

@gbrnt
> a difference between "not blowing" and "blowing hard"

Of course, there's a huge difference!

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.

Experimental setup - sensor in a height adjustable tube over the mouthpiece Oscilloscope screenshot, showing some good variation as I blow on the mouthpiece

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.

My graph - points showing a vague curve that goes up in the middle Similar graph from the sensor's datasheet - it's a bit taller with quicker falloff around the sweet spot

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.

My graph from before but with a new data series added for the 2.2k resistor. There aren't many points but it looks similar.

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.

@gbrnt
Damn, you make cool shit!

@Tay0 Thanks! I'm kinda flitting from project to project while they hold my interest at the moment

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.

Mouthpiece base with a 3D printed tube on top of it and some wires coming out. There are screws in slots on the side to adjust the height of the sensor.

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.

Better graph than before showing range of breath sensor going from 50 ADC counts when the sensor is close to the membrane, up to 270 at 14mm, then decreasing again

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.

Top of the electro-sax, showing the new mouthpiece taped to the end at an angle The other side of the mouthpiece, with a small board for adjusting the internal LED and connected via a cut up USB cable

@gbrnt How did you get the pressure sensor to behave?

@sj_zero I didn't! This is a more mechanically complex version that's based on your breath flexing a diaphragm. It uses an IR reflectivity sensor to measure the distance to the diaphragm and thus how hard you're blowing.

@gbrnt Ah, ok! Sometimes it's hard to fault old mechanical ways.

@sj_zero Yeah, this is one style that Jeppe from Kontinuum Lab on youtube uses, so it's somewhat tried and true.

I was a bit worried about protecting the sensor from the breath moisture anyway, so the electrical simplicity of this is quite nice! Downside is that it's much bulkier.

@gbrnt I dig the pastry box. 🤘

@fortifieduniverse Haha yeah I'm not in any rush to make a "proper" version!

@gbrnt you could just change the box you're using based on your mood. today it's pastries, tomorrow it's a pasta box. 😃

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.

@gbrnt
Good luck! Tricky...

Discovered https://elk.audio/ the other day, don't know if it fits your use case and haven't tested. They advertise low latency.

@arthurlutzim Looks cool! I only see an image for raspberry pi though - is there an x86 one I'm missing?

@gbrnt
I think they focus their efforts of kernel patching on a few platforms, not sure x86 is one of them

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?

@gbrnt USB protocol overhead vs. built-in being right on the PCI bus?

@ieure 100ms difference is a lot though! I bet it's something you can configure some things to minimise but it's way over my head

More saxophone-like mouthpiece in progress

FreeCAD screenshot showing mouthpiece shaped basically like a saxophone mouthpiece, connected to a block with some air channels

Here's the sketch page that led to that design

Page of sketches and notes around a more modular breath sensor, with a more typical saxophone-style mouthpiece

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 breath sensor in FreeCAD. It goes from the mouthpiece on the right, into the mouthpiece block on the left. On top of the mouthpiece block there's a piece which clamps the membrane in place, and then the part which holds the sensor

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.

Shiiiiinyyyyy

3D printed mouthpiece, sanded and polished to a shiny finish

Ok that didn't last long!

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

Freshly 3D-printed sensor mount with the springy clip bit already broken off

@gbrnt Looks like you made a snap on that part, correct?

@gudenau Yeah, it was supposed to snap *on* and instead it just snapped.

@gbrnt It does look like you put the force for that against the layer lines instead of with. But with that shape you can't really do it with. Layers are often the weakest parts of prints because of the inter-layer adhesion.

Happy hacking!

@gudenau Yeah, I was aware of that when I designed it but didn't want to put more effort into it to make that a separate part with the layers in the correct direction. For now I'll just put a rubber band around it to replace the clips!

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.

Graph - it's a flat line, then dips down below the line, then gradually increases relatively linearly before going back to flat when I stopped blowing

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!

Similar graph to previous post but where I start blowing the line suddenly jumps up a little bit before increasing roughly linearly to maximum blowing, then dropping back down to flat.

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.

Table showing various combinations of synth, hardware, audio output, operating system, audio backend and the resulting latency.

23ms is pretty good though!

@gbrnt that's not too terrible at all. Feel ok to play on?

@fortifieduniverse Yeah, tbh I can't tell much difference between 23 and 50. Apparently a good drummer can detect latency around 5ms! Luckily I'm not a good musician ;)

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.

Slightly blurry photo of the top of the instrument, with the more sax-like mouthpiece

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?

Graph of the "blowing gradient test". When I start blowing, it jumps just barely up from 0 then stops increasing. The blowing reaches a certain point and jumps right up, then starts increasing somewhat linearly. Graph of playing. It's pretty spiky with flattish tops. The sudden increases from "not blowing" to "blowing" are very obvious.

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

Teensy LC connected by a wire to some aluminium tape attached to cardboard

@gbrnt I haven't been following your story that well, but how are you sensing the breath? I have a couple of IST MEMS thermal gas flow sensors, if you want to give one of them a try I could mail one.

@uglyhack They sound pretty cool! I think what I have works well enough and is very cheap, but thanks for the offer!

Essentially your breath inflates a rubber membrane. An IR LED shines at the membrane and is reflected to a phototransistor. When you blow harder the rubber gets closer to the LED and so the reflection detected by the phototransistor is higher intensity.

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.

Piece of stripboard with clear tape on top, soldered to a multiplexer board so that each strip connects to a mux pin. The multiplexer is connected by wires to a Teensy LC.

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.

Cardboard cuboid with some copper pads, and a colourful breath sensor at the top end. The tube is held closed with a rubber band.

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.

@gbrnt What were you using for physical switches?

Keeping in mind I'm not a musician (one of the skills I've always wanted but could never quite wrap my head around), but I'm imagining having your fingers on the buttons then pushing them in would be a more intuitive experience than hovering your fingers over the buttons and tapping.

@sj_zero I was using some leftover Gateron Brown switches from building keyboards. Their travel is a bit long for this use-case, but the feel is pretty good.

You're right on the hovering being a bit weird, but it looks like it's not uncommon to use capacitive buttons for this and people do get used to it. I guess it makes it operate a bit more like a recorder.

I'm thinking it would be good to find some switches with quite a short throw and low activation weight.

@gbrnt Sweet! Nice progress!

@fortifieduniverse Thanks! It's not a clear upgrade so I might go back to switches, but it could just be a matter of getting used to it.

@gbrnt Random trivia, one of my early 3d printer projects was trying to replace the home switches with cherry switches.

I was successful, but what I learned is that while cherry switches are very nice keyboard switches, they make terrible limit switches so I returned to standard limit switches.

I know it sounds sort of crazy, like "why would anyone even try that?" but my first printer wasn't very good and playing with it trying to improve the prints was a lot of fun

@sj_zero Haha I guess it was worth a try! Limit switches are definitely something I'm considering - it might just be a bit hard to nicely attach buttons on top. The light force needed to activate them would be pretty nice!

@gbrnt Here's a photo of the test at the time. Doesn't look great but it did work, it just wasn't really beneficial. I was doing some serious calibrations on this printer, and used the repeatability of the calibration as a benchmark, and these were not repeatable.
Cherry switch mounted on a delta printer

@sj_zero I guess that makes sense - key switches are optimised for feeling nice, microswitches are optimised for repeatability.

@gbrnt Indeed. Love watching you iterate, though. Cool stuff.

Thinking about building my own keyboard controller someday... like mill all the keys from hardwood and build my own keybed and such. We'll see. Have a lot of stuff I need to build before that.

@fortifieduniverse This little macro-pad's wooden keys are quite neat! https://hackaday.io/project/179512-custom-wooden-mechanical-keyboard

Looks like they used laser cut layers and sanded them to shape. Routing would probably be an improvement.

@sj_zero With a little 3D printed cap, microswitches seem to work well! Probably needs a better way to mount the cap than superglue, though.

@gbrnt Kinda looks the part too, which is neat.
replies
1
announces
0
likes
1

@sj_zero Yeah! Thanks for the idea :)

@gbrnt That's a sweet little project!

But I'm more thinking about musical keyboard controllers... like:

https://www.soundonsound.com/sound-advice/mechanics-keyboards-explained

Would love to get into building really nice, really well engineered (and beautiful) custom keyboard controllers in the future.

Definitely lots of CNC involved!

@fortifieduniverse Haha I'd actually forgotten about musical keyboards! That would definitely be cool to make - I wonder how they do the pressure sensitivity.

@gbrnt The pressure sensitivity was also one of the first things I wondered about when I started thinking about this.

According to my naive current understanding, most inexpensive controllers actually have 2 activation switches that activate at different points in the keypress... the timing between the two activations is tracked to get velocity.

Not sure about aftertouch. I'm sure it can be figured out. Pressure sensitive resistor strips and such, maybe?

@fortifieduniverse That does make sense as a cheap way of sensing the speed! Pressure sensitive resistors definitely sounds like an expensive way to do aftertouch though!

@gbrnt It'll be fun to figure out what the right approaches are. If it ends up being expensive... well, building one's one keyboard controller from scratch is already kind of an expensive proposition, compared to just buying a plastic piece-of-crap on the internet. 😜

@fortifieduniverse It looks like for per-channel aftertouch it's common to use one long force sensitive resistor. Not sure if FSRs are still what they use for per-key versions though.

@gbrnt Makes sense. Will also have to look into what the new MIDI spec supports, to make sure the controller can support all the things.

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.

Four switch assemblies mounted to a plate. They're staggered to match my fingers. Close-up of the keys. They have a square top with a round concave surface. You can just about see the metal of the microswitch levers underneath. The backs of the switches, showing how they're soldered to stripboard, which is glued to the switch assemblies.

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.

Cross section of the button design - there's a base in green, with an arched lever over the top and both have a hole for a pivot axis on the right.

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.

Cardboard cuboid with black 3D printed keys mounted to it.

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.

@gbrnt Awesome progress!

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!

Cross section of the design - clearly based on the microswitch version but with a hook for a rubber band to pull the button back up when releasing pressure. The assembled switch - there's copper tape wrapped around the two pieces, with an extra layer of clear tape over the copper on the stationary half. A rubber band is pulling on the other side of the pivot, holding the two pieces of copper apart. A graph of the touch sense value over time. At the start it's only slightly varying, which is me moving closer and further from the switch. Then it has a slightly larger variation with sharper edges, which is touching and releasing the switch (without pressing). Finally it has a bunch of big, sharp changes, which are me pressing the switch down.

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!

FreeCAD screenshot of the three parts - a green base, which supports a red lever, and on the red lever there's a purple curved pad mounted to press on. There are some notches on the lever and base for a rubber band to un-press the button.

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.

Graph of the touch readings from the button. There are small oscillations when I move near/far from it, detectable ones when I tap it without pressing it down, and big ones when I press it.

@gbrnt I like where you're going with the design...

@gbrnt Nice!

@fortifieduniverse It could probably be a bit more compact if I could find appropriately sized compression/torsion springs but they all seem super expensive (>£1 a spring) unless you buy a set of 20 different sizes, or thousands of the same spring/. Rubber bands are easy anyway.

@gbrnt I get it. Those kinds of design tradeoffs are always a pain. But it really does look like you're zeroing in on a pretty nice design.

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!

Sketches of various details of electro-sax ideas, at jaunty angles. Mostly centred around adding covers which hide the mechanism of the keys. It's all coloured in very bold orange and greys, with somewhat realistic looking copper on the keys.

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.

FreeCAD screenshot with view of four colourful button levers mounted into recesses in a grey plate. They're positioned in a slightly staggered fashion to match the different lengths of my fingers.

@gbrnt Great image description there! Thanks!

@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.

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.

Three black 3D printed switches with copper tape for capacitive sensing. The first one is more complicated than it needs to be, and uses the base of a balloon as a rubber band to pull it back up. The second is much simpler and replaces the rubber band with an O-ring. The third puts the bottom copper tape closer to the button you press, and uses a weaker O-ring for the return spring.

@gbrnt those look really nicely done!

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.

Electro sax prototype with 3D printed keys with copper tape wrapped around them. There are 8 on the front, staggered to match my fingers, and 2 different shaped ones you can see on the side. It's all mounted on another cardboard box.

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.

The front and right of the prototype. It has plastic keys with copper tape wrapped round them. The breath sensor's wire is too long and is just flapping around at the top. The front and left of the sax, pretty much the same. The back view, showing the right thumb hook and the left thumb octave button. It's kind of a central pad with copper contacts above and below. The idea is you can move your thumb up or down to touch the contact to go an octave up or down.

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.

Top of the back of the sax. The thumb rest now has two touch pads sticking out the right side, easily reachable with the thumb. The bottom of the rear of the sax. It's got three buttons labelled "transpose", "cal buttons" and "cal breath".

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.

@gbrnt I'm really impressed with your creativity and the process you are following. Seriously, I follow your progress with enthusiasm.

@ekaitz_zarraga Thanks! I'm glad that sharing this is worth it. Hopefully once the project is done someone will feel like making their own!

@gbrnt You are very inspiring. Thanks to your work on the trackball I researched a lot and have almost all what I need (but the fucking pixart sensors) for making my own from scratch.
I had the idea before watching you, but you made me keep it up and gave me a lot of good info. This thing with the saxophone it's just crazy, if I were a musician (which I'm not, at all) i'd probably try to mimic your process somehow.

@ekaitz_zarraga Thank you, that's awesome! It would be great to see the progress you make on your trackball

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!

The parts of the breath sensor - sensor block at the bottom, membrane in the middle, membrane clamp and mouthpiece at the top. The membrane is placed onto the sensor block, held down and flattened by the membrane clamp, then locked in place by screwing the mouthpiece down. Testing the new mouthpiece by connecting it up without removing the old one New breath sensor mounted on top of the electro-sax with fancy matte black gaffer tape

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

https://gitlab.com/gbrnt/electro-sax/-/blob/main/electronics/electro-sax.pdf

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.

2D and 3D sketches of two ways of putting two buttons next to a thumbrest. One has them with a pivot in between and looks a bit awkward, the other has them on separate levers. Two 3D printed prototypes of the buttons. The first (left) is smaller and the buttons turned out to be too small. The second is wider and gives more space for you to press the buttons with your thumb, without accidentally pressing both.

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.

3D printed thumbrest mounted to cardboard sax prototype, with two L-shaped buttons visible.