Rien Heuver posted Dec 4 '17, 21:28:
In short: is there a way to write my own (python or otherwise) program that can send midi signals to samplerbox?
In long: I'm working on building a full sized electrical marimba, which is a rare instrument much like the malletKAT (just google it ;-)), but clearly I want it way cheaper. So the idea is to build the entire construction, use piezo-elements for velocity detection, wire all piezos (through multiplexers) to an ADC and hook that up to a raspberry pi. Then write a python program that turns the piezo-signals into sound.
The best solution to that last part now seems to be using samplerbox. It's quite featured, I can build the display in my casing and everything else just makes sense too. So how would I go about instructing samplerbox with the right commands from my program? Greatly looking forward to any help, since all is appreciated!
Rien Heuver posted Dec 4 '17, 21:50:
Alright, so I continued researching in the meantime and found that rtmidi (which samplerbox uses) can do virtual midi, if you will. Somehow this doesn't seem like the right way to go, since I'm now creating a virtual midi device to send midi signals to a midi server which then plays the notes. I´d rather import samplerbox and play the notes, if that's possible. Any help is still welcome of course! In the meantime, this is my little test script that got the virtualization working:
import rtmidi_python as rtmidi
from time import sleep
midi_out = rtmidi.MidiOut()
midi_out.send_message([0x90, 48, 100])
midi_out.send_message([0x80, 48, 100])
Rien Heuver posted Dec 5 '17, 20:19:
Today I have been experimenting some more: this time I put the samplerbox-image on a raspi, booted the raspi, connected my regular earphones to the raspi (no dac), ssh'd to the raspi and tried the script above. When listing the midi out ports available, I only get "Midi Through:0". I got RtMidi Input Client a few times (and then it would also play a note), but now it seems gone. Am I going about this the wrong way or is there some other reason why this virtual midi program would not work?
After rebooting it could work again for a few times, but then the rtmidi-out seems to crash or something, because it "disappears" again.
Ted posted Dec 25 '17, 11:54:
Well, the samplerbox service basically scans for any new midi devices. (Ignoring the midi through, because it's designed to be at the end of the bus. You could get rid of the through port with no issue.) I'm guessing if you get lucky and samplerbox scans for new midi ports while your test script has an output port open (probably during the call to sleep). Not sure what is going on though. For example, is the snd_virmidi module loaded? I'm assuming it is, because otherwise open_port(2) would try to open the default ALSA sequencer which would be nonexistent.
But back up a little there, did you say you are building an electric marimba??? That sounds awesome but impossibly difficult. Like is it an actual acoustic marimba that also has piezo sensors inside every single pipe? How are you muxing the analog output then feeding it into the ADC, unless I'm misunderstanding something here? What is this ADC's output format, I'm having a hard time imagining what your vision and/or progress for this project is... Unless it's a drum pad shaped like a marimba, in which case you'd still have trouble with mistriggerring notes on adjacent sensors without decoupling the bars from the cord somehow.
I'm very intrigued anyhow, enjoy your holidays and give us an update on how its going!
Thurstan posted Jan 6, 10:45:
Rien, Nice idea!
But if i may, i think a better approach for you is to develop the marimba as a standalone 'midi controller', ..then hook a midi cable to the SamplerBox for your sounds (or to any midi device you wish).
The raspberry pi is not best suited to capture the data from the amount of sensors you will have, things like issues with GPIO Interrupts.
I would suggest another microprocessor, mabye a Teensy 3.2, that can also act like a usb midi device so you dont even have to add midi ports, just plug usb straight into SampleBox and voila.
..right, off to buy a pi (and register on this forum)