Tonehole Sensor reading?

This forum is for discussing the process of updating the firmware, Please feel free to ask questions about this here, as the process of updating can be a little tricky the first time you do it, and your questions and responses will help others in the future.
Krishkal
Posts: 18
Joined: Thu Feb 29, 2024 4:55 am

Tonehole Sensor reading?

Post by Krishkal »

I'm trying some hacks here for fun. One thing that would be useful is to know the actual sensor readings for the baseline with the calibration in place. Namely, the value of toneholeread[i} for all values of i. Is this possible to get?

If not, what are the typical values of toneholeread for the furthest finger position, to the closest? Do the values increase or decrease as the finger gets closer?

Thanks!
User avatar
admin
Site Admin
Posts: 792
Joined: Tue Mar 26, 2019 5:17 pm
Contact:

Re: Tonehole Sensor reading?

Post by admin »

Good question. The sensor values increase as your fingers get closer. They are in the low single digits with your fingers completely removed and range up to around 200-300 touching the toneholes. They also increase exponentially, so they are much more sensitive when fingers are very close to them. The possible values of the sensors range from 0-1023, but I don't use the full range because it's best to have some overhead for detecting and subtracting ambient infrared light when playing outside.

Without the calibration added, the baseline readings (no fingers nearby) are slightly higher-- I believe in the range of 10-15. That is because the enclosure itself reflects a bit of light back onto the sensors. There's also usually a bit of ambient infrared light that isn't completely removed by the sampling algorithm, and the baseline calibration helps with that.

If you want to see the tonehole readings readings you can paste this into the loop:

Code: Select all

            for (byte i = 0; i < 9; i++) {
                Serial.println(toneholeRead[i]);
            }
            Serial.println("");
            
It's probably easiest to put it in the loop somewhere that doesn't repeat very frequently, like around line 675 where it sends pitchbend data every 9 ms.
Andrew Mowry
info@warbl.xyz
Krishkal
Posts: 18
Joined: Thu Feb 29, 2024 4:55 am

Re: Tonehole Sensor reading?

Post by Krishkal »

Thanks, Andrew! That is quite useful.

What I am doing is mounting the Warbl inside another tube (with holes at appropriate places) to physically emulate another instrument. This puts ~10mm distance from the Warbl to the outer hole. I can easily calibrate this out, so I can get reliable on/off signals. However, the pitchbend values are totally incorrect. I am trying to figure out where to patch the code to say "normal finger placement is already 10mm out, so pitch bend is anything over that value".

Any thoughts on that? Thanks!
User avatar
admin
Site Admin
Posts: 792
Joined: Tue Mar 26, 2019 5:17 pm
Contact:

Re: Tonehole Sensor reading?

Post by admin »

Unfortunately, the sensors are only able to detect your fingers around 1 cm away, so if you're adding another enclosure around the WARBL I don't think you'll be able to get any useful readings from them. When designing the WARBL I tried to make it so that your fingers are as close to the sensors as possible.
Andrew Mowry
info@warbl.xyz
Krishkal
Posts: 18
Joined: Thu Feb 29, 2024 4:55 am

Re: Tonehole Sensor reading?

Post by Krishkal »

OK, I'm a bit confused by that answer. The sensors are able to detect open/close just fine even with the outer tube in place. If I set the Vibrato/Slide setting to "No Pitch bend", it is totally playable. However, when I turn the pitchbend on (e.g., slide and vibrato), it is always reporting a pitch bend value (even when my finger is right on the outer hole). I was hoping that there was some "offset" that I could subtract out, which says the new minimum finger distance is higher than normal, and have it report zero pitch bend when the finger is that far.

Is there something I can try even experimentally? I know this is outside of the design parameters of the Warbl, but this is a platform to have fun with right? :)
User avatar
admin
Site Admin
Posts: 792
Joined: Tue Mar 26, 2019 5:17 pm
Contact:

Re: Tonehole Sensor reading?

Post by admin »

Interesting-- I want to make sure I understand correctly. Are you saying that you've recalibrated the sensors so that they "light up" in blue in the Config Tool but they are applying a pitchbend value even when fully covered and illuminated in blue? As far as I'm aware, if a hole is registered as being fully covered (shown in blue) then the pitchbend should be turned off for that hole. I didn't think it was possible for both to occur. Pitchbend should automatically occur in the range between where your fingers are first detected and the calibration point where the holes are fully covered. I may be misunderstanding what you are saying?

I suspect that even though you are able to have the holes detected as being covered when your fingers are that far (~1 cm) from the tone holes, pitchbend won't work well (or at all) because the sensors would need to detect your fingers even farther away (say 15 or 20 mm), and I don't think that's going to work well. If you read the sensor values as I described above when your fingers are covering the holes on your new enclosure, I would think that the values would already be very low, so there won't be much additional overhead for adding in pitchbend.
Andrew Mowry
info@warbl.xyz
Krishkal
Posts: 18
Joined: Thu Feb 29, 2024 4:55 am

Re: Tonehole Sensor reading?

Post by Krishkal »

Yes, close to what you said. Let me elaborate.

I can calibrate out to get a solid blue light when covered and no light when not covered. That part is rock solid.

If I cover ALL 7 holes, NO pitchbend is sent. Then, as I start uncovering each hole from the bottom most one, the note has a -2.8 or so pitchbend with each one of them. Finally, if I just cover the second hole ("middle C fingering"), then no pitchbend is sent!

As I look at the code, it appears that the pitchbend is dependent on the next lower note being partially covered. I believe the problem is that there is some residual signal from that lower hole because of the reflections from the outer tubing (which is what I calibrate out for the hole covering). That residual coverage, which is only used for pitchbend sensing, is not being calibrated out by the calibration of the lower hole. Does this make sense?
User avatar
admin
Site Admin
Posts: 792
Joined: Tue Mar 26, 2019 5:17 pm
Contact:

Re: Tonehole Sensor reading?

Post by admin »

Okay, yes-- it does sound like the holes are being "seen" as partially covered even when they are totally uncovered. I think this has to do with the senseDistance variable, and I just noticed that my notes in the code for that variable say: "Needs to be higher than the baseline sensor readings, otherwise vibrato will be turned on erroneously." I suspect that your baseline readings are unusually high because of your tube reflecting light back, so they are high than the senseDistance ("Finger-sensing distance").

If you lower the "Finger-sensing distance" in the Configuration Tool, does that have any effect? It's possible that you'll find that it prevents the pitchbend from being turned on erroneously but also limits the distance at which your fingers are sensed so much that pitchbend becomes unusable.

If you could print out the values with the sensors covered and totally uncovered then we could plug those back into the pitchbend algorithms and get a better idea of what's going on.
Andrew Mowry
info@warbl.xyz
Krishkal
Posts: 18
Joined: Thu Feb 29, 2024 4:55 am

Re: Tonehole Sensor reading?

Post by Krishkal »

Yes, the distance sensor setting does help some. But, my tube is not uniform (it has a conical bore) so it does not work for all holes.

I enabled the printing (that code was already there, commented out, so I just uncommented it). However, I am not able to see the outputs in the IDE output window. Do I have to do something to enable that?
User avatar
admin
Site Admin
Posts: 792
Joined: Tue Mar 26, 2019 5:17 pm
Contact:

Re: Tonehole Sensor reading?

Post by admin »

If you’ve disabled the CDC class as described on the GitHub site you’ll have to enable that again in order to print to the serial monitor. Here’s the info about that:

https://github.com/amowry/warbl?tab=rea ... onal-notes

In other words, you’ll need to recomment this line in the USBDesc.h file:

Code: Select all

#define CDC_DISABLED

If the CDC class is enabled you should be able to select the WARBL port in the IDE and then open the serial monitor. At that point it should start displaying the sensor values.
Andrew Mowry
info@warbl.xyz
Post Reply