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
"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).
It's better to use the [makefilename] object for this :
[atom] (number box)
|
[makefilename /Samples/DM/Boss_DR55/DR55_%d.wav]
|
[read -resize $1 drum1array(
|
[soundfiler]
|] [] |.| ][|-| -- http://soundcloud.com/domxh
Great! Thanks alot Domien
hey guys,
thanks for that little tutorial.
i tried the example in a little sample looper, but i only get that error:
0-sample: no such table
can someone look inside my patch and tell me what is going wrong?
you need to put [f $0] in an object box, not a message box [ ( . $0 messages don't work in message boxes. Run the output of [f $0] into the right inlet (the float inlet) of [pack s f] - then everything works.
grrrmlkrr, 
thanks a lot, what a stupid error.
now it works great.
thank you all for the excellent information
everything is working well except my loadbang doesn't seem to fire when my abstraction is created from a message box connected to a s pd-window.pd, so unless i manually create the abstraction object in the pd window, i'm not getting the loadbang-$x output i need.
i.e., if i open the message-created abstraction and bang the test bang i have loadbang routed through, i get my output. if i put an object and create my abstraction that way i get my output without having to do anything else (like i expect, and want it to be).
what gives? is there something fundamental that i'm missing about message created abstractions or obj messages? there are no $x's in the abstraction name/argument list, so a missing slash in my obj creation message can't be the problem, right?
the patch i'm working on will be running on a library in objective c (http://gitorious.org/pdlib/pages/Libpd) so i'm not sure if i will have the same problem when the abstraction is called from a code-sent message, but i can't imagine why it would behave any differently than in the pd window environment.
hopefully this is just something i'm overlooking.....?
any feedback is most welcome
Oops! Looks like something went wrong!