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.
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!
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?
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.soin
/etc/pam.d/sueverything started working as expected.
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.
Oh, I just came across the ArduinoFFT and ArduinoFHT libraries, and they have a Pd patch example for a spectrum display! But my question still remains... Maybe I should just create a bank of osc~ of the corresponding bin frequencies?
Perhaps this post would do better also in a more general forum, but I have a project coming up where I'd like to use Digispark Arduinos to analyze audio signals then send the FFT info wirelessly to Pure Data. I haven't gotten the equipment to futz with yet, but my question is this:
Is it in principle possible to taken a serial stream of data representing FFT bin amplitudes, and then get them into rifft~ for resynthesis? What's involved here? Some sort of status/frame bit, maybe? Some other object maybe an external other than rifft~? Maybe somebody's already done this?
Thanks so much!
On Pd-extended 0.43.4, both on Snow Leopard (10.6.8) and the same system (late 2008 15" MacBook Pro) upgraded to Mavericks (10.9), I can no longer click and drag objects! I can still click and drag to select objects, but I must use Shift+arrows to move them.
Thoughts? I just tried an external mouse, as well as turning of tapping and multi-gestures on my trackpad. No dice.
Hi all! I'm a long-time Pd user, but now I'm not-so-gingerly dipping my toe into the lunacy that is GEM.
I've attached what I hope is an exciting and useful patch. Through a lot of trial-and-error, I was able to figure out how to make an arbitrarily-sized grid of circles using a few of ClaudiusMaximus's recursion techniques. I still don't exactly understand what's going on, though, which is one of my main complaints about GEM... it's so opaque as a dataflow language!
Anyway, because I wasn't able to get Gridflow to work on my system, I went about trying to color this grid of geos according to a live video input without it. Miracle of miracles, it somehow works. But, thinking that since I was able to manipulate the color of individual geos, I should be able to do the same thing to their translations and rotations using the same gem chain.
But no. When I tried manipulating the Y-axis rotation of the individual circles (to signify brightness corresponding to the grey output of [pix_data]... viz. skinny side toward the viewer at 0 and face-on at 1) I could not for the life of me get it to make any recognizable sense as a raster. It's detuned, so to speak. I tried throwing all imaginable combinations of [separator] and [t a a] at it at various points, to no avail.
On the upside, the recursive results of such manipulations are incredibly interesting. The patch annotations gives you a few ideas to start.
I imagine somebody with more experience, or who understands OpenGL as a scripted language, might be able to shed some light on this question? Please?
Also, can somebody please explain to me why it is more useful for the x-y-position for [pix_data] to be scaled from 0 to 1 instead of the actual pixel dimensions of the image? I can imagine some reasons why, but it would be much simpler in in many cases to work in pixel addresses, instead of arbitrary floats...
Note: this patch makes use of [nrepeat] which seems to exist only as an abstraction somewhere in Claudius' recursion tutorial.
Hi everybody! Thanks in advance for your help...
I'm trying to build a server to send and receive messages from multiple touch devices using the free app Fantastick due to its support of OpenGL (http://www.pinktwins.com/fantastick/). It was a tossup between this and Control (http://charlie-roberts.com/Control/). Both are excellent and free (which is important, because I don't want guests to my performance/installation to have to make the choice to pay for an app... credit will definitely be given where due, obviously!)
However! Caveats, caveats, caveats. Both apps communicate via UDP. And in order to make a server, I need to be able to associate incoming messages with an IP number, which the mrpeach objects provide (unlike [netreceive]).
The problem is, however, that, whereas I can decode incoming OSC messages using [unpackOSC], I am stuck trying to find a method to decode the lists of numbers being sent by Fantastick. [netreceive] does this just fine, but then I lose the IP address! And I can't seem to use both at the same time as a kludge.
So the question seems to be: how can I decode lists of ASCII numbers into lists of symbols and floats???
i know this won't earn me a genius award, but i hadn't been able to find a simple arpeggiator floating around anywhere. i've made far more complex patches, but this is the first one that i can guarantee won't crash your system!
i thought that this was going to be a more trivial task than it turned out to be. in any case, i look forward to any thoughts you may have on my method, since there's surely more than one way to do this.
the patch itself is arp.pd and takes [bang( inputs for a clock. arptest.pd is a simple implementation that will give you commodore64 type sounds! Fast enough and perhaps with a little delay, it's a good way to approximate polyphony with a single voice (to a limit). Slower, and you have automatic Phil Glass.
Of course, the more interesting possibility with this design is the "rand" function, other permutations of which i will be exploring more in future patches.
Hm. Problem has mysteriously solved itself? I'll keep documenting details here if the problem comes back. First theory is that it may (?) be related to the first time Pd is launched after boot, and CoreAudio (i.e., changing the audio device may have somehow affected click-and-drag functionality).
I was able to compile it successfully with the tarball provided in this thread, and the corrected Makefile provided at the end of this thread: http://markmail.org/thread/uc4jkcxxazb6o5sp
(For those following this thread who are even less acquainted with compiling things from source than I am, I had to download the source code for Pd-extended, and alter the Makefile to point to the locations of the required files in the source code.)
It works, but I don't know exactly how to apply it to my scenario. I understand that it's rendering geos by reading arrays... but I'm not clear how it is that one chooses exactly what kind of geo gets rendered? Other than the triangle / point / whatever messages?
Also, I suggest we move this back to my original posting here: http://puredata.hurleur.com/sujet-8930-manipulating-recursive-grids-geos.