Showing posts with label class ideas. Show all posts
Showing posts with label class ideas. Show all posts

Wednesday, June 27, 2012

A mapping to the keyboard tutorial

// not a full "lab" per se but it does have the possibility to be developed into one. This is based on my experience working with the KIns.

To get ChucK working with the keyboard, there are a few essential things to include in your code:

1.
// keyboard
HidIn kb;
// hid message
HidMsg msg;

In the above code, "Hid" stands for "Human Interface (possibly also input?) Device." AKA a device that you use to interact with your computer, like the keyboard. The first line defines the variable that will represent the HID, and the second defines the variable that will hold the information we receive from the HID.

2. 
// If the keyboard is not available, just exit the program right away
if( !kb.openKeyboard( 0 ) ) me.exit();
//Otherwise, assuming the program didn't exit on the last line, keep going
<<< "Ready?", "" >>>;

These lines are not critical, but helpful to include in a file, especially for debugging purposes. Obviously you can change them around to suit your tastes, such as only printing out a message if the keyboard *doesn't* open instead of if it does.

3.
// wait for event
    kb => now;

The above lines go inside the event loop, which is the (usually infinite) loop that makes the program run. They'll probably be the first thing inside the loop, unless your program has a reason for them not to be. Basically they pause the loop until the HID has a message to send.

4.
kb.recv( msg )

When this function returns true, a key is being held down. It's probably best used in a while loop or if statement, such as while( kb.recv( msg ) ){....} That will execute the body of the loop as long as a key is being held down.

5. msg.which

The value of this variable contains an int that corresponds to the key that's being held down. Operators like ==, >, <, != can be used to work with it to assign different actions to different keys.


These are the most important things to understand when working with keyboard input. Using them, you can construct an array of values of the keys on your keyboard that correspond to meaningful values. For example, to make a program that plays notes when the keyboard is pressed, you could make an array in which the index of the array is the frequency of the note, and the data that corresponds to any given index is the key mapping integer.

How can we find out the key mapping integers if we don't know them or have a reference though? An easy, if tedious, way to do it is to simply print out msg.which whenever a keypress event is received. You can then write your own table by going through each key on your keyboard.

Wednesday, June 6, 2012

Possible lab: Audio effects in Audacity

Here's a rough idea for a lab for students to do. Not sure where it would fit in the curriculum, but it could hopefully be adjusted to fit somewhere.

1. Open Audacity. If you're using a desktop computer in a lab, it likely has it installed already. Otherwise, if it's not installed on your own computer, download it from http://audacity.sourceforge.net/download/

Tuesday, June 5, 2012

Changing the Face of Music: making your keyboard a musical instrument


Changing the Face of Music: Making your keyboard a musical instrument

             I view research as a process of examining society’s problems, and then look for ways to provide solutions for those problems. Research to me is never purposeless, but it always has an intrinsic goal to serve. After working on ChucK for the past few days and discovering how one can turn a computer keyboard into a musical instrument, I realized how this technique could be used to meet societal needs. Being an international student from a developing nation living in a developed nation now, I have a deep understanding of problems that could be in both developing and developed nations, and I continually realize that financial problems are not just a curse for developing nations—they exist in developed nations as well. Because many families and institutions barely make ends meet, musical instruments become luxuries to many. Many kids may even grow up without much knowledge of music, yet they are gifted and could do great in the field. As a way to curb problems of access to musical instruments, I thought it would be great if we could turn our keyboards into musical instruments. Instead of complaining about lack of money, we can enjoy the best of both worlds—our computers and the music. Even if the keyboard instruments may be so different from the real instruments, sparking an interest in any person about something may make it easier for that person to learn the real thing when exposed to it. Besides, this is a generation where people are doing things they have never done before, and breaking new ground, so this could be a dawn of a new era in music.
            There are also a bunch of other people who might not have garage band and other applications that play musical instruments on their computers, yet they love music, but they just cannot get off their computers to play an instrument, or the do not own an instrument. Such people could also benefit from the musical instrument models in ChucK.

What you need to turn your keyboard into a musical instrument

MONKEYING AROUND

STANFORD FINAL PROJECTS
Check this main page and scroll to Final Projects for Fall 2009, 2010, and 2011


FINAL PROJECT - SoVND
This uses neural activity from a monkey experiencing stimuli to create music.

SUGGESTION BOX - Exercises

EXERCISE:  Ask students to choose a particular app like Songify, Broadlands, Ocarina, Beatstream, MoMu, MoPho, Glee Karaoke, VoiceJam, MagicPiano, MagicFiddleSmule, I am T-Pain, LaDiDa or company like Smule, that allows users to create their own digital sounds and music, individually or collectively through social media.

EXERCISE:  Examples for beginning exercises are in Chapter 6 of Ge Wang's thesis.  Create a percussive arrangement.  Run code examples provided and modify parameters, create two programs to generate one rhythmic and one non-rhythmic arrangement.  pg. 127 Thesis

EXERCISE:  Build soundscapes. pg. 129 Thesis by Ge Wang

Wednesday, May 30, 2012

Lab Idea 1: Intro to ChucK for Non-Programmers

Here's an idea for a lab for a class to do. It doesn't assume anything beyond a basic knowledge of how computers work and attempts to explain the basics of ChucK to someone who's never programmed before, while hopefully also giving some ideas for more advanced students to explore. Content is below the jump.