USB MIDI host and adding potentiometers


#1

Hello, I’ve been using Pd for quite some time (7 years) on a regular basis, I’ve created number of sound generators/synths/midi sequencers and such, that is why I’m interested in pisound, because it would allow me to fit all of those in my pocket :heart_eyes: without a need for computer and external midi/audio interface.
I’ve got couple of noobish questions as I have not used RPi before (the closes thing I’ve got is Axoloti, but it’s a different beast):

  • Would it be able to work like a USB MIDI host for USB based midi controllers? (I reckon yes, but It may require to use keyboard+mouse+screen combo to set the controller in the Pd MIDI setting after each RPi startup?)
  • How will be the latency if I would try to use it to host simple synthesizer in Pd? (I’m aware that Pd itself is not well optimised for this purpose, using it like this on an average specs Win based computer with ASIO is beyond acceptable range unfortunately :disappointed:)
  • How hard would it be to add simple potentiometers to it (e.g. to control parameters inside Pd)? I’ve did some digging and it seems that it would require adding some kind of board with ADC (connected to the unused pins of the RPi header), pots and some codding, am I thinking right? (there is space on the pisound board, maybe 4 potentiometers could be included in future revision? :smiley:)

I’m looking forward to get one of those when they crowdfunding campaign will happen :slight_smile:


#2

Hey,

You can connect MIDI devices to Raspberry Pi’s 4 USB B connectors (and probably even more through externally powered USB hubs), and they will work out of the box for receiving as well as sending MIDI data. Additionally, pisound has MIDI DIN5 input and output ports which you can use in the same way.

The latency when playing around with synthesizers, samplers and MIDI keyboards is definitely playable, we didn’t have complaints from the users who tested the hardware. :slight_smile:

For potentiometers - you can easily use MIDI CC messages sent by connected MIDI controllers with knobs (via USB or MIDI DIN5 port) in your Pd patches. So there’s no actual need for soldering your own potentiometers.

A pretty cool feature of the board is that it has a button on it. If pressed once, it launches Pd and loads main.pd from any connected USB storage devices, starts dsp and sets up all the currently connected MIDI devices to be usable in Pd. Double clicking the button will terminate Pd and safely unmount the usb storage device, so you can swap it to something else.

I hope that answers your questions :slight_smile:


#3

Awesome! Thank you for the reply :relaxed:
I was thing about using the potentiometers when utilising pisoun as an audio effect or with simple MIDI USB keyboard (without knobs) so I won’t have to carry another MIDI controller. Maybe I should just get a new controller with keys and knobs (USB powered should be fine when powering RPi from pisound, right?) :thinking:
Then I guess I should start looking for RPi soon, so I will have something to connect it to. :slight_smile:
Any info when the crowdfunding will start?


#4

Yes, with pisound on top of RPI, you can still power some USB devices from the RPi’s USB ports, as long as there’s enough power being supplied. The ‘official’ RPi power supply is providing 2.5A of current, which is a lot. Most of USB devices are designed to consume up to 500mA of current, if they require more - they provide external power supply options.

You could actually make some DIY MIDI controller using potentiometers, which connects via USB or the MIDI port. We did develop a USB MIDI driver for Arduino boards with atmega32u4 main processor, such as Teensy 2.0 or SparkFun Pro Micro.

The usbmidi driver is available here: https://github.com/BlokasLabs/usbmidi

Using that you’d just have to add code for reading of potentiometers, and generating MIDI CC messages via the usbmidi driver.

You can see how usbmidi library can be used in an arduino sketch here: https://github.com/BlokasLabs/BuildingBlocks/blob/master/arduino/libraries/BuildingBlocks/examples/MidiPots/MidiPots.ino

All lines with ‘USBMIDI’ in them would be of interest to you. The sendCC function is the one that sends MIDI controller messages over USB. The rest of the lines have to do with interfacing with another chip over SPI which you can ignore, you’d replace that part with direct reading of values of the potentiometers.

For doing DIN5 port MIDI implementation, you’d use the ‘Serial’ library and tx/rx pins.


#5

@maceq687, you might be interested in Adding more MIDI controls to pisound :wink: