Hi, again, Core.<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>&nbsp;</div>  <div>&nbsp;</div>  <div>// setting up the keyboard to trigger Osc 
<br>// this should trigger a middle c tone when A key is pressed</div>  <div>{<br>&nbsp;&nbsp;&nbsp; if (<a href="http://msg.is" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">msg.is</a> ButtonDown()) and if (msg.my_keynumber
 = 65 then <br>&nbsp;&nbsp;&nbsp; SinOsc s =&gt; Dac;<br>&nbsp;&nbsp;&nbsp; 261 =&gt; s.freq;<br>&nbsp;&nbsp;&nbsp; 1::second =&gt; now<br>}</div>  <div>&nbsp;</div>  <div>it still giving me errors ? even when i running the <a href="http://kb.ck" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
kb.ck</a> file in chuck any help would be great thanks </div></blockquote><div><br>Well, it&#39;s giving you issues because it&#39;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 &quot;and&quot; here but ChucK will only get it if you write &quot;&amp;&amp;&quot; 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.
<br></div>-----------------------------------8&lt;-------------------------<br>65 =&gt; int mykeynumber; //define what key we are interested in for readability<br>SinOsc s;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Let&#39;s define the oscillator outside of the loop, it will save issues
<br><br><div>{<br>&nbsp;&nbsp;&nbsp; if (<a href="http://msg.is/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">msg.is</a>ButtonDown() ) //detect the type of message<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (msg.which == mykeynumber)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //This bit will only get run if the message is a a button-down one AND it refers to the right button<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Structuring it like this means you can check for other buttons as well in a cleaner way.
<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; s =&gt; dac; //notice &quot;dac&quot; is lowercase, it&#39;s not a Ugen as such.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 261 =&gt; s.freq;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1::second =&gt; now;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s =&lt; dac; //disconnect once we are done
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}</div>  -------------------------------------------------------------<br>That&#39;s how I would rewrite what you wrote. I had to interpret it a bit as I&#39;m not 100% sure what you are after exactly but I think this is fairly close.
<br><br>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;<br><br>----------------8&lt;--------------------<br>else if( msg.which
 == anothernumber) //you&#39;ll need to define this other number, of course<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; s =&gt; dac; <br>&nbsp;&nbsp;&nbsp; 330 =&gt; s.freq;&nbsp; //another key another note. <br>&nbsp;&nbsp;&nbsp; 1::second =&gt; now;<br>
&nbsp;&nbsp; &nbsp; s =&lt; dac; <br>&nbsp;&nbsp;&nbsp; }<br>--------------------------------------------<br><br>This means we only have to check for the message type once which saves CPU and leads to a cleaner program.<br><br>Did you have a look at the keyboard-organ example in the HID dir? That example might be interesting to you too.
<br><br><br>Oh, and don&#39;t worry about getting errors, everybody gets them, it&#39;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.
<br><br>Hope this helps,<br>Happy ChucKing!<br>Kas.<br></div>