SHARE
TWEET

DTMF Encoder

a guest Nov 18th, 2014 199 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // started from a ChucK example
  2. // modified by Les Hall
  3. // beginningTue Nov 18 2014
  4. //
  5.  
  6.  
  7. SinOsc colOsc => Gain sum => dac;
  8. SinOsc rowOsc => sum;
  9. 0 => sum.gain;
  10.  
  11. [1209, 1336, 1477, 1633] @=> int colFreqs[];
  12. [697, 770, 852, 941] @=> int rowFreqs[];
  13.  
  14.  
  15.  
  16. // create our OSC receiver
  17. OscRecv recv;
  18. // use port 6449 (or whatever)
  19. 11000 => recv.port;
  20. // start listening (launch thread)
  21. recv.listen();
  22.  
  23. // create an address in the receiver, store in new variable
  24. recv.event( "/gyrosc/button, i i" ) @=> OscEvent @ oe;
  25.  
  26. // infinite event loop
  27. while( true )
  28. {
  29.     // wait for event to arrive
  30.     oe => now;
  31.    
  32.     // grab the next message from the queue.
  33.     while( oe.nextMsg() )
  34.     {
  35.         oe.getInt() => int buttonNum;
  36.         oe.getInt() => int buttonPos;
  37.         <<< "got (via OSC):", buttonNum, buttonPos >>>;
  38.        
  39.         rowFreqs[buttonNum%3] => rowOsc.freq;
  40.         colFreqs[buttonNum/3] => colOsc.freq;
  41.         1 => sum.gain;
  42.         250::ms => now;
  43.         0 => sum.gain;
  44.     }
  45. }
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top