electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
playable ChucK Instruments
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [2 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
tommy2caps



Joined: Jul 19, 2014
Posts: 1
Location: USA

PostPosted: Sat Jul 19, 2014 1:52 pm    Post subject: playable ChucK Instruments
Subject description: Is it possible to create an instrument in chuck that can be played with the keyboard as an interface
Reply with quote  Mark this post and the followings unread

Hi, I am very new to chuck but incredibly interested by it. I have no experience with code so if this is hard to understand i apologize. I am trying to build an instrument that can be played by hitting notes on the keyboard for example as long as I hold the 'A' key an a 440will sound. is this possible/already exists? please help.
thanks
tom
Back to top
View user's profile Send private message
jkant



Joined: Dec 14, 2013
Posts: 14
Location: Milan, Italy

PostPosted: Tue Sep 16, 2014 6:21 am    Post subject: Reply with quote  Mark this post and the followings unread

Welcome to the wonderful world of chucK! Smile

You can use human interface device aka hid.

Try to add this shred:

Code:

// human interface device
Hid hid;
// a message to convey data from Hid
HidMsg msg;

// device number
0 => int device;

// try to open keyboard
if (hid.openKeyboard( device ) == false ) me.exit();

<<< "keyboard:", hid.name(), "ready!" >>>;

// sound chain
BeeThree organ => JCRev reverb => dac;
// set params
.05 => reverb.mix;

while(1)
{
    // wait for event
    hid => now;
   
    // get message
    while( hid.recv( msg ))
    {
        // check
        if (msg.isButtonDown() )
        {
            <<< "BUTTON DOWN:", msg.ascii >>>;
           
            // take ascii value and convert to frequency
            msg.ascii => Std.mtof => float freq;
            // if too high then skip
            if( freq > 20000 ) continue;
           
            // set freq
            freq => organ.freq;
            // sound the note
            1 => organ.noteOn;
           
            80::ms => now;
        }
        else // should be a button up event
        {
            <<< "BUTTON UP:", msg.ascii >>>;
            1 => organ.noteOff;
        }
    }
}

_________________
Random Bitz
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [2 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use