Using hRadio to switch between samples using a button-like function
@enoemowohoo Your top [t b f] always sets your counter to 0, there is no value sent out from a bang so the value of the f in that [t b f] is always 0. So you bang and the trigger sends 0 to the right [+ 1] which sends 1 to [mod] and the hradio which goes to [f 0] and then sets the right [+ 1] cold inlet and the bottom [+ 1] hot inlet which adds 1 to give two and the loop repeats giving you a stack overflow but it does count through 0 1 and 2 while it overflows. The left outlet of the [t b f] will actually never trigger since the float outlet never completes, pd just gives up once it has overflowed enough and realized there is no way out. The counter below the hradio actually does nothing but print an error to the log, output will always match the input.
If your use of two [+ 1}s was an attempt to get a single bang to cycle through all three states you probably want to use a metro to give your bangs, anything else will go too quickly but [until] is what you would want in place of the [metro] if you wanted to go as quickly as possible.
I have a problem with a mixer.
@Carambolooo You have forgotten to connect the right inlets of the [*~] volume controls for the effects channels.
Here is an abstraction that will give you the [panner] objects........ panner.pd
Put it in the same folder as your patch, then re-open your patch and for each instance give it an argument.
...... so in your patch change each [panner] to [panner 1] [panner 2] etc.....
That will keep them separate..... each one will receive control messages from only the fader that you wish.
Look inside [panner]. You will see at the top [r pan$1]. The $1 will take the argument you have just added to each [panner] as it is created.
Before you continue you should get to grips with abstractions...... that will save you a lot of time as you develop your patches......... https://forum.pdpatchrepo.info/topic/9774/pure-data-noob
You need to change all the hsliders controlling the pan to have a range of 0 to 1
In fact all your sliders need to have a range of 0 to 1 (because audio values in Pd must be in that range) and you will have to change them all in their properties pop up window..
You might well need to reduce the volume after your [catch~] objects as well because adding lots of [throw~] sends together will give you a final output greater than 1.
As @benalb says...... we have no "multiply defined" problems in Pd.
My best guess is that you have opened your patch twice..... effectively having each [catch~] then created twice in the plugdata program.
David.
Ps.... other parts of your patch could also be abstractions...... e.g.
You would create an abstraction...... say [mymix] and give that the argument for the channel number..... [mymix 5] etc.
Inside it would look like this......
..... and [panner $1] would then get the same argument (5 in this case) from its parent abstraction.... its a sort of magic......
And adding a $0 to all the send and receive names would mean that you can open your [mixer] twice without cross communication and without any "multiply defined" errors.
You could even include the control faders and VU's and show them through the GOP window of the abstraction...... another subject, but see the link above.......
Expanding your patch would then be child's play rather than a lengthy process prone to errors.
It's a lot to learn in one hit..... but well worth the effort...
MIDI port names on Linux
Hi all,
I've built 3 small Pd patches to fit in my workflow, e.g. to convert one MIDI controller's messages into OSC, one to light up the LEDs of another controller, one to control a pedal, etc.
If I open 2 instances of Pd, each with its own MIDI (or audio, for that matter) inputs and outputs, Alsa-Midi refers to them as follows:
$ aconnect -l
client 128: 'Pure Data' [type=user,pid=260121]
0 'Pure Data Midi-In 1'
1 'Pure Data Midi-Out 1'
client 129: 'Pure Data' [type=user,pid=260548]
0 'Pure Data Midi-In 1'
1 'Pure Data Midi-Out 1'
2 'Pure Data Midi-Out 2'
The client name is the same, and the client ID cannot be predicted - depending on which controllers I have plugged in and in which order, it might be any number incremented from 128. The tools that should remember and restore the patching (jack_patch
, Ray Session and the like) struggle the same as I do to figure out which instance of Pd to connect to which controllers.
I want to keep these patches in separate PD instances so I can mix and match, and not necessarily have all of them open, and always rely on the specific instance's MIDI input number and output number.
So, here's my question: any idea if it is possible to rename Pd's alsa-midi ports? I found surprisingly little online about this issue, yet I can't really believe that nobody met this issue before...
I've never seen the command line option -jackname
to actually have an effect, but in any case Pd does not use Jack MIDI as far as I understand.
I've been thinking about running the patch in a libpd wrapper instead, e.g. from a Python script in which I could specify the client's and port names, but I'm struggling a bit to install pylibpd.
macOS & iPad - can PureData be controlled from the touchscreen?
@whale-av said:
@esaruoho I have found the very small investment in TouchOSC
Great app!
TouchOSC and Open Stage Control are similar but different.
Open Stage Control is a server and thin client. The server runs in Windows, Mac or Linux. It ships with its own client for editing, but you can also point Firefox or Chrome to it, with full access to editing features in the browser as well. The server can load any number of "sessions." One session is synced across any number of clients. If I open the same session in multiple browsers, moving a control in one window will update all of them at once.
So it's client window --> server --> OSC messages to an address of your choosing.
One nice feature is that starting the server prints a QR code in the console, which you can scan in mobile Firefox to open the page, without typing an IP address. Typing the address always annoyed the **** out of me.
At this point, I feel like this works out better for me than TouchOSC. But, Open Stage Control doesn't send accelerometer data. I never used it extensively, but it was nice to have.
Open Stage Control is also free and open source, no proprietary app you have to install on your device.
Here's Open Stage Control driving SuperCollider:
hjh
how to get dynamically updated values into Pd from Python
@seb-harmonik-ar thanks for helping think this through, I am at a very low level with python myself, but it is useful for this kind of stuff.
I don't think the problem is sending the variable over, because, as you say you could send a variable over in a simple way. Its more of how to assign dynamically updated values (from the server) to a variable.
I will try to show you what I mean:
here I define a function:
import socket
def handle_data(trace):
#print('Received the following trace:')
print(trace)
print()````
#(I am leaving out the code that sets up a client and queries data from a server because it is a bit #long,
#but I am using a package called obspy which is a package for doing this with seismographic data)
#then I do this:
s = socket.socket()
host = 'localhost'
port = #put an open port here
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
b = client.run()
s.sendall(b + ";")
# problem is to get the data that prints from the client.run() sent over.
#That is what I have been trying here with "b".
#The way I do it for a static value is this
#(posting this because it might actually help someone else doing this stuff)
s.connect((host, port))
mess = "yello"
Msg = mess + " ;"
s.send(Msg.encode('utf-8'))
# the ";" is because Pd likes messages in this 'FUDI' format
#which I think needs the semicolon like normal message boxes in Pd
#(and also if I am not mistaken there should be tab-separations between
#parts of. a message so that they can be separated as lists are in Pd)
Problems with jack on linux.
@bocanegra Thank you, i do hve librewolf (firefox) open, so i want that to work. i installed qjackctl and pulseaudio-jack on my artix (arch based) openrc system. it worked, purr data works, but librewolf audio clips and sounds like crap, i disconnected my usb headphones and reconnected them, but now librewolf outpts no audio, the same with purr data, except it shows up in the graph in qjackctl unlike librewolf which disappeared from there.
i restarted my system just now and jack won't start for some reason, but librewolf audio works fine.
error message in qjackctl:
13:31:47.206 JACK is starting...
13:31:47.208 /usr/bin/jackd -dalsa -dhw:0 -r48000 -p64
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
13:31:47.226 JACK was started with PID=3085.
Could not open component .so '/usr/lib/jack/jack_firewire.so': libffado.so.2: cannot open shared object file: No such file or directory
Could not open component .so '/usr/lib/jack/jack_firewire.so': libffado.so.2: cannot open shared object file: No such file or directory
jack_get_descriptor : dll
jack_get_descriptor returns null for 'jack_firewire.so'
Could not open component .so '/usr/lib/jack/jack_firewire.so': libffado.so.2: cannot open shared object file: No such file or directory
jackdmp 1.9.19
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2021 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot lock down 107341340 byte memory area (Cannot allocate memory)
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|64|2|48000|0|0|nomon|swmeter|-|32bit
ATTENTION: The playback device "hw:0" is already in use. Please stop the application using it and run JACK again
Released audio card Audio0
audio_reservation_finish
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
13:31:47.348 JACK was stopped
13:31:49.270 Could not connect to JACK server as client. - Overall operation failed. - Unable to connect to server. Please check the messages window for more info.
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Any help?
netty-mcserver on a Raspbery Pi 4
Hi . .
Here's an update. I was able to compile Pd-0.51-2 and run Pd on the Raspberry Pi 4. Thank you to Whale-Av / David for the clear instructions.
I navigated to the Quack/bin folder where the server patch is and ran this command:
/home/pi/src/pd-0.51-2/bin/pd -nosound -nogui -nrt netty-mcserver.pd &
the command line returned this:
[1] 1112
Checked to see if the process is running and it appears to be:
ps -ef | grep pd
pi 1112 1096 4 19:08 pts/0 00:00:01 /home/pi/src/pd-0.51-2/bin/pd -nosound -nogui -nrt netty-mcserver.pd
So, feeling good right? I checked the port forwarding on my router and opened ports 10000 to 10100 going to the Pi. That should be solid since I previously ran some tests with some colleagues using the same network but pointing to my iMac running netty.mcserver.pd.
When I open netty-mcnetface.pd on my iMac and put in the Pi's DNS name (bitpanic.org) into the patch as the server I get a netsend error:
netsend: bad host or port? nodename nor servname provided, or not known (8)
I also tried the direct IP (not the local IP) and no dice . .
Anyway, I'm going to see if someone outside of my network can connect. Maybe it is some sort of internal routing issue.
I'm also not clear if the patch "netty-mcserver.pd" will work on a Raspberry Pi. I've been following Michael Dessen's google doc on getting this to work on a Debian server so it must work but maybe not on the Pi? Michael says in his instructions that he got to work on a single core Debian server on Linode. I guess I could try that but where's the fun? : > ) And, we (CalArts) are running two streaming servers on campus that are Raspberry Pi's so I'd love to get it work.
Anyway, will keep plugging away. Any insight is appreciated!
Thanks!
Clay
Ninjam external
Hi, I've been playing with ninjam for a few weeks, it's very useful for the current situation (see the date and do a google search if you are from a distant future). I would like to make an external for it, so asking if others pders are interested in collaborating?
Here's some information to kick off this idea.
First of all I have a server up and running for testing the solution. Ask me in PM for the password:
https://ninjam.baldapproved.com
The best client for now is in Reaper or you can use a VST called Jamtaba. Maybe there's a way to simply use the VST (Jamtaba - https://jamtaba-music-web-site.appspot.com/) in PD and then we don't need this external?!
A client close to what we want is the curseclient. I think it's a good starting point for us:
https://github.com/justinfrankel/ninjam/tree/master/ninjam/cursesclient
The Makefile is simple:
CC=gcc
CXX=g++
CFLAGS = -O2
OBJS = cursesclient.o
ifdef MAC
CFLAGS += -D_MAC
LFLAGS = -framework coreaudio -lncurses.5 -lm
OBJS += ../audiostream_mac.o
COMPILE_VORBIS = 1
else
LFLAGS = -lncurses -lm -lasound -ljack
OBJS += ../audiostream_alsa.o ../audiostream_jack.o
endif
OBJS += ../../WDL/jnetlib/asyncdns.o
OBJS += ../../WDL/jnetlib/connection.o
OBJS += ../../WDL/jnetlib/listen.o
OBJS += ../../WDL/jnetlib/util.o
OBJS += ../../WDL/rng.o
OBJS += ../../WDL/sha.o
OBJS += ../mpb.o
OBJS += ../netmsg.o
OBJS += ../njclient.o
OBJS += ../njmisc.o
CXXFLAGS = $(CFLAGS)
default: cninjam
cninjam: $(OBJS)
$(CXX) $(CXXFLAGS) -o cninjam $(OBJS) -lpthread $(LFLAGS)
clean:
-rm $(OBJS) cninjam
Ninjam is https://www.cockos.com/ninjam/ (the guy behind Winamp, Reaper). Very smart programmer. It's using WDL (https://www.cockos.com/wdl/) [re]usable C++, modestly].
I think the first step would be to compile njclient, being able to connect to a server (auth or anonymous). If anyone is willing to work on that or if someone have social accounts that can post this call for collaboration please do so. If successful we can then open a dedicated server for puredata.
Cheers!
Http://www.netpd.org/
@beem Nope, just audio and timing.
https://github.com/wahjam/wahjam/wiki/Ninjam-Protocol
*Time is divided into intervals which allow each client to upload audio that other clients will receive and play when the next interval starts. Therefore clients do not play audio together in real-time; audio from remote clients is always delayed by one interval. This design recognizes the fact that latency on the internet is too high for real-time audio collaboration.
The tempo is defined by the Beats Per Minute (bpm) and Beats Per Interval (bpi) session settings. Clients typically offer metronome functionality based on the bpm setting to enable musicians to play in time.*
I added OSC to the ninjam client so that PD can receive the bpm and downbeat (start).
Ofelia Emscripten loading samples and images / converting number table to const char* or const float* array?
Now I can answer my own question
Loading an ofImage from a Lua table with pixel values from a .bmp works like that:
ofelia d $0-embindReceiveBitmap;
function embind_6(w, h, buf);
testImage:allocate(w, h, OF_IMAGE_COLOR_ALPHA);
print("bitmap size:", #buf, "bitmap width:", w, "bitmap height:", h);
local count = 0;
for i = 0, h - 1 do;
count = count + w -((w >> 2) << 2);
for j = 0, w - 1 do;
ofPushStyle();
testImage:setColor(j, h - i, ofColor(buf[(i * w + j) * 3 + 54 + count], buf[(i * w + j) * 3 + 55 + count], buf[(i * w + j) * 3 + 56 + count], 200));
ofPopStyle();
end;
end;
testImage:update();
end;
So, now it is possible with Emscripten and Ofelia to load and manipulate .bmp and .wav data in the internet...
And to control the patch with webMIDI (or just Java Script).
And to output (MIDI) data.
I seperated the MIDI and audio example:
https://pdsample.handmadeproductions.de/
https://pdmidi.handmadeproductions.de/
https://github.com/Jonathhhan/ofxOfelia
And I have some ideas and suggestions how to optimize this:
- It would be nice to make a better basic webMIDI Java Script interface template, which is easy to connect to any Emscripten Pure Data Patch.
- It would be really nice if the [ofelia define] object could return a value through the outlet if an embind function is called from C++ / Java Script.
At the moment the values are banged from a 10ms [metro], which is not optimal... - it would be great to directly load userdata from java script to Emscripten Ofelia, so the conversion to and from arrays would not be necessary.
- I would like to get rid of the security warnings, that appear because of webMIDI and webAudio...
- Another idea is to have the Ofelia Window fullscreen on a subpage that is controllable from a Java Script interfache on the main page.
- And, because I am not very experienced, it is possible that there are some bad mistakes in my code.
But I tried my best, and it seems to work.
Would be nice if somebody more experienced can have a look.
Of course there are some disadvantages compared to a desktop app:
- MIDI is not as tight (but quite good for the internet, still - it could be optimized).
- Loading a picture or a big sound file while audio is running drops the audio.
- It accepts only .bmp images.
- the size is more limited.