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
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
nevermind....i guess a message-created object needs to be followed by a loadbang message to trigger it - not sure i understand why but makes sense that it worked
Just found this post, cheers hardoff you've saved me a load of head scratching and staring at the monitor!
Just an idea: I really like the way this forum is structured: patch, abstraction, etc. Makes it easy to search.
Another great section to have would be: tutorials.
With time, a nice collection could be built.
Most useful to newcomers.
sounds like a good idea. it's up to the users of the forum to add stuff now
Mod, thanks so much for implementing the suggestion.
Cheers
Samuel
Aaahhh, thanks for bringing this old thread up, now I finally get 'graph-on-parent', one of the most mysterious PD terms
@mod said:
sounds like a good idea. it's up to the users of the forum to add stuff now
You could also move threads like this one into the new subforum. If it's not possible or preferable, we could just copy/paste the text from the OP into a new thread.
Hey, dudes. Been reading a bunch about $0 the last two hours, and I think I'm missing something somewhere. Trying to make a sampler abstraction, and I know the concept behind $0, but can't put it into practice.
First thing is in relation to a table. I renamed it from "Sample" to "$0Sample". Can tables not use this argument? Once I put the same into anything referencing the table, I get "0Sample: no such table". If tables can't use the argument, what ways around it are there when using more than one?
Second thing is $f1. How do use the argument for this? Is it needed?
I think I managed to get one example of it to work, but as I'm not too sure about how it even works, I guess I'll find out when it's finished.
Here's the patch, if it helps.
Your 2 questions are related I think.
You can use $0 in objects, arrays/tables names, send/receive in gui properties etc... but you can't use it like this in a message block. Instead you have to use $1 in it and send it a message. Check the help by clicking on a message block for some examples.
I've modified your patch, you don't need this [f $0] by the way. $1 and $2 in the read message are replaced with the file name and the name of the array ($0Sample in this case). Hope it helps.
Oops! Looks like something went wrong!