Midi controller not seen by Pd, but seen by system. Rpi3. Pd .49
I think what I'm going to attempt is to create a midi client with Jack.
Is there a way to do that in Terminal? Kind of convoluted, but when I boot up maybe I can make a midi connection between my controller and alsa midi, and between alsa midi and Jack.
Since I can save the midi connection between Jack and Pd that might work. I didn't want to use Jack because I can't really figure it out, but maybe I'll keep trying.
I finally figured out how to open it in terminal, but typing "jackd" I having a hard time finding a list of commands for jack though.
MobMuPlat OSC-to-MIDI Remote Control, spec. for PD, Guitarix, and Rakarrack and other guitar effects apps
It's always funny to me how working on one PD project results in fruit that might also prove useful.
Currently, working on a broader project, but this part (at least) (I think) is ready for distribution.
Background: I Really hate leaving the side of my guitar (for example to click a mouse or tweak a setting) when I am playing. So designed this mmp app so that I can attach (with funtack, ex.) my handheld to my guitar and control my settings from there or perhaps even as I play. Like so:
[Aside: the broader project also includes (on the front-side of the app) controls driven by the handheld's tilt, as well as, the adc~ pitch, env~, and distance of the pitch from a "center". But that part has to wait (though the code is all inside the mmp_osc2midi_rc.pd patch just disconnected/does not use the cpu).]
SETUP (linux is what I know, so other OSes may work just can't/haven't tested them):
JACK
Pure Data
a2jmidid - JACK MIDI daemon for ALSA MIDI (in the Ubuntu at least repos)
guitarix a/o rakarrack, or other midi-driven effects apps (such as the included set of 30 pd effects(see below))
PIECES:
The mmp_osc2midi_rc.zip (extract(android)/install(ios) to MobMuPlat directory)
The osc2midi_bridge.zip (to be run on the "pd receiver") and includes the osc2midi_bridge.pd, help file, and a set of 30 mmp-ready-(mono) effects (in the ./effs directory) that can be used if PD is to be used as the receiver. (They are standardized to include 3 inlets: left=inlet~, center=[0 $1(, [1 $1(, [2 $1( messages sent to 3 parameters on the effect, and right=[switch~] and 1 outlet~ and a demo guitarix "bank" file called "MIDITEST.gx" (which includes 2 presets/programs and set midi values (0-8) to test. Just add the file to the guitarix config "banks" folder).
Instructions:
- Start Jack;
- In Pure Data, open the osc2midi_bridge-help.pd file; toggle "listen" on; and set MEDIA to "ALSA-MIDI" (the additional pieces are just examples of receiving the midi values);
- In Jack>ALSA: Connect Read:MIDI to Write:PD & Read:PD to Write:Midi;
- From the command line execute "a2j_control start" (no quotes);
- Start (ex.) guitarix;
- In Jack>Midi connect a2j:Pure Data(capture) to (ex) gx_head_amp:midi_in_1.
Note/Alert/etc. For a machine to receive OSC messages the recipient-computer's firewall must (I believe) be turned off.
GUI:
The GUI has 3 pages that look (basically) as follows (with the subsequent 2 pages having only the 3 knobs and 3 buttons).
The buttons trigger text entry boxes which allow you to enter numbers (0-127) representing:
PGM: the number sent to (midi) [pgm]
and
(the buttons beside the knobs) the midi value, i.e [ctrl] (0-127), each knob is to be sent to (all on channel=0). (The resulting number of which are all written to the label to the left.)
For example:
Results in:
You can now to do 1 of 2 things:
Set the mmp-knobs to whatever midi values you have set in guitarix
or
Set the guitarix midi values (mousewheel click on a control) to one of the mmp preset 0-8 midi values.
WOW!!!
That took a helluva a lot of writing (and reading) but I hope you can both see the value and make use of this bit of technology.
As I said before,
I look forward to being able to fine tune my sound ALL while my hands and I are BOTH still at my guitar and not bend over, move, etc. etc. etc. to get the sound I want.
Peace, Love, and Ever-Lasting Good Cheer.
If you made it this far , Thanks for Listening.
Sincerely and Optimistically,
Scott
p.s. ask whatever you want regarding setup, how to use, points-of-clarification, etc. I am more than happy to help.
"Out of Love comes Joy"
Ubuntu - Browsers and Puredata wont share audio output device. [SOLVED]
@dxk said:
So I've done what you said and the exact same errors happen with PD. Jack works fine, my microphone works, I can use skype etc. But I don't know why PD gives me these errors
Then i got this error
JACK: unable to connect to JACK server. Is JACK running?
JACK: server returned status 17
(This happens when i run pd as sudo).
But if i run it without sudo i get
JACKerror: Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
JACKerror: JackClient::AcquireSelfRealTime error
Ubuntu - Browsers and Puredata wont share audio output device. [SOLVED]
I have tried jack https://puredata.info/docs/JackRoutingMultichannelAndBrowserAudio/
Then i got this error
JACK: unable to connect to JACK server. Is JACK running?
JACK: server returned status 17
(This happens when i run pd as sudo).
But if i run it without sudo i get
JACKerror: Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
JACKerror: JackClient::AcquireSelfRealTime error
Both ways i cant use jack with pd. HOWEVER jack works fine with youtube!
JACK: unable to connect to JACK server. Is JACK running? JACK: server returned status 17
Hi I followed this tutorial however I keep getting this message
JACK: unable to connect to JACK server. Is JACK running?
JACK: server returned status 17
However, I selected in the settings the sound driver as jack and also I can hear sound so the server is running.
Ubuntu - Browsers and Puredata wont share audio output device. [SOLVED]
Linux and audio can get relatively hairy,.. basically if you try to use ALSA directly with Pd, you can't use anything else that has sound. That's where intermediary layers like PulseAudio and JACK come into play that talk to ALSA, PulseAudio is good for general use, JACK is good for lower-latency stuff like you would want with Pd so use JACK with Pd and then you want to download "sinks" where everything else can use PulseAudio and then be connected to JACK, I have this info saved somewhere...
Edit: Well essentially you want to sudo apt install both qjackctl (which I think installs jack also?) and pulseaudio-module-jack. Then in qjackctl: under setup > options: "pulseaudio -k" on startup, "pacmd load-module module-jack-source channels=2; pacmd load-module module-jack-sink channels=2;" after startup, then "pulseaudio -k" after shutdown. Basically, kill the pulseaudio process when you startup and after you shutdown the JACK server. You might have to tinker with /etc/pulse/default.pa,.. can't remember if I did on my current installation but we'll get to that if need be...
Easiest way to connect a MIDI keyboard to PD-l2ORK on Ubuntu 16.04
Pardon If I'm behind the curve here (I'm still using L2ork v1 most of the time) but last I checked Jack Midi was not an available option in any version of Pd. You can connect through the jack midi patcher in Qjackctl (the second tab in the connections dialogue box after audio) but only if you have the jack/alsa midi bridge running. That just lets you patch jack midi only apps through to alsa midi only apps and vise-versa. I personally always use the third tab (confusingly only labeled "alsa" when it should be "alsa midi") because jack midi presently has no way to handle the larger sysex messages I deal with and blocks them by default.
Anyway the point is that If you are using any Pd variant you are always using either Alsa midi or OSS midi (actually the OSS is just an alsa-based simulator now so you're really always using alsa, but I digress). There are a few other graphical audio/midi patcher programs such as Patchage or the similar Catia program from the KXStudio package but AFAIK they all require you to set up the connections manually at least once.
However, all of those programs allow you to save your patching setup for instant automatic recall the next time you need it. In Qjackctl this is done from the "Patchbay" dialogue box. I haven't used it in awhile but if you mess with it you'll find a way to save the current set of connections. Qjackctl is pretty messy and counter-intuitive thou so for beginners you might want to have a look at the other options mentioned above.
AFAIK there's no auto-midi patching options available. I know they tried implementing something like that in Pd some time ago but they disabled it because it ended up causing more problems than it solved. There's info about that buried in the Pd list somewhere....
sampling rate impacting sound
Not entirely sure about the math of the whole thing, but what I know is that when you use Jack as your audio server, you don't change your audio setting in Pd, but only in Jack.
Check this, start Jack (in the image you posted, the sampling rate is at 48KHz), then start Pd and open its audio settings. Most likely it will read a 44.1KHz sampling rate. Don't change that, open a new patch and put a [samplerate~] connected to a [print]. Bang it and see what it prints. It should print 48000 and NOT 44100. This is because Jack's sampling rate is at 48000 and that's the sampling rate Pd is using, even though its settings read 44100.
What happens, I guess, is that when you change Pd's audio settings you force a different sampling rate between the client (Pd) and the server (Jack), which causes this frequency difference, which probably occurs due to two different samplings of the same frequency.
The only thing you should probably set in Pd's audio settings (if I'm not mistaken), is the number of channels of your sound card.
jack_midi2pd_2sys_connector_sv: (Jack) Midi_out to pd|sys_playback switcher
Mark this one up as: Creative Ways to Use the [Shell] Object
jack_midi2pd_2sys_connector-help_sv.pd
jack_midi2pd_2sys_connector_sv.pd
{image of code at the bottom of this post}
Synopsis:
By clicking "init" then selecting your left- and right- ins and outs, you can then switch between your midi (or for that matter any jack-in) out-ing to pd_in or system_playback. So from one perspective it is a jack-bypass/router.
Copy from the help file:
This abs is designed to empower the user to switch (in a sense a sort of jack router/bypass) between having a connection, in my case, the virtual midi synthesizer "amsynth", running into pd_in to instead running into system:playback.;
The benefit is that (using the shell object + jack_lsp) the rerouting is done in a single click (which certainly gets one to thinking).
The two inlets are init which writes a file to /tmp which it then reads to populate the connector names and the other inlet is the switch itself.
Steps:
start jack and any and all apps you may want to run through the abs;
then click "init" this writes two files, one for ins and the other for outs;
select from the radios (which populate the symbols on the right);
and
then you can switch between the two connections using the vradio on the top-right.
Note: if you are using QJackCtl or other jack-guis you may need to refresh the connection page to ee the result. -svanya
#end help file
As I say, more than anything (since my system just points to shell scripts to do this), I just wanted to show some novel/powerful things we can do with the [shell] object.
Perhaps, you may find a use for it (or its ideas).
Happy pd-ing
-svanya
p.s. feel obliged to add: in my case, I am using this with my latest and current project (a mobmuplat front-end to go on the body of my guitar (for me to use as I play) which will allow me to run my guitar pedals, a looper, amsynth and all of its controls, as well as the audio-bus controlling the mixing of all of those) to reroute my synth to and from going thru my pedal-rack. So in one case its just a synth ("amsynth" to be exact) and in the other case it is a synth-running-thru-my-pedal-rack.
Pure Data / Raspberry Pi / Realtime Audio / Permissions
THE GOAL:
I want my Raspberry Pi 2 to automatically start up the Jack server with realtime scheduling, and subsequently start Pure Data with realtime scheduling, load a patch &c. without any user intervention from a login shell.
As a performance artist working primarily with psychodrama (the technology is definitely NOT the important part here), fiddling around at a terminal right before or during a performance is kind of... psychically inconvenient. I need a box that I can plug in, give the audio output to the sound guy, and be ready to go.
PREREQUISITES:
I use Raspbian with a Linux kernel compiled with realtime goodness. I have hand-compiled Jack2 and Pure Data with realtime support in order to take advantage of this. Running a process with realtime priority requires the proper PAM directives set in /etc/security/limits.conf and related places, but that is beyond the scope of this little write-up.
Also somewhat relevant: I use a M-Audio MobilePre USB soundcard (sounds pretty awful by today's standards, but it's an extremely USEFUL box and sounds good enough for the work I do). For full-duplex sound, this requires the RasPi's USB to be set to single speed. In this configuration, I can get just under 2.9ms latency with good CPU overhead for Pure Data to run a few of my 64-voice wavetable and delay line granulators. Yeah!
THE PROBLEM:
Purely by happenstance, I had given the jackd command in my startup script the option “-s” which allows the server to ignore overruns and so on. So things seemed to be working as expected, but I noticed a lot more glitches than when I manually started up Jack and Pd from the terminal without the “-s” option. Upon removing it from my startup script, everything failed! WAH.
So I started piping STDERR and STDOUT to text files so I could read what either Jack or Pd were complaining about. As it turns out, Jack was unable to start with realtime priority due to a permissions problem. (I assume this is one of the things the “-s” options allows jackd to ignore, and thus start up with non-realtime priority. Problem is that Pure Data can’t connect to a non-realtime Jack server when its “-rt” option specified.)
Now, I had already been through the whole rigamarole of setting proper memory and priority limits for the “audio” group, to which the user “pi” belongs. So I thought, okay, I have to execute these commands as “pi”, and while simulating a login shell because the security limits in question are only set during login.
So I did this:
su -l pi -c "/usr/local/bin/jackd -R -dalsa -dhw:1,0 -p128 -n3 -r44100 -S >> /home/pi/jackd.log 2>&1 &"
This says “login as user ‘pi’ and then run the jackd command with these options, piping the outputs to this log file and run it in the background”. Well, I still got all the same errors about not being able to set realtime priority. WHYYYYYYYYY?
THE SOLUTION:
I hunted and hunted and hunted on a Very Popular Search Engine til I decided to try searching “security limits not loaded with su -l” and found this.
(Makes me think of that Talking Heads lyric, “Isn’t it weird / Looks too obscure to me”.)
So by uncommenting the line # session required pam_limits.so
in /etc/pam.d/su
everything started working as expected.
CONCLUSION:
I now know a LOT MORE about PAM and how important it is to keep in mind when and in what order scripts and other little subsystems are executed; but also that sometimes the problem is EXTREMELY OBSCURE and is to be found in some seemingly far-flung config file.
I hope this helps anybody out there working with Pure Data and the RasPi. The second generation board really packs quite a punch and can run several hundred audio grains (run by vline~ and enveloped by vline~ and cos~) simultaneously without a problem. And I'm pretty sure this is just using ONE of the 4 cores!
I'm by no means an expert Linux sysadmin, so if you have any other suggestions or corrections, please let me know! I wouldn't have been able to get this far without all the generous and helpful writeups everybody else has contributed, both within the RasPi and Pure Data communities. If you have any questions about anything I glossed over here, I'll do my best to answer them.