New Hardware and left hand setup progress

With the BLE MIDI transmission working rather well, it was decided to move on to finish the programming work of the project. As stated in the goals set for the third semester, the left hand setup will be complemented by an additional threshold-setting knob which enables flexible threshold settings while the right hand setup will have a reset/calibration button added to it. Thus, a potentiometer with matching knob and a button were purchased at Neuhold Elektronik Graz.

As adding the threshold button seemed to be the easier thing to do, it was decided to start with the additions to the left hand setup. Firstly, the basics functions of a potentiometer were researched and a simple code to test the potentiometer and its functionality was written. The potentiometer gives out analog values ranging from 0 to 4095 if operated with 3.3 volts. These values were then divided into nine equal ranges that were matched with nine fret numbers with range 1 going from 0 to 455 for the 1st fret for example. These calculations were then put into code which was also successfully tested. Subsequently, the additional code was added to the main ToF sensor code.

Then another challenge arose: the ESP32 only has one 3.3 Volt pin. However, the ToF sensor and the potentiometer need electricity to work. The first solution found was to connect everything via a breadboard which makes it possible to split the output of the 3.3 Volt pin. This solution works but is not very sleek and thus, not suitable for the final product. Here, some other way will have to be found. Nevertheless, with sensor and potentiometer supplied with power, the code was tested.

Here, an old problem arose. The values fluctuated quite a bit so it was decided to revisit the idea of implementing a code that switches states instead of sending continuous values.

In other words, it was required that if the hand reaches above the set threshold, a MIDI message to turn an effect ON is sent just ONCE and if the hand reaches below the set threshold, a MIDI message to turn the effect OFF is sent just ONCE. If the hand moves but stays above the threshold, no MIDI message is to be sent and if the hand moves but stays under the threshold, no MIDI message is to be sent either.

To make such a code possible, not only the currently incoming fret number had to be known but also the previous fret number so both fret numbers could be compared to each other.

In order to attain the basic logical structure before actually writing the code, four possibilities were discerned:

Prerequisite: Effect is usually ON

Current fret >= threshold && previous fret >= threshold -> do nothing (leave ON)

Current fret >= threshold && previous fret < threshold -> send ON once (turn ON)

Current fret < threshold && previous fret >= threshold -> send OFF once (turn OFF)

Current fret < threshold && previous fret < threshold -> do nothing (leave OFF)

This logical structure was then put into code, but it failed to work at first. As it was hard to debug the code using MIDI messages, it was decided to resort to the old serial monitor and print everything out. Thus, the influence of different conditional operators on the actual output could be monitored very accurately and the code was gradually increased in complexity. Finally, the logical structure mentioned above worked in conjuncture with serial printing. It was then changed to work via MIDI messages, and it also worked successfully. While the code was tested in conjuncture with Cubase, it was not yet tested while actually playing guitar.

Leave a Reply

Your email address will not be published. Required fields are marked *