A digital instrument with all the flare of a trombone, with the power and flexibility of an MIDI instrument
Finally got round to adding the Ping sensor to my board.
Did some work to the code to incorporate the NewPing library to handle my ping sensor, uploaded the code and got an LCD full of gibberish.
I'm assuming it is power related (The rest of the script runs fine) soon will have a look at rewiring the breadboard tomorrow.
On a lighter note the Arduino has been successfully talking to the python script via serial and sending data, and the python script has been playing according beeps.
Next step is to add some debouncing to the arduino code buttons, and then focus on using the Ping data and range value to determine what note to send to the Python script.
I would like to use an air pressure sensor to trigger when notes are to be played; it keeps the hands free to use the pitching buttons and also is in keeping with the trombone.
The pressure sensor will most likely be used in an on/off sense and not to dictate the velocity of the notes.
Coding the Arduino will follow a pattern of:
If air pressure sensor returns a value indicative of air being put into it, then:
read slide position and range value, and send the corresponding note to the Pi.
I will be ordering some of these on pay day to give them a try. They look small enough to be inserted inside a mouthpiece so that's a brucey bonus:
This is the middle Range of the scale, and octaves can be achieved by adding or subtracting 12; C3 would be 48, and C5 would be 72.
I have used the MIDI Values to map out what notes an actual trombone can play on its positions. This way the final product will be very playable for trombone players.
|8: Top Bb||70||69||68||67||66||65||64|
For the final Slide mechanism I will take a total of whatever potentiometer/s values and divide it by 7 to determine the slide position and the pitching value (controlled by the PitchUp/PitchDown buttons) to then play the correct value.
The arduino code will all be triggered by either a momentary button or an air sensor to trigger playback; while the play button is pressed the arduino will then pass the serial data to the Pi.
Tonight I have made a start on developing a sketch for the Arduino.
The Arduino has two main functions in this project; to read a variety of buttons and sensors, and to send a command to the Pi based on its readings.
For testing and prototyping I have decided to write a simple menu for the LCD button shield that allows me to manually select data to send.
At present the left and right buttons cycle through the chromatic note scale, and the up/down buttons step the range number up and down. The select button outputs both the note and range to serial.
The arduino is also running a function that reads both potentiometer readings and combine them. This function does not appear on screen just yet, but it will certainly be used at the core of any slide processing that will determine the note being played.
Next step is to develop the python scripts some more and add a serial handle, then I will be able to transfer development from my Tinkerboard 👌
Normally it takes an age for me to formulate and out a plan of action down for a project, however this one has fallen into place rather quickly!
Today I have put in place my prototyping board:
An Asus Tinkerboard w/Justboom Amp/DAC hat
Arduino Mega w/lcdshield (plus a wifi shield underneath. No plans on using it in this project).
This little setup will allow me to test everything from getting data from the (currently hypothetical) slide mechanism using the pots, start work on formulating the serial data to be sent to the Pi from the Arduino for notes, work on using the lcdshield and buttons as a method of menu control to the Pi/Tinkerboard, and also work on how the Pi will handle that data.
I also had a little play with Fluidsynth on my laptop (an aged beast running the Pi x86 Desktop OS) and it took me ten minutes to get all dependencies installed and notes coming out via python script. Great start so far!!
This is the area that will need the most thought, investigation and research I feel.
7 distinct note positions, with the areas in between still selectable, all in one smooth and easy to use mechanism.
My first thought was to somehow fabricate a >50cm slide potentiometer to mount in the frame.
Second idea would be to use 7 standard slide potentiometers all in a line, and create a mechanism for the bar moved by the player to move the slide pot as it passes.
If pot 1 is reading 0 we know the slide is in position 1 and would sound note one on that pitch; any other reading would indicate a pitch bend down in that note (as the slide has been moved out). Once pot 1 hits 1023 we know that the slide has reached position 2 and can start reading pot 2 for the pitch bend value, and so on and so forth.
This second way would take a lot of refinement to get a smooth output from the Arduino but having the range of 7 full potentiometers (compared to the one pot idea) would give a far greater degree of accuracy.
I am going to build my prototyping onto on of these boards:
I have another one which I will load with my Justboom amp/DAC and a Pi, alongside an Arduino Mega with a display shield.
Just a note for myself here, really.
Rather than using combinations of buttons to determine pitch look into using two buttons to allow the player to cycle up and down through the ranges.
Also add momentary buttons to 'Octave up' and 'Octave down' for quick jumps when the range cycling won't be fast enough.
Volume control - use a thumb trigger on the left hand to control note velocity.
Also add a note on/off momentary switch where a mouthpiece could go and use lip/chin to trigger notes on or off, or use a traditional mouthpiece with some kind of air sensor in it.
Also project name:
I may update the name to RaspBone or TinkerBone depending on what board I settle on.
My initial thoughts and research on how to create the software side of this project has brought me to Fluidsynth.
Fluidsynth is a fantastic bit of software with many features, but one feature is exactly what I need; it capable of generating notes from MIDI data using a loaded soundfont. With some work this could carry out exactly what I need the Pi to be doing in this project.
Fluidsynth has no GUI and is operated via command-line. It has a python module on Github too. This is fantastic - I will be able to write my own python scripts and control it exactly the way I like.
The Arduino could even just pass simple commands rather than MIDI data and have the Pi then generate the midi to pass to fluidsynth.
For the hardware there are many options.
My gut feeling is to go for Aluminium extrusion; easy to assemble, and it'll be easy to mount components to it.
Assembly will be rather trombone like, built from two, elongated U-shaped parts.
The first part will be the slide mechanism. Rather than an assembly that moves, there will be a thin bar that will slide inside the extrusion.
Moving this will adjust the a potentiometer of sorts (still undecided on this element).
The second part (not as long as the first shape will join the 1st part at a 90 degree angle, giving that trombone shape.
On the other end of the U shape a bracket will be created to hold a speaker, for on-board output.
A DIN rail will be mounted through centre to allow for an easy and modular electronics section.
The electronics will comprise of:
Battery Pack outputting 8v-24v
Pi/Tinkerboard with Justboom Amp and DAC combo.
The Justboom Amp accepts 8v-24v via it's barrel connector and powers the amp, DAC and Pi from this input.
The speaker connects to the amp hat also (either 4Ohm or 8Ohm. I'm going to be using a car speaker at first).
The Arduino will read any buttons and potentiometer values and use those to send MIDI information via USB to the Pi.
The Pi will be running software to interpret that midi data and turn it into sound using a VST or other virtual instrument software.
Depending on the software I use I may either add an Arduino lcd/button shield to control sounds and settings, or I may use a webserver and change settings via Wi-Fi.