i/o-errors in pd
@JackPD Ok, looking at sndfiler. Let me see if I understand it correctly.
Take the following test patch:
[table foo 128]
[nbx]
|
[; A bang; B resize foo $1; C bang(
[receive B]
|
[sndfiler]
|
[bang]
|
[send SNDFILER_OUT]
[r A] [r SNDFILER_OUT]
| |
[timer]
|
[print first]
[r C]
|
[print last]
Is it true that I would get output printed in the order "last" then "first"? If so then sndfiler breaks Pd's depth-first message passing rule.
Is it true that [timer] here will output different values depending on the size of the float provided to [nbx]? If so then [sndfiler] breaks Pd's deterministic scheduling rule.
Also, it appears a "resize" message with no arguments would crash Pd. That's a bit alarming given that I just happened upon it while scrolling through the source. Threading issues are extremely difficult to debug so I'm a bit cautious about exploring much further. (Also there's a threading wrapper library dependency by yet another author...)
Just for a thought-experiment: imagine a set of "delay" externals that try to do computation on a separate thread in the time allotted:
[resize foo 256(
|
[sndfiler 50]
In this case "50" would mean to delay output for 50 milliseconds from the time the object receives an input. So you send the resize message, sndfiler does the work in a separate thread, and after 50ms the object gets a callback to send output.
Now, if the thread has finished its work the output would be sent deterministically. If not the object would block until the thread has finished, send the output, then display an error to the console that it missed a deadline.
That's basically just mapping Pd's system scheduling to control objects. I think that would be a very clunky design that would be hard for users to maintain and reason about. But it's still preferable to breaking determinism as sndfiler apparently does.
Btw-- even after sndfiler finishes its threaded array resizing, it still must rebuild the dsp graph for the reasons I mentioned in my last message. So for patches with lots of signal objects you'd probably still generate dropouts.
Hm... here's an idea:
- Require every class that deals with garrays to have a "set" method
- Require the "set" method of these classes to bind the object to a symbol that concatenates the array name with something like "_setter". So [set foo(--[tabread] would bind that object to symbol "foo_setter"
- When array "foo" gets resized, send a message "set foo" to "foo_setter"
Now every table-related object that uses array "foo" will have an updated reference to the newly resized array before the next dsp tick. This is because when you send a message to a receiver symbol in Pd it will dispatch the message to every object that shares this name.
On the other hand, the "set" methods of table-related classes in Pd weren't designed to be realtime safe. For example, some resize values may trigger an runtime error condition that requires rebuilding the graph. I guess the algorithm above could call some kind of "slim-lined" version of "set" that does size-based checks but excludes things like array name lookups, etc. But that would require splitting out every single "set" into a set of two methods.
A combination of that and the delay-based sndfiler could get you array resizing without dropouts. But that's a very clunky interface which is difficult to debug for a lot of work upfront just to get it running.
Table-using Abstraction can be used multiple times in one patch
@Maggie17 Sometimes it is easier with words........
Dollar $ variables in Pure Data patches.
A dollar variable is a thing that can be given a new value.
The new value can be a float or a symbol.
- If the Dollar variable is in an [object] box
A Pd patch can be saved and used inside another patch. We then call it an abstraction.... and it is just like a programming sub-routine.
If you want to use it many times then you have a problem, that they are all the same, so if you put an object [receive woof] they will all receive any message that you send with [send woof].
That might well be what you want to do.
But what if you want to send the message to only one of them?
You can give it an [inlet], but your patch will get messy, and what if your patch needs to make its own mind up about which abstraction it wants to send the message to, maybe depending on which midi note it received?
The solution is to give the abstraction arguments... some parameters that define it and make it different to the other copies.
For example [my_abstraction]
Let’s give it some arguments [my_abstraction 5 9 woof]
Inside the abstraction, as it is created (you open its parent patch) the dollar variables will be replaced. Wherever you see $1 written IN AN OBJECT it has been replaced by the number 5.
Number 5 because 5 is the first argument and has actually replaced the $1. You still see $1, but if you bang a [$1] object it will output 5.
[f $2] will output 9
[symbol $3] will output woof
So if you have an object [receive $1-$3] then it has now become [receive 5-woof]
And if you want to send it a message from outside, from another patch or abstraction, you will need to use [send 5-woof]
Every Pd patch, which remember includes your abstractions, also has a secret number. The number is unique and greater than 1000. As Pd opens each patch it gives it the number, increased by one from the last number it gave.
That number will replace $0 as the patch is created. You can find out what the number is by banging a [$0] object and connecting its output to a number box, or [print] object.
$0 can be used in any object as part of the name or the address, which means that a message cannot escape from the abstraction. A sub-patch like [pd my-subpatch] will be given the same number.
But from outside your abstraction you don’t know what it will be when the patch is created, so it is not useful. (A lie, you can find out, but as it can change every time you open your patch it is not worth the bother).
Use it to send messages within your patch [send $0-reset] to [receive $0-reset] for example, because the message is absolutely unique to its window, so you know it cannot interfere with other abstractions. - If the Dollar $ variable in a [message( box
Dollar $ variables are also replaced, but not as the patch is created (drawn by Pd as you open it).
Dollar zero $0 has no meaning in a message box. It will produce a zero if the message is banged, but that is it.
It is a mistake, a patching error, to put a $0 in a message box.
$1 $2 $3 $4 etc. in a message box are replaced by incoming atoms (individual floats or symbols or whatever) when they arrive. $1 will be replaced by the first atom in the list, $2 the second etc.
So if you have a message box [$1 $2 $3( ..... and you send into it a list [3 48 lala( .....then it will output 3 48 lala
That is not really very useful.
But it is actually very powerful.
Make a list in a message box........ [33 12 wav(
And bang it into a message box [open my-track$2-$1.$3( and you will get the output.........
open my-track12-33.wav
Which could be just the message that you want to send to [soundfiler]
David.
Table-using Abstraction can be used multiple times in one patch
@Maggie17 $0 will be different in every abstraction. That is useful ...... making it local.
But if you want to look at it from another patch or abstraction you can't ...... the other abstraction doesn't know its value. It is looking for its own $0 value....... cannot find it...... hence the message.
Probably best to give your abstraction an argument........ [abstr 1]...... [abstr 2]..... and then use $1-meight for your table.
Then you will have 1-meight ........ 2-meight...... etc. and you will be able to read them from your other patches.
You can then use $0 ...... or $1 for messages inside your abstraction....... but always $1 if you want to send or receive a message from outside.
Of course..... if you put a [receive $1-mess] in a patch that has 5 as its first argument then if you want to send to it from another patch you must use [send 5-mess]..... and to use tabplay to read table $1-meight from outside the abstraction you will need to use [tabplay 5-meight].....
David.
P.S. the error you are seeing though, is coming from your second [read -resize........( message.
$0 has no meaning in a message box...... and becomes simply "0"....... and you don't have a table 0-meight...... although you could if you wish.
Your first part...... bang >> [$0] >> [message with $1( puts the value of $0 into the $1 in the message and is the correct way to get $0 into a message....... and will get $1 into a message too...... bang >> [$1] >> [message $1(
See this....... dollar.zip ..... small change made..
It is hard...... but great when you finally understand...... so worth the work.....
Is automatic patching possible?
@elden [obj 350 10 r test( means put [r test] at x =350 y = (minus) 10 (from top left corner)..... build_bus_panels.pd
[connect 0 0 1 0( connects the first objects first outlet to the second objects first inlet.
[connect 2 1 3 4( connects the third objects second outlet to the fourth objects fifth inlet.
... object... outlet .... object .... inlet.... as you would draw it in Pd.
It's great counting from zero isn't it......?
Better than Hex though.......
The object "id's" are the order they were created in. If in doubt put all the objects by message before you put anything in the patch manually, or count up the objects that you have already and go from that number + 1
As a rule, you need to put any permanent objects first..... as you might need to connect to them.
But if you change them... add or take away..... you will need to change all of your connect messages.
That is why I prefer to set a base number and derive all my connect messages from that using [+ n] and $ variables in the messages. Much easier like that to modify the dynamic patching.
If you are adding to an already existing patch, and want to connect to something, you will have to open the patch in a text editor and count from the top of the page down to that object (objects only) because you have no idea in what order they were created..
David.
Lissa Executable / ofxOfelia compile error (Solved)
@cuinjune I tried to compile the lissa seq patch. but when i open the executable it opens only a small empty window.
i also tried to compile a help patch for testing, with the same result.
but your example works fine(Win32Example).
Foot Pedal Behaviours Abstraction
@image_engine I have absolutely no idea why it should be the case...... but the GUI will be laggy if the audio settings are too tight........ even when the DSP is not in use AND IS TURNED OFF. It makes no sense, but it is so. Maybe an audio chain is built as the patch is built, even when there are no audio objects?
[input_event]...... I might be wrong, but my foggy old brain is trying to tell me that [input_event] was not part of extended. If you have made a fresh installation on W10 it might be missing.
Here it is again from my "pd/extra" folder........ in.zip
The two files were in "extra"...... not in a sub-folder.... which makes me a little more certain that they were not included in extended.
Of course the Win 10 api might have been re-written and the .dll might be deprecated.
I don't know if the execution order is critical for the pedal up flag...... but that would be the first place to look if the patch behaved badly. It could matter if you changed something else for some reason. But on the left side the send_ped_up can send [0( from the box above when banged by [sel 1 3] and [1(...[1( or [0(....[1( depending on the order from [sel 1 2 3 4]. Can that cause problems because of the arrival of a new input in the middle of a pedal input? I don't know...... but it could be best to "fix" the order so that there is no doubt about the logic.
Yes, I inserted the two bangs to get rid of the double cords from the select object...... but also, as you say, it helps with a de-bug...... as it reminds the reader that outputs 2 and 4 are getting only bangs, while outputs 1 and 3 are getting logic (0/1).......
I would use logic (0/1) as you have done....... as the patch is all about logic. Number 0 is logical false and so "means" "off" and is a natural reset. You could create tags for messages using symbols and then [route] instead of [select]. I had never thought about that, but it is a very interesting idea . It serves no purpose in a running patch, and creates extra work building the patch........ BUT......
..... In the past I have set a slow [metro] to make such a patch "live" and used "magic glass" or labelled [print] objects for debugging. In a very complex logic patch it could be very useful to tag the messages. It can be hard to spot message ordering problems just using the terminal window and even harder with "magic glass". With symbol tags you would easily see where the messages originated. It's a very good idea! Up-vote deserved!
Sorry...... that sparked some ideas.
Tagging and routing by symbols will be a bad idea because the logic decisions need to be taken by 1/0 true/false and so the value needs to head up the list.
But tags could be appended....... to show the route taken.
[route] would always be used instead of [select]...... so that the appended message is preserved...... and then the logical value re"-"placed using [list prepend].
I might start a new thread I think..... to gather ideas and criticism.
A set of specific "normal" and "debugging" objects would be useful, as, for example [myselect 0 1] (which contained values to "send onwards" unlike [sel] ) could be renamed to [myrouter 0 1 router5].
Aarrgh...... probably a huge hole in which to stop digging......
..... and I bet it exists in extended already........?????
P.S.
Is your patch working as you wish?
And reading again.... after all that!..... I think you meant "message or float" and not "symbol or float" to send the zero.
I don't know of any difference, and they send exactly the same data, but the message [1( is more useful for debugging than the float [1] because you can click it and send the message.......
David.
debugger.pd
Build a MIDI controller with the Arduino, Firmata and Pure Data
Time to start contributing some knowledge back to the wonderful world that is the internet; today, a step by step nice and easy tutorial on getting started to building your own MIDI controllers with the arduino.
When researching for my ableton controller project, I didn’t find much out there about using firmata on an arduino to send data to software. The standard approach just seemed to be create the code in the arduino language, upload it to your board and hack one of those MIDI to USB cables as a bodge job way of getting the MIDI out of the arduino.
So why firmata and pure data? Well the whole idea of firmata is that you flash it to your arduino, and it throws out serial about whats going on with the arduino inputs and outputs, then you decide how the software treats the readings coming in and going out.
Theory out the way, lets build some controllers. You’ll need a few things…
HARDWARE:
An arduino and something to wire into it (for this i’ll be using a pot)
A USB cable for your arduino
SOFTWARE:
Arduino – http://arduino.cc/en/Main/Software
Pure Data – http://puredata.info/downloads
Firmata – http://at.or.at/hans/pd/objects.html#pduino
Something to patch your new controller into; like Reason or Ableton Live
- SETTING UP FIRMATA AND PURE DATA
Install Pure Data and create a folder to store all your patches somewhere. Unzip Firmata and add the files ‘arduino.pd’, ‘arduino-test.pd’ and ‘arduino-help.pd’ to your new Pure Data folder. The ‘arduino.pd’ file is the object that we use in PD for opening up communication with your arduino and routing it to PD. Done? Awesome, your software is almost set up.
- FLASHING FIRMATA TO YOUR ARDUINO
Install the latest version of arduino and open it up. Connect your arduino with the USB cable to your laptop (i’m using a macbook for this by the way). In the example patches, open up “Standard Firmata”, select your board (im using an arduino mega), and your serial port (look for tty.usbserial for use with a USB cable). Then compile and hit the upload button and your arduino is now ready to use firmata and communicate with Pure Data!
- WIRING UP A POT
Potentiometers are cool, and theres a great arduino tutorial of how to wire one up here: http://www.arduino.cc/en/Tutorial/Potentiometer
Basically, all you need to know is that there are three pins; your two outer pins govern voltage flow across the pot, meaning one has to be 5V and the other has to be ground. It doesn’t matter which, but your 5v pin is going to be where your pot reads maximum, so convention dictates this should be the right hand pin. The center pin needs to be connected to an analog in on the arduino and will read the value of the pot as it sweeps from ground (0v) to 5v.
All wired up? Plug it into your laptop and open Pure Data, we’re ready to get things talking.
- SETTING UP OUR PATCH
Open the example “arduino-test.pd” Pure Data patch you copied over earlier. It should look like this one…
The test patch has everything we need to open a connection and enable pins. Firstly, lets delete a bunch of stuff and make our window a bit bigger. Hit Command + E to enter edit mode in Pure Data.
Ok a quick explaination; the key component here is the ‘arduino’ object. This is being drawn from the file you copied in earlier, and is what communicated with your arduino. Here we can do everything to control the arduino from opening a connection, to receiving data.
The large grid allows us to set the mode of each pin on the arduino. Remember pins 0 and 1 are reserved for Rx and Tx. I’m using analog pin 4 for this demo, so I’ve set my pin mode for pin 4 to ‘analog’.
Now we can plug our arduino in and get a reading from the potentiometer.
- ARDUINO INTO PURE DATA
With your arduino plugged in, hit command and E to bring us out of edit mode. In our patch, click on ‘Devices’ above the arduino object and open up the pure data terminal. (That other thing that loads with PD that has all the scary code in)
The “Devices” message connected to the arduino object pings your computer to find what devices are connected and on what serial ports. Since we’re using a USB cable to connect our arduino, we’re looking for something with ‘usbserial’ in it, in this case; port 2.
Select the relevent port in the green box at the top (remember the first box is ‘0’, second is ‘1’ and so forth) and hit ‘Open’ to establish a connection. Check the terminal to see if the connection was sucessful.
Now lets check we’re getting something in. Create a number box (Command + 3) and connect it to the relevent pin on the ‘Route analog’ box at the bottom. In this case, pin 4.
One more thing; if you’re not getting any readings in, you’ll need to click on ‘pd old analog/digital controls’ and enable your pins here too. What I tend to do in my patches is just not include the large grid but make my own ‘old pd’ controls custom to what i’m enabling/disabling to save space.
Here’s what the ‘old analog/digital controls’ subpatch looks like (pin 4 enabled)…
Come out of edit mode and check that you’ve got readings. If so congratulations! If not, troubleshoot, start with making sure your usb connection is opened, make sure all the correct pins are enabled (remember you’re counting from 0 not 1 on most of these buttons in PD, it’s just the way computers work).
- SCALING READINGS TO MIDI
So we’ve got a reading and chances are it’s to 3 decimal places between 0 to 1. No problem, create a new object (Command + 1) and type “autoscale 0 127”. This allows us to scale the input to a min and max value, in this case 0 to 127 of MIDI. Next, lets get things looking nice, create a new object and type “knob”. Connect this AFTER the autoscale object. (the knob is default set to read inputs from 0 to 127. Then create another number to display the scaled MIDI data coming out, and finally a new object and type “ctlout 1”.
It should look something like this…
The second box should be outputing values from 0 – 127 now, and the knob giving a visual representation of your potentiometer.
Now lets patch it into ableton…
- PURE DATA TO ABLETON LIVE
Firstly, you’ll need to set up your macs IAC driver if you’ve not done this. Basically you’ll need to go into Audio/MIDI preferences and enable your IAC driver. Then create a new input and output. One for input to DAW and one for output from DAW. Google around for a tutorial on this, its really simple, a 30 second job.
After you’ve set up your IAC driver, go back to PD and go to preferences > MIDI Settings, and connect your IAC driver.
Open ableton and go to its MIDI preferences. Create a device listing for your IAC driver and enable its ins and outs into ableton like so…
And thats it! Create an instrument and try to assign something! I’ve got it controlling the brightness of a bass sound here.
Shout out for Facu who requested this tutorial. Hopefully it’ll help some of you looking to get into this stuff and start building things but with no idea where to start.
ArguScore
Here is an updated version
arguscore-update.zip
and a few Purr Data compatibility replacement objects: purr-data-compatible-replacements.zip
A creation argument only object driven system for instant music making;
Objects so far;
Required;
globaltimer - outputs a 10ms bang to drive all objects;
globalsync - resets all objects to zero or start;
audio~ - dac~ catcher~ for all throws~, output level, mute;
Sound Objects
By default sound objects start playing at the bpm of the first argument
basspump - args - bpm note distortion duration
wood - args - bpm note duration
tremsaw - args - bpm note vibrato distortion duration
tremsine - args - bpm note vibrato noise duration
noisy - args - bpm note vcfq duration
kauplus - args - bpm note string-resonation duration
Effect Objects
sqr - args - 16 required(0 or 1) bpm (starts playing by default)
overides sound objects autoplay
2 optional args for cursor offset and pitch if font different
has 16 outlets to send 0 or 1
echo-delay-bpm - args - bpm feedback(0 to 100) level(0 to 100)
echo-delay-ms - args - millisecs feedback(0 to 100) level(0 to 100)
pan-level - args - pan (-100 to 100) level (0 to 100)
autopan - args - width (0 to 100) frequency (* 0.01) level (0 to 100)
fade - args - millisecs to fade-in pecentage of level to drop to (0 to 100) millisecs to fade-out
filter - args - highpass (midi note to frequency) lowpass (midi note to frequency)
(0 to 135 equates to approx 8Hz to 19912Hz)
start-delay-secs - args - seconds (delays the autostart of the connected object)
start-delay-bpm - args - bpm (delays the autostart of the connected object)
stop-delay-secs - args - seconds (outputs a one at the end of the delay which can connect to a globalsync)
stop-delay-bpm - args - bpm (delays the autostart of the connected object)
isolator - sits between two sqr's and sends a signal to start/stop the receiving sqr
seqnotes - four pairs of note & velocity that receive sqr ones to fire a connected sound object
Notes
Can crash Pd when making lots of edits to arguments, particularly while playing, so save often
There is a [declare -path objects] hiding behind the audio~ object
Fixed missing note and velo message for tremsaw
Two more arguscore patches can be open at the same time providing only one patch contains the globaltimer and audio~ objects (see arguscore-2.pd and arguscore-2-b.pd)
new objects
kauplus, autopan, fade, filter, stop-delay-secs, stop-delay-bpm;
Problem loading libraries (iemguts)
Eighteen-year-old Shen Qiang says he soon thereafter began winning Canadian contests, and came in Canada in 2004. He will be a proud representative of the Canadian Olympic team this summer. While he didn't immigrate explicitly to further his table tennis career (he came with his family, who live in Toronto), he's happy with Table Tennis Canada's sports app, and is looking forward to the autumn opening of this new 24-hour training centre in Ottawa, so that he can work harder on his sport. Produced in northeast China, Shen first picked up a paddle at nine. He quit college to proceed to Harbin, a town 300 kilometers away, to train full-time and represent the province of Heilongjiang and had left home. The contest in China was extremely intense, '' he states. https://ok.ru/group/53953306755154/ The athletes trained five days a week, six hours a day; they were paid to train fulltime and compete, he says. "In China, it is very competitive because in the event you do not make results then you will be removed from the team, and if you don't have table tennis without a school, there is no future for you."
beginner's question: how to store and access objects in pd
Hey there,
as a beginner I am having trouble dealing with lists and accessing scalars within lists. Would be nice if you can point me in the right direction.
Background: I am using “netsend” to send data from a python code to pd. Within pd I want to store the messages which are being send. Essentially every message is referring to an “object”. A message contains five floats: e.x. “1 52 23 54 6”. The first float is the id of an object. The other floats are properties of the object.
Now when a message is send to pd I want my patch to:
-
Check if the object is already stored in my list, in other words: If an object with the same Id exists in the list
-
... Yes -> change the properties of that object
-
... No -> add (“append”) the object to the list
-
Delete an object if the message is “xx xx 0 xx xx”
In future I’d like to use these objects to create sounds (duh), similar to a sequencer as presented in the Help Browser
-> pure Data/ -> 4.data.structures/ -> 07.sequencer.
Thanks for taking the time!
Daniel