I've been playing a bit with a Csound handpan synth from here and I've used the r_cycle external to make a handpan with my Launchpad (the patch is not very complicated so I didn't try to make it neat, sorry!).
The csound patch maps specific MIDI notes to the synth according to a scale, and the Pd patch lights up the pads so each colored group of pads sends the corresponding MIDI note to CSound:
I'm super happy with it, but the next step is to make it configurable: the csound patch contains many different scales defined with
giNotes = ftgen(0, 0, -<number of notes>, -2, <list of note numbers> ):
; B Kurd ;giNotes = ftgen(0, 0, -10, -2, 47, 54, 55, 57, 59, 61, 62, 64, 66, 69) ; B Golden Arcadia giNotes = ftgen(0, 0, -9, -2, 47, 51, 54, 58, 59, 61, 65, 66, 68)
So instead of editing the CSD file and changing the color mapping of the launchpad when I want to change scale, I would like to send a list/array/table of note numbers from Pd to [csound6~] via a message (and adjust the MIDI notes sent by the launchpad at the same time).
I know basically nothing about Csound, so I've read up and found examples using
invaluewhich seem relatively straightforward to change the value of a single int variable. However I don't really have any idea on how to pass the list/array of scale notes using chnset or invalue, or if there is a better way to do it.
Maybe someone around here has an idea? Thanks for reading so far in any case
@whale-av Hmm thanks, this sounds like I might actually be better off with running parallel pd processes right from a shell script and communicating via netsend (this laptop has only 2 cores, so audio processing is all running in the same patch anyway, and controls+GUI in the other), rather than trying hard to get it working with [pd~] and possibly hit some more undocumented limitations later on...
I guess I'll try a bit more, and let's see where I end up
I think I finally figured it out!
Well, not sure it solves all my problems, but at least here is a limitation of pd~: midi inputs and outputs (obviously)! There were a few of those in one of the libraries called by mybigpatch.pd (r_cycle).
So here is my way around it, in case it might help others:
- In the main patch, capture notein and send
[notein $1 $2 $3(to
- in the pd~ subprocess, capture the incoming in an abstraction ./myfolder/notein.pd:
and replace all instances of
- similarly for noteout, an abstraction ./myfolder/noteout.pd to use in the pd~ subprocess:
and replace all instances of [noteout] with
- in the main patch, replace noteout with [r noteout]:
- and the same thing with ctlin, ctlout, bendin, bendout, midiin, midiout, etc.
And the command line magic trick (that it took me a while to figure out) in order to replace all this easily in all pd files:
$ sed -i 's+\(touchin\|polytouchin\|bendin\|notein\|ctlin\|midiin\|midiout\|noteout\|ctlout\)+'./myfolder/'&+' *.pd, which will prepend any instance of notein & co with
Improvement suggestions are of course welcome.
- In the main patch, capture notein and send
@mtdr2012 Hey, my bug report seems to still be open: https://git.purrdata.net/jwilkes/purr-data/-/issues/672 but maybe you can help solving it over there
I've moved from Purr-data to vanilla a couple of months after that issue so I can't really help anymore, sorry ! I'm focusing less on the UI now, so whenever I need a control for a knob I just use a centered hslider instead.
I've been working for a few months on a patch that got more complicated than I had planned, and I finally decided to split it into subprocesses to avoid audio clicks when UI elements refresh. In the past I've done it with 2 separate pd processed and osc calls between both, but I'd like to try with [pd~] instead (which I've read about bit never actually used for real).
So as a first step I'm just trying to load my whole complicated patch inside a [pd~] subprocess (with DSP on in both of course) using a simple
[pd~ start mybigpatch.pd( | [pd~ -ninsig 8 -noutsig 2]
It works with a simple patch in the same folder, however with the big one, the subprocess starts, loads the libraries, and immediately closes, showing only
pd~: No such file or directoryin the parent process' Pd console window.
I get no more details when adding
-noloadbang(in case it's the patch initiation that failed).
My "big patch" will call many abstractions, initiate arrays, soundfilers and load text files into [text] objects so there are quite a few possibilities for not finding files - however the exact same patch starts perfectly from the same folder. Using the whole path to the patch in [pd~ ( also doesn't help.
Are there any known limitations to what [pd~] can or cannot do compared to the main parent pd process?
The main thing to be careful about IMO is to get the right board to communicate directly over USB (Micro, Leonardo, Teensy, see the documentation), otherwise (Uno, Nano) you will need a serial-MIDI converter software like hairless (with GUI) or ttymidi (command line).
For the LED lighting I took inspiration from my other commercial controllers, and set the arduino's code to light up the LEDs by sending a notein and then it off with a noteoff (if you have multiple colors or blinking mode, you can use different velocities, e.g. 36 1 1 for solid green on button 36 (channel 1), 36 2 1 for blinking green, 36 3 1 for red, etc.
You can also hardcode the LEDs status with the buttons status, but you may loose flexibility (especially when using Pd, but it may be more complicated to use a DAW if you have to set up when to light up the LEDs, not sure).
Now I am looking into building another controller with faders and knobs, and there I'll indeed also need multiplexers, as I believe that the bigger Arduino I could find had ~40pins. You will probably need digital pins for the buttons and LEDs, while potentiometers need analog pins (as far as I could understand so far, but I'm also new to this!).
In any case, regardless of how you initially program the arduino (e.g. only notein/noteout to control the LEDs), you can just decide otherwise later on and reprogram it (just like you would update a commercial controller's firmware) to change the note numbers of each button, add special modes to give other functionalities to the same buttons, this kind of things.
Let me know how it goes I'm hoping to get started on mine in 2 weeks or so.
Thank you @oid , I should have thought about that right away!
Turns out that
aseqdumpdoesn't show any difference (NoteOn with velocity 0 is interestingly displayed as NoteOff, but it works anyway on the 64bits machine to turn off the LED).
I found one cause by chance however: If I connect Pd with the MIDI device via ALSA-MIDI, it works fine, but if I connect them via JACK-MIDI, I can't turn off the LEDs!
So when I connect PD with the controller with
aconnect 130:1 24:0it does work fine on both laptops. Not sure whether that might be caused by a2jmidid in the end, but I guess it is solved (and indeed not related to Pd!).
So, continuing my investigations, I have had no more success with [cyclone/xnoteout] and raw hex midi messages sent to [midiout]. And not better either if I start jack with
-Xraw, and both laptops use the same version of a2jmidid.
Two more details:
- laptop where it works: Jack 1.9.14, 64 bits
- laptop where it doesn't work: Jack 1.9.12, 32 bits. I could try to upgrade jack to 1.9.14 but it may have to use different repositories or potentially mess up dependencies.
I am having a weird issue, not sure whether it is actually due to Pd or not: in order to turn on and off the LEDs of my Midi controller, I need to send it a noteon message with a velocity of 1 (turn on), 2 (blink) or 0 (off). This works very well on one of my machines with Debian 10, Pd vanilla version 0.49.0-3 or Pd-L20rk 2.15.2, by sending
[noteout 1], however on another machine with also Debian 10, Pd vanilla 0.49.0-3, only the velocities of 1 or 2 make the LED turn on or blink, but impossible to turn it off with a velocity of 0!
I first thought that it may be due to Pd interpreting NoteOn with velocity of 0 as NoteOff, but it works fine on one of the computers.
Jack is started on both machines with
-dalsa -Xseqand I run
a2j -eto access the Midi devices through Alsa. If I stop a2j I can successfully turn the LEDs on and off with
amidi -phw,2 -S "90 40 01"or
00". So I am ruling out the hardware/driver issue.
What else could it be, any idea anyone? I shall check the version of a2j later today, but they are both up-to-date using Debian buster repos so I doubt I'll find any difference there...
Sorry if this turns out to actually not be related to Pd, but I hope someone may be able to help anyway