this is a quick explanation of the role of abstractions in pd, and why it is useful to use $0, $1, etc.. inside these abstractions.
ok. say you want to create a very simple sample player. you'd do something like this.
[0] <-- gui bang object #1
What is an abstraction, and why use $0, $1 etc ??
this is a quick explanation of the role of abstractions in pd, and why it is useful to use $0, $1, etc.. inside these abstractions.
ok. say you want to create a very simple sample player. you'd do something like this.
[0] <-- gui bang object #1
Awesome! This reads really well. Final example to explain $1,$2 is very elegant.Now we must sticky it. NIce work!
Use the Source.
man. you really do know jedi mind tricks!
i was just thinking today...what this forum needs is 'stickies'
edit...oh.. it does have stickies.
Yeah, this is one of the cloistered secrets of pure data, finally revealed. I like your writeup and it will help a lot of people out. this stuff is is especially helpful when transitioning from "beginner" to "intermediate."
Just to throw my pennies in. I like to use $1, $2 etc as you said as well; to set the initial values for a nested delay, or envelopeparameters, or table length. However I also find them invaluable in communication between sub-patches. I like to break my patches us into modular components, as simple as possible. Each component only does one thing, and all the control data is standardized and sent about using . One of my "performance" patches might look like:
[loader a] [loader z]
[fazor a] [badrummer z]
[looper a] [looper z]
Maybe something extra stuff that needs to be explained to make it more complete.
In time i've noticed that the reason to prefix objects with $0 has not always so much to do with creating abstractions, but is to avoid duplicate names within different patches altogether. Once you start having a considerable amount of patches, chances are great you'll end up giving (gui) objects, send/returns... the same name. E.g. you often want to name a slider that controls a lowpass filter "lop" or "lp" or "lopFreq" or whatever. So even when you don't intend to create an abstraction out of something, it's often useful to use $0.
|] [] |.| ][|-| -- http://soundcloud.com/domxh
This dual use of $args is very confusing to beginners. I would say separate any mention of message substitution $args completely from abstraction parameter use of $args and just make a brief mention that they have two uses. Frank has patiently explained this over and over yet it still comes up as a FAQ. There was some talk on the pd-list of changing this, but it will never happen for reasons of backward compatibility. I think in Max you use # for parameters, is that right?
On tutorial/howto subject: How about contributing that one to the pdwiki Hardoff? I think some of my tuts got tidied up and put in. Instead of long tutorials I might try contributing some shorter FAQ/WTF? I think your example above is a good model. One subject and a succinct focussed couple of hundred words to give just the facts.
btw: If you chaps want a temporary home to host user written snippets like this I'd be happy to put them on OB1B and we can keep a running link list here until they are finalised into the wiki.
A really useful format is LaTeX, basically
\title{what is it}
\author{who wrote this stuff}
\begin{document}
\section{Section heading}
blah blah blah stuff
\subsection{subsection heading}
blah blah subsection of stuff
\end{document}
and these can be converted to HTML nicely
Use the Source.
This is great. thanks for taking time to explain all this. just one question to Nestor - when using $1, $2 etc at the beginning of an object name, such as $1-whatever, does the $1 in this case actually represent anything other than '1'? In other words, is naming the objects $1-whatever and $2-whatever any different from naming them whatever1 and whatever2?
"In other words, is naming the objects $1-whatever and $2-whatever any different from naming them whatever1 and whatever2?"
Absolutley - 1-whatever will not work. $0-whatever works because $0 is special, it gets replaced bu a unique per patch/abstraction number. $n is the nth parameter to an abstraction.
sory jumping in, that was addressed to you Nestor, elaborate for brett with an example maybe, i need my bed.
Use the Source.
brett, the answer to your question is at the end of what i wrote.
if u make an abstraction called [dollars]
then, for [dollars 5 bananas] $1 = 5 and $2 = bananas
so $1-whatever = 5-whatever , and $2-whatever = bananas-whatever.
Great! I second that, I didn't understand this stuff well in the beginning. Coming from a MAX/Reaktor background I didn't get it. But now I get it and like it more! Thanks for the concise clarification.
thanks for this, I have been trying to figure this out with a modified sample/looper from the examples e.g: how to have 1 to 100 of these independently.
However, I must being doing something wrong in this example, because after I graph and add the $0....I can't load a sample, when I try I get "0-my-sample: no such table"
as far as I can tell I have followed your text to a tee, but I must be overlooking something simple.
thanks,
db
I guess that's what i meant in my previous comment. When you try to use $0 objects within messages, you should "push" the $0 inside. For instance, assuming you have a table called $0-sampler1, the following won't work :
[bang]
|
[set $0-sampler1(
|
[tabread4~]
instead, you should do this :
[bang]
|
[pack $0]
|
[set $1-sampler1(
|
[tabread4~]
This way you push the $0 value (which is actually internally replaced by a number) inside the message. Remember that the $ variables inside messages are something completely different than the $ for objects parameters.
|] [] |.| ][|-| -- http://soundcloud.com/domxh
can you relate this to hardoffs sample, re; why no such table response when I am following his directions?
thanks..
db
if you follow from my example like this, it will definitely work.....
[0] <-- bang #1. right click for properties and set the send as $0-open
[0] <-- bang #2. right click for properties and set the send as $0-play
[r $0-open]
it works now, I don't know what the problem is/was. I have been spending the last few hours trying to get a solid installation, so maybe this was part of it.
thanks.
db
before finding out about all this $1- and $0- stuff I'd already put together an abstraction for playing a drum sound inside a drum machine. because I knew I wanted several copies of this within the drum machine I assigned "d1" at the beginning of each send or receive object in the drum abstraction, and then did find/replace in a text editor to change it to "d2", "d3", "d4" etc to make several different copies.
Now that I realise you can just have one copy and use $1 and creation arguments to generate further copies, I have tried to use find/replace to replace "d1" with "$1-". Sure enough the replacement operation works, but when I try to open the amended abstraction again in pd, it just opens a blank canvas?!
In the text editor everything looks exactly the same except for the d1 has changed to $1- so I just can't fathom what the problem could be.
Anyone have any suggestions?
I've attached the 2 versions for reference: 'drum1' is the original with "d1", and 'drum' is the amended version with "$1-" (except you won't be able to see anything with 'drum' unless you open it in text editor!)
...the other abstraction
you need a forwards slash before the $ sign if you go the textedit route
so $1-whatwhat -> \$1-whatwhat
attached fixed version seems to work fine:
Thanks mate! If you got paid for all the help you give out, you wouldn't be hard off!!
the slash is specifically for $ signs is it? i presume to distinguish it from also being used in messages?
i think it's because the $ symbol has another meaning in the software that pd runs on top of.
i'm more than happy to help anyone here if i can. certainly a much better use of my time than visiting music boards that are over-run with idiots being trolls to seek attention.
Is there any way to use $1 to select files for loading, for example:-
[atom] (number box)
|
[pack $1]
|
[read -resize /Samples/DM/Boss_DR55/DR55_$1.wav drum1array(
|
[soundfiler]
This doesn't seem to work because $1 is not at the beginning of the file name, or because it is embedded in the filename.
I'm just thinking that, if only we could change a small part of the filename remotely like this, then we'd be able to load samples easily just by scrolling a number box or moving a slider (as long as the sample files are all named with numbers).
Oops! Looks like something went wrong!