2010年3月7日星期日

Final Project-Sound


After Clay's successful experiment with Christmas tree light board switches. I've written Max patch for the "keyboard" of our instrument.

Here is how the maxpatch looks like. It will interperate each trigger to a unique serial of pitches output in a certain interval and spacial position over time.

2010年2月28日星期日

Simple example-Arduino playback module

After discoraged by carelessly burned one SD card in the Waveshield, I became more precise when trying to link two pins together. Once pin connection can be fixed, programming for Arduino can be interesting.

Here's the program I've modified for playback different sound sample based on any switches that can connect analog-in0 and gnd.

#include
#include
#include
#include "WaveUtil.h"
#include "WaveHC.h"

#define SWITCH_PIN 14

SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the filesystem on the card

uint8_t dirLevel; // indent level for file/dir names (for prettyprinting)
dir_t dirBuf; // buffer for directory reads

WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time

// Function definitions (we define them here, but the code is below)
void lsR(FatReader &d);
void play(FatReader &dir);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps for debugging

putstring_nl("\nWave test!"); // say we woke up!

putstring("Free RAM: "); // This can help with debugging, running out of RAM is bad
Serial.println(freeRam());

// Set the output pins for the DAC control. This pins are defined in the library
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);

/*add by Iris*/
// pin13 LED
pinMode(13, OUTPUT);
// enable pull-up resistors on switch pins (analog inputs)
digitalWrite(SWITCH_PIN, HIGH);
/*end*/

// if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
if (!card.init()) { //play with 8 MHz spi (default faster!)
putstring_nl("Card init. failed!"); // Something went wrong, lets print out why
sdErrorCheck();
while(1); // then 'halt' - do nothing!
}

// enable optimize read - some cards may timeout. Disable if you're having problems
card.partialBlockRead(true);

// Now we will look for a FAT partition!
uint8_t part;
for (part = 0; part < 5; part++) { // we have up to 5 slots to look in
if (vol.init(card, part))
break; // we found one, lets bail
}
if (part == 5) { // if we ended up not finding one :(
putstring_nl("No valid FAT partition!");
sdErrorCheck(); // Something went wrong, lets print out why
while(1); // then 'halt' - do nothing!
}

// Lets tell the user about what we found
putstring("Using partition ");
Serial.print(part, DEC);
putstring(", type is FAT");
Serial.println(vol.fatType(),DEC); // FAT16 or FAT32?

// Try to open the root directory
if (!root.openRoot(vol)) {
putstring_nl("Can't open root dir!"); // Something went wrong,
while(1); // then 'halt' - do nothing!
}

// Whew! We got past the tough parts.
putstring_nl("Files found:");
dirLevel = 0;
// Print out all of the files in all the directories.
lsR(root);
}


//////////////////////////////////// LOOP
void loop() {
root.rewind();
play(root);
}

/////////////////////////////////// HELPERS

// this handy function will return the number of bytes currently free in RAM, great for debugging!
int freeRam(void)
{
extern int __bss_end;
extern int *__brkval;
int free_memory;
if((int)__brkval == 0) {
free_memory = ((int)&free_memory) - ((int)&__bss_end);
}
else {
free_memory = ((int)&free_memory) - ((int)__brkval);
}
return free_memory;
}

/*
* print error message and halt if SD I/O error, great for debugging!
*/
void sdErrorCheck(void)
{
if (!card.errorCode()) return;
putstring("\n\rSD I/O error: ");
Serial.print(card.errorCode(), HEX);
putstring(", ");
Serial.println(card.errorData(), HEX);
while(1);
}
/*
* print dir_t name field. The output is 8.3 format, so like SOUND.WAV or FILENAME.DAT
*/
void printName(dir_t &dir)
{
for (uint8_t i = 0; i < 11; i++) { // 8.3 format has 8+3 = 11 letters in it
if (dir.name[i] == ' ')
continue; // dont print any spaces in the name
if (i == 8)
Serial.print('.'); // after the 8th letter, place a dot
Serial.print(dir.name[i]); // print the n'th digit
}
if (DIR_IS_SUBDIR(dir))
Serial.print('/'); // directories get a / at the end
}
/*
* list recursively - possible stack overflow if subdirectories too nested
*/
void lsR(FatReader &d)
{
int8_t r; // indicates the level of recursion

while ((r = d.readDir(dirBuf)) > 0) { // read the next file in the directory
// skip subdirs . and ..
if (dirBuf.name[0] == '.')
continue;

for (uint8_t i = 0; i < dirLevel; i++)
Serial.print(' '); // this is for prettyprinting, put spaces in front
printName(dirBuf); // print the name of the file we just found
Serial.println(); // and a new line

if (DIR_IS_SUBDIR(dirBuf)) { // we will recurse on any direcory
FatReader s; // make a new directory object to hold information
dirLevel += 2; // indent 2 spaces for future prints
if (s.open(vol, dirBuf))
lsR(s); // list all the files in this directory now!
dirLevel -=2; // remove the extra indentation
}
}
sdErrorCheck(); // are we doign OK?
}

/*add by Iris*/
bool read_switch()
{
return digitalRead(SWITCH_PIN);
}
/*end*/

/*
* play recursively - possible stack overflow if subdirectories too nested
*/
void play(FatReader &dir)
{
FatReader file;
while (dir.readDir(dirBuf) > 0) { // Read every file in the directory one at a time
// skip . and .. directories
if (dirBuf.name[0] == '.')
continue;

Serial.println(); // clear out a new line

for (uint8_t i = 0; i < dirLevel; i++)
Serial.print(' '); // this is for prettyprinting, put spaces in front

if (!file.open(vol, dirBuf)) { // open the file in the directory
Serial.println("file.open failed"); // something went wrong :(
while(1); // halt
}

if (file.isDir()) { // check if we opened a new directory
putstring("Subdir: ");
printName(dirBuf);
dirLevel += 2; // add more spaces
// play files in subdirectory
play(file); // recursive!
dirLevel -= 2;
}
else {
// Aha! we found a file that isnt a directory
/*add by Iris*/
/*sleep until switch pressed, low */
while(read_switch()) delay(10);
/*end*/

putstring("Playing "); printName(dirBuf); // print it out
if (!wave.create(file)) { // Figure out, is it a WAV proper?
putstring(" Not a valid WAV"); // ok skip it
} else {
Serial.println(); // Hooray it IS a WAV proper!
wave.play(); // make some noise!

while (wave.isplaying) { // playing occurs in interrupts, so we print dots in realtime
putstring(".");
delay(100);
/*add by Iris*/
if(read_switch())
{
wave.stop();
break;
}
/*en*/
}

sdErrorCheck(); // everything OK?
// if (wave.errors)Serial.println(wave.errors); // wave decoding errors
}
}
}
}

2010年2月22日星期一

Final Project Ideas

Our goal for the final project is to build a interactive instrument which can switch between different sound timbres and background environment sound texture responding to human body gesture interacting with LED light sensors.

We will be constructing a musical instrument interface to send data and control parameters to MaxMSP/Jitter which will actually create the music. Our controller ideas data flow are influenced by Kevin Patton and Carmon Montoya's workshop but hopefully will expand upon that making a system, that if you chose to and had the skill, you could play traditional familiar music with scales, notes, chords and such.

For the sound part, once Max receive a trigger from each individual LED light sensor. It will generate different banks of sound as well as background sound texture using MAX/MSP/Jitter. some specific object such as mono reverb and different types of filters which will be external max objects will be applied for the sound effects. Further more, once we are able to control the sensor confidently, we will try to create a piece based on human body gesture which can be interpret in to music sequenced in Logic.

The controller itself will be a freestanding battery controlled wireless arduino based device but using a gyroscope in addition to an accelerometer to more accurately track movement and allowing us to capture yaw (spin around a y axis) data which an accelerometer alone cannot do. Furthermore logic to decipher movement will be placed on the arduino chip making it a more universal controller. For example not only will 3 axis rotation data be available but imagine playing air drums that alter the instrument and or note to be triggered depending on the angle the controller is at when the initial strike starts. The controller itself will have some traditional button like inputs for finger input control except they will be pressure sensors allowing us a range of data depending on how hard we 'chord' the input. This aspect may be very similar to Kevin and Carmen's fossile input - I'm not exactly sure how there device worked.

Time and resource and technology permitting we will investigate other non-traditional forms of electronic input - specifically proximity detection through capacitive circuits like like a theremin but using ordinary Christmas tree lights.


Sources:

http://www.imagineeringezine.com/e-zine/capacitance-11.html
http://www.discovercircuits.com/C/capacitance-sw.htm
http://www.discovercircuits.com/DJ-Circuits/3vtchmom2.htm
http://users.otenet.gr/~athsam/touch_dimmer.htm
http://www.epanorama.net/links/lights.html#dimrouch fun sight to get lost on
http://www.akustische-kunst.org/maxmsp/
http://web.media.mit.edu/~tristan/maxmsp.html

2010年2月17日星期三

Box Building--Making Sound


After one week's box making, we are ready to install Sound into the box.
Here is how we make sound with Arduino and Wave shield.

First,
Solder 32 Analog and Digital I/O and Analog In. Join the two board together.

Second,
Setup the speaker, arduino and Computer. Download wavehc20091219 as an example. Load audio files to SD card.(FAT16, audio file name should be less than 8 characters)

Third,
Load libraries to Arduino.
Go to Arduino>Preference>sketchbook location:
/Users/Documents/Arduino
If you don't have a file called libraries, create a new file called libraries, copy and paste the whole folder "WaveHC" into the libraries.

Four,
Choose a test example. compile and upload to the boards. Then you should be able to hear the music playing through the speaker.

2010年1月20日星期三

Modification for Solar Kit

It might be simple for everyone else in this class about this assignment... But after I've tried several attempts, I realize that I've became a total digital/software girl...who is really bad at handcrafting or idea realization in hardware.... but here's what I have so far...



First I've thought of converting it to sound-- Music box might be a good model. But in reality, th small music box seems very tiny, it needs more than 6V power supply to start the engine.

Then I've been thinking of a mini Fan that we use during the summer, but it act like it still need more than 0.8 V for the power supply..

Eventually, I have to use the "box" from the music box and the fan from the mini fan, to create my own “竹蜻蜓”.

2010年1月13日星期三

Solar Energy

In search of the meaning of ABSTRACT, Proceeding from “Modern”, Analogous arrangement is not purely enough for him to express. “Though I had heard the word ’modern’ before, I did not consciously know or feel the term ’abstract’ so now, at thirty-two, I wanted to paint and work in the abstract.”

In my aspect, abstract can happen in all level of cognition: we need three stages for sound to travel; two additional condition to meet for sound to exists in human being’s world ; more than 20 tissues for sound wave energy to pass on and finally across the magical transducer in our body to change it to nerve impulse -finally give us a stimulation for the brain to give it a response based on our personal experience and “knowing” to image the type of energy. There could be thousands of possibilities of abstract – waiting for us to explore.

In other word, Technology has crudely crunched down the analog world to digital world. Although people are busy working on describing all the in between world, digital world already give us the direction: the interpretation of what people can access the other world is the source of our inspiration. 1980’s alternative is only one tiny possibility that has been exploded.