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.