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.
· ChucK
· A deep understanding of what sound is, and what frequencies mean
· A deep understanding of programming
· Choose the instrument you would like to model from the instruments that are supported in ChucK
· Choose the frequencies you would like to play, and map your keyboard keys to those frequencies
· Dive in and model your instrument
Sample code
Please note that the code could have been better. Functions could have been created in order to make the code short and more efficient, but this is just a draft that will enable people to understand the basics.
// HID
Hid hi;
HidMsg msg;
// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;
// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;
// patch
BeeThree organ => JCRev r => Echo e => Echo e2 => dac;
r => dac;
// set delays
240::ms => e.max => e.delay;
480::ms => e2.max => e2.delay;
// set gains
.6 => e.gain;
.3 => e2.gain;
.05 => r.mix;
0 => organ.gain;
// infinite event loop
while( true )
{
// wait for event
hi => now;
// get message
while( hi.recv( msg ) )
{
// check
if( msg.isButtonDown() )
{
// Std.mtof( msg.which + 45 ) => float freq;
Std.mtof( msg.which+45) => float freq;
freq $ int => int ifreq;
<<< "Frequency: " + freq + " " + ifreq>>>;
if( ifreq > 20000 ) continue;
.5 => organ.gain;
/******************Third Octave Low*******************/
if (ifreq==349){
131=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==493){
147=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==174){
165=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==369){
175=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==415){
196=>organ.freq;
1 => organ.noteOn;
}
}
else if (ifreq==554){
220 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==440){
247 => organ.freq;
1 => organ.noteOn;
}
/***************Fourth Octave Low*****************/
else if (ifreq==220){
262 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==311){
294 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==329){
330 => organ.freq;
1 => organ.noteOn;
}
/*******************Third Octave High*************/
else if (ifreq==659){
139 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==698){
156 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==783){
185 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==830){
208 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==880){
233 => organ.freq;
1 => organ.noteOn;
}
/*****************Fourth Octave High***************/
else if (ifreq==987){
262 => organ.freq;
1 => organ.noteOn;
}
else if (ifreq==1046){
294 => organ.freq;
1 => organ.noteOn;
}
/*****************Fifth Octave Low******************/
else if (ifreq==587){
523=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==523){
587=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==155){
659=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==466){
698=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==146){
784=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==293){
880=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==277){
988=>organ.freq;
1 => organ.noteOn;
}
/*******************Fifth Octave high***************/
if (ifreq==391){
554=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==164){
622=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==195){
740=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==207){
831=>organ.freq;
1 => organ.noteOn;
}
else if (ifreq==233){
932=>organ.freq;
1 => organ.noteOn;
}
80::ms => now;
}
else
{
0 => organ.noteOff;
}
}
}
Future Work
· In order to make playing easier, removable keyboard covers that enable individuals to know the keys that can be played could be made
· Libraries of different instruments and different pitches could be made too since the computer keyboard cannot have all the keyboard keys
I agree with Lucy on this and I think she's saying (in a rather more organized fashion) some of the things I said in my essay-thing that I posted a few days ago. There is definitely a need for free, easy to learn musical instruments for people who are musically inclined but don't have access to/can't afford musical instruments and education.
ReplyDelete