hello Ive been working on triggering Osc by the use of the keyboard and im still a having trouble I read the kb.ck file in the hid folder to figure out how it triggered and output the keys so i came up with the below syntax. // setting up the keyboard to trigger Osc // this should trigger a middle c tone when A key is pressed { if (msg.is ButtonDown()) and if (msg.my_keynumber = 65 then SinOsc s => Dac; 261 => s.freq; 1::second => now } it still giving me errors ? even when i running the kb.ck file in chuck any help would be great thanks Gabriel --------------------------------- Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how.
Hi, again, Core.
// setting up the keyboard to trigger Osc // this should trigger a middle c tone when A key is pressed { if (msg.is ButtonDown()) and if (msg.my_keynumber = 65 then SinOsc s => Dac; 261 => s.freq; 1::second => now }
it still giving me errors ? even when i running the kb.ck file in chuck any help would be great thanks
Well, it's giving you issues because it's not correct syntax. Unlike humans programming languages demand that you write everything in a certain way. For example I understand what you mean with "and" here but ChucK will only get it if you write "&&" or if the structure of the program implicitly means we want both things to be true (like below). Like with learning French or Japanese in learning ChucK you will need to learn the right syntax. Like with other languages there are definitions on what correct syntax is (the manual) but also like other languages the best way to learn is to try to figure out what others are saying (the examples directory) and simply trying to speak it yourself. -----------------------------------8<------------------------- 65 => int mykeynumber; //define what key we are interested in for readability SinOsc s; //Let's define the oscillator outside of the loop, it will save issues { if (msg.isButtonDown() ) //detect the type of message { if (msg.which == mykeynumber) { //This bit will only get run if the message is a a button-down one AND it refers to the right button //Structuring it like this means you can check for other buttons as well in a cleaner way. s => dac; //notice "dac" is lowercase, it's not a Ugen as such. 261 => s.freq; 1::second => now; s =< dac; //disconnect once we are done } } } ------------------------------------------------------------- That's how I would rewrite what you wrote. I had to interpret it a bit as I'm not 100% sure what you are after exactly but I think this is fairly close. The advantage of this structure is that you could add something along the lines of this bellow the paragraph that deals with detecting the key; ----------------8<-------------------- else if( msg.which == anothernumber) //you'll need to define this other number, of course { s => dac; 330 => s.freq; //another key another note. 1::second => now; s =< dac; } -------------------------------------------- This means we only have to check for the message type once which saves CPU and leads to a cleaner program. Did you have a look at the keyboard-organ example in the HID dir? That example might be interesting to you too. Oh, and don't worry about getting errors, everybody gets them, it's rare to write something larger with no typos at all. Just take them on one by one and try to figure out what the issue is, correct it and try again. Hope this helps, Happy ChucKing! Kas.
On 04/12/2007, Martin Ahnelöv
tis 2007-12-04 klockan 07:59 -0800 skrev Alpha Core:
hello Ive been working on triggering Osc by the use of the keyboard and im still a having trouble I read the kb.ck file in the hid folder to figure out how it triggered and output the keys so i came up with the below syntax.
// setting up the keyboard to trigger Osc // this should trigger a middle c tone when A key is pressed { if (msg.is ButtonDown()) and if (msg.my_keynumber = 65 then SinOsc s => Dac; 261 => s.freq; 1::second => now }
it still giving me errors ? even when i running the kb.ck file in chuck any help would be great thanks
The syntax should look like this (I've made some notes): // if followed an expression in brackets. if there are mutliple, use // "and" followed by a new expression between brackets (you can also use // "or" instead of "and". // The curly brackets come after the whole if-statement. // No "then". if (msg.isButtonDown()) and (msg.my_keynumber = 65) { SinOsc s => dac; <-- dac is in written in small letters 261 => s.freq; 1::second => now; <-- should have a ";" at the end } That should - at least - work better. I'm a bit unsure about "msg.my_keynumber = 65", shouldn't it be "msg.key == 65" (note the double equal-signs)? Also, instead of doing raw frequencies, try Std.mtof instead. that will convert a midi-note number to a frequency. In your case the line 261 => s.freq; would be: Std.mtof(60) => s.freq; Hope that helps, Gasten
On 04/12/2007, Martin Ahnelöv
The syntax should look like this (I've made some notes):
// if followed an expression in brackets. if there are mutliple, use // "and" followed by a new expression between brackets (you can also use // "or" instead of "and". // The curly brackets come after the whole if-statement. // No "then". if (msg.isButtonDown()) and (msg.my_keynumber = 65) {
I'm sorry but I really don't think you can do that. I don't think I ever saw "and" used in a ChucK context and I can't get this to run; if ( true and true ) <<<"poof">>>; or this; if ( true) and (true ) <<<"poof">>>; While this works; if ( true && true ) <<<"poof">>>; If I'm wrong, could you give a example along those lines that uses "and" and will run? Yours, Kas.
tis 2007-12-04 klockan 18:18 +0100 skrev Kassen:
On 04/12/2007, Martin Ahnelöv
wrote: The syntax should look like this (I've made some notes):
// if followed an expression in brackets. if there are mutliple, use // "and" followed by a new expression between brackets (you can also use // "or" instead of "and". // The curly brackets come after the whole if-statement. // No "then". if (msg.isButtonDown()) and (msg.my_keynumber = 65) {
I'm sorry but I really don't think you can do that. I don't think I ever saw "and" used in a ChucK context and I can't get this to run;
if ( true and true ) <<<"poof">>>;
or this; if ( true) and (true ) <<<"poof">>>;
While this works;
if ( true && true ) <<<"poof">>>;
If I'm wrong, could you give a example along those lines that uses "and" and will run?
No, you're right. I just thought "and" and "or" was in there, since they are pretty common in languages with this kind of syntax. My bad. Gonna go edit my sintax file. IT DECEIVED ME!!!1 Gasten
Hi all, I am building an interface in Puredata to control via OSC a chuck program, but I am having some trouble when sending the position (x,y pairs) of a small "canvas" which I use as a point in space. The problem is that somehow most of the time I just get the x-coordinate and only sometimes the y-coordinate. And really don't know why. I must say that I'm not very used to work with puredata, so if there are any PD+chuck experts in this list that may have some time to have a look at the patches (attached below) and give some advice, I'd much apreciate it. thanks in advance, eduard
Just in case anyone is interested.... I fixed the problem by packing x and y and sending them together via osc. If someone uses more points, as its my case, all values need be packed, in order to receive all info at the same rate. eduard On Dec 5, 2007, at 8:16 PM, eduard aylon wrote:
Hi all,
I am building an interface in Puredata to control via OSC a chuck program, but I am having some trouble when sending the position (x,y pairs) of a small "canvas" which I use as a point in space. The problem is that somehow most of the time I just get the x- coordinate and only sometimes the y-coordinate. And really don't know why. I must say that I'm not very used to work with puredata, so if there are any PD+chuck experts in this list that may have some time to have a look at the patches (attached below) and give some advice, I'd much apreciate it.
thanks in advance,
eduard
Hi.
I know you found a good solution, but I am curious. Are you running your
puredata and ChucK programs on the same computer? UDP (upon which OSC is
based) is lacking in the secure-transfer department, but if you aren't
sending enourmous amounts of data on different hosts (or use an old
computer), you shouldn't lose messages like this.
Cheers, Stefan
On Dec 6, 2007 2:57 PM, eduard
Just in case anyone is interested.... I fixed the problem by packing x and y and sending them together via osc. If someone uses more points, as its my case, all values need be packed, in order to receive all info at the same rate.
eduard
On Dec 5, 2007, at 8:16 PM, eduard aylon wrote:
Hi all,
I am building an interface in Puredata to control via OSC a chuck program, but I am having some trouble when sending the position (x,y pairs) of a small "canvas" which I use as a point in space. The problem is that somehow most of the time I just get the x- coordinate and only sometimes the y-coordinate. And really don't know why. I must say that I'm not very used to work with puredata, so if there are any PD+chuck experts in this list that may have some time to have a look at the patches (attached below) and give some advice, I'd much apreciate it.
thanks in advance,
eduard
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the cosmos!
in my experience, UDP regularly drops messages, even when sending small amounts from one server to 2-3 clients (all reasonably new machines). we use it all the time in PLOrk, and have always had to find ways to work around the unreliability. this is true with both max and chuck. tcp and other things are in our future, though the accurate timing of udp is still quite remarkable. dt On Dec 6, 2007, at 9:53 AM, Stefan Blixt wrote:
Hi.
I know you found a good solution, but I am curious. Are you running your puredata and ChucK programs on the same computer? UDP (upon which OSC is based) is lacking in the secure-transfer department, but if you aren't sending enourmous amounts of data on different hosts (or use an old computer), you shouldn't lose messages like this.
Cheers, Stefan
On Dec 6, 2007 2:57 PM, eduard
wrote: Just in case anyone is interested.... I fixed the problem by packing x and y and sending them together via osc. If someone uses more points, as its my case, all values need be packed, in order to receive all info at the same rate. eduard
On Dec 5, 2007, at 8:16 PM, eduard aylon wrote:
Hi all,
I am building an interface in Puredata to control via OSC a chuck program, but I am having some trouble when sending the position (x,y pairs) of a small "canvas" which I use as a point in space. The problem is that somehow most of the time I just get the x- coordinate and only sometimes the y-coordinate. And really don't know why. I must say that I'm not very used to work with puredata, so if there are any PD+chuck experts in this list that may have some time to have a look at the patches (attached below) and give some advice, I'd much apreciate it.
thanks in advance,
eduard
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Release me, insect, or I will destroy the cosmos! _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Quoting dan trueman
tcp and other things are in our future, though the accurate timing of udp is still quite remarkable.
and the timing with tcp can be quite variable... brad http://music.columbia.edu/~brad
good to know. probably then some combination of udp for well timed messages (except for multicasting, which also stinks for timing) and tcp for single messages that *have* to get to their destination is the way to go. i believe Perry has a student working some new networking protocols for ChucK and related apps. top secret i suppose. dan On Dec 6, 2007, at 10:31 AM, garton@columbia.edu wrote:
Quoting dan trueman
: tcp and other things are in our future, though the accurate timing of udp is still quite remarkable.
and the timing with tcp can be quite variable...
brad http://music.columbia.edu/~brad _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Quoting dan trueman
good to know. probably then some combination of udp for well timed messages (except for multicasting, which also stinks for timing) and tcp for single messages that *have* to get to their destination is the way to go.
The other alternative is time-stamping of some sort of sync signal, but that makes some kinds of r/t interactivity more difficult.
i believe Perry has a student working some new networking protocols for ChucK and related apps. top secret i suppose.
weapons of mass distraction? brad http://music.columbia.edu/~brad
good to know. probably then some combination of udp for well timed messages (except for multicasting, which also stinks for timing) and tcp for single messages that *have* to get to their destination is the way to go.
The other alternative is time-stamping of some sort of sync signal, but that makes some kinds of r/t interactivity more difficult.
I believe the TCP-for-commands, UDP-for-parameters approach is a pretty good one. In my experience UDP packets aren't really dropped all that often, but I often wondered if TCP might be a better approach in general. Some day I'd like to see a standardized shared-memory approach to passing OSC messages, which would be insanely fast on a local machine. (Though, I believe that local loopback sockets are often implemented using shared memory, and are thus pretty much just as fast. Not sure if this is the case in Linux, I've been meaning to look it up for a while..) Keep in mind that if you have several OSC messages that must arrive simultaneously, you can us bundles, which should be supported in most implementations. I believe you can use them in PureData by sending "[" and "]" messages to the dumpOSC object. Not sure if Chuck supports them? In any case they are an under-used part of the OSC standard. Steve
yeah, you can do OSC bundles in ChucK, though it is undocumented. definitely helps when sending lots of data that should be together. dt On Dec 6, 2007, at 11:20 AM, Stephen Sinclair wrote:
good to know. probably then some combination of udp for well timed messages (except for multicasting, which also stinks for timing) and tcp for single messages that *have* to get to their destination is the way to go.
The other alternative is time-stamping of some sort of sync signal, but that makes some kinds of r/t interactivity more difficult.
I believe the TCP-for-commands, UDP-for-parameters approach is a pretty good one.
In my experience UDP packets aren't really dropped all that often, but I often wondered if TCP might be a better approach in general.
Some day I'd like to see a standardized shared-memory approach to passing OSC messages, which would be insanely fast on a local machine. (Though, I believe that local loopback sockets are often implemented using shared memory, and are thus pretty much just as fast. Not sure if this is the case in Linux, I've been meaning to look it up for a while..)
Keep in mind that if you have several OSC messages that must arrive simultaneously, you can us bundles, which should be supported in most implementations.
I believe you can use them in PureData by sending "[" and "]" messages to the dumpOSC object. Not sure if Chuck supports them? In any case they are an under-used part of the OSC standard.
Steve _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Quoting Stephen Sinclair
Some day I'd like to see a standardized shared-memory approach to passing OSC messages, which would be insanely fast on a local machine. (Though, I believe that local loopback sockets are often implemented using shared memory, and are thus pretty much just as fast. Not sure if this is the case in Linux, I've been meaning to look it up for a while)
My preference is to dump OSC entirely, and use some kind of loadable/imbeddable scheme. It would be just fun fun fun to put the entirety of ChucK into a loadable lib of some kind, and then find the entry-points you want from your calling environment and go go go. This is how [chuck~] works, by the way, brad http://music.columbia.edu/~brad
Hmm I am mainly a PD User but had a short look into chuck.... For now i cannot grasp the capabilities that a chuck~object brings into max or PD, but i am very interested.. Its a shame you didnt use "flext" (you know it ??) http://www.parasitaere-kapazitaeten.net/ext/flext/ That way we had a PD-object as well.. Since i am not a programmer i cannot do the port, do you think it is a lot of effort ??? Thanks Luigi Am 06.12.2007 um 18:10 schrieb garton@columbia.edu:
Quoting Stephen Sinclair
: Some day I'd like to see a standardized shared-memory approach to passing OSC messages, which would be insanely fast on a local machine. (Though, I believe that local loopback sockets are often implemented using shared memory, and are thus pretty much just as fast. Not sure if this is the case in Linux, I've been meaning to look it up for a while)
My preference is to dump OSC entirely, and use some kind of loadable/imbeddable scheme. It would be just fun fun fun to put the entirety of ChucK into a loadable lib of some kind, and then find the entry-points you want from your calling environment and go go go.
This is how [chuck~] works, by the way,
brad http://music.columbia.edu/~brad _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
mån 2008-05-19 klockan 11:42 +0200 skrev Luigi Rensinghoff:
Hmm
I am mainly a PD User but had a short look into chuck....
For now i cannot grasp the capabilities that a chuck~object brings into max or PD, but i am very interested..
Its a shame you didnt use "flext" (you know it ??)
http://www.parasitaere-kapazitaeten.net/ext/flext/
That way we had a PD-object as well..
Since i am not a programmer i cannot do the port, do you think it is a lot of effort ???
Thanks Luigi
AFAIK, the chuck development team is not responsible for the [chuck~]-object in PD, it's Martin Robinson, and he in turn based his work on Brad Garton's Max/MSP-object. I think you should get in touch with either them or the PD-list. Though, I might be very wrong in this. Mr Robinson will probably turn out to be a plork-member, or something =) Gasten
I didn't use flext because I am old and my brain is tired. brad http://music.coumbia.edu/~brad On May 19, 2008, at 5:42 AM, Luigi Rensinghoff wrote:
Hmm
I am mainly a PD User but had a short look into chuck....
For now i cannot grasp the capabilities that a chuck~object brings into max or PD, but i am very interested..
Its a shame you didnt use "flext" (you know it ??)
http://www.parasitaere-kapazitaeten.net/ext/flext/
That way we had a PD-object as well..
Since i am not a programmer i cannot do the port, do you think it is a lot of effort ???
Thanks Luigi
Am 06.12.2007 um 18:10 schrieb garton@columbia.edu:
Quoting Stephen Sinclair
: Some day I'd like to see a standardized shared-memory approach to passing OSC messages, which would be insanely fast on a local machine. (Though, I believe that local loopback sockets are often implemented using shared memory, and are thus pretty much just as fast. Not sure if this is the case in Linux, I've been meaning to look it up for a while)
My preference is to dump OSC entirely, and use some kind of loadable/imbeddable scheme. It would be just fun fun fun to put the entirety of ChucK into a loadable lib of some kind, and then find the entry-points you want from your calling environment and go go go.
This is how [chuck~] works, by the way,
brad http://music.columbia.edu/~brad _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Seriously, when I was building rtcmix~ (which acted as the template for chuck~), I don't think flext was fully-developed. Plus there is some weirdness in the way I do the dynamic loading, not sure about flext compatability (probably is easy). flext does look like a nifty approach, does it work with Xcode yet? There is a PD chuck~ object, as noted in an earlier post. Plus source for all this stuff is on-line, feel free to flext-ize it! brad http://music.columbia.edu/~brad On May 19, 2008, at 5:42 AM, Luigi Rensinghoff wrote:
Hmm
I am mainly a PD User but had a short look into chuck....
For now i cannot grasp the capabilities that a chuck~object brings into max or PD, but i am very interested..
Its a shame you didnt use "flext" (you know it ??)
http://www.parasitaere-kapazitaeten.net/ext/flext/
That way we had a PD-object as well..
Since i am not a programmer i cannot do the port, do you think it is a lot of effort ???
Thanks Luigi
Am 06.12.2007 um 18:10 schrieb garton@columbia.edu:
Quoting Stephen Sinclair
: Some day I'd like to see a standardized shared-memory approach to passing OSC messages, which would be insanely fast on a local machine. (Though, I believe that local loopback sockets are often implemented using shared memory, and are thus pretty much just as fast. Not sure if this is the case in Linux, I've been meaning to look it up for a while)
My preference is to dump OSC entirely, and use some kind of loadable/imbeddable scheme. It would be just fun fun fun to put the entirety of ChucK into a loadable lib of some kind, and then find the entry-points you want from your calling environment and go go go.
This is how [chuck~] works, by the way,
brad http://music.columbia.edu/~brad _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hey chuckers -- I may have missed a few posts, but I think Martin Robinson <mjr at cc.gatech.edu> has a [chuck~] object available for PD. It may make connecting the two apps easier... brad http://music.columbia.edu/~brad
participants (11)
-
Alpha Core
-
Brad Garton
-
dan trueman
-
eduard
-
eduard aylon
-
garton@columbia.edu
-
Kassen
-
Luigi Rensinghoff
-
Martin Ahnelöv
-
Stefan Blixt
-
Stephen Sinclair