Ask me anything

by qianqian hu

“physical and digital”___ waking up alarm sounds!

Responsive Environment Coursework 1.


——“physical and digital”

The brief I choose is”physical and digital”. What I want to do with this brief is create an alarm clock which people could record and share there creative alarm sound to wake others and themselves up in the morning.

People are always getting familiar and familiar with their alarm sound, and will do the subconscious reflection to the alarm clock—-turn it off and keep on sleeping. If they will never know what kind of sound will wake them up at the next day’s morning, and every morning the user will have an expectation of the alarm sound, this would be a great way for people to be clear-headed immediately. And it will be hard to make people getting bored of this, because everyday could be new.

The Original Idea


The first time I talked about my idea in tutorial, I got no concept about what kind of things arduino can do. The only thing I know is the way I was dreaming to solve my waking-up problem probably could be treated as a kind of responsive environment thing, which is people can share there alarm sounds. And about the sharing inspiration was get from a video that things are shared in pen drive.

http://www.youtube.com/watch?v=hwohadcUv4A

And the wish was hopefully everybody could get an/lots of excited alarm sound which could wake them up everyday on time. After talk to Tom twice, I realized what kind of role arduino will play in my waking-up idea, also it brings another big problem to me, which is I also do not know much about processing. But this time they two need to create a cooperation.

Realizing process

The first thing I know about how to realize them is I need the final product could record sound from people which is my most important interaction part, also be my reason of the brief I choose —’ physical and digital ‘. And play the sound, and which sound would be play is depend on the twist controller. The record sound one can be easily get from the processing libraries. The first one I picked was RecordLineIn, but after played with my classmates through using this one, a problem happened. Everybody who played with my recording processing they all want to check their sounds, but go to the very deep folder to find the final voice is really a complex thing. So, after check the libraries again, I found another similar code which could play the sound back immediately. And all of the player become happy to hear their sound immediately then they can decide keep this sound or delete easily.

Then, I need to finish the twist controller. It is easy to get the circuit from Fritzing. However, the most similar one to what I am going to do about the twist controller is using controller to control the color, this is already very close to what I need. But the identification of different audio players are really complicated. The only thing I can do is following the reason of the error it gives to me. For this part, it is really a long story. I’ve changed my code around 50 times, and the final result I’ve got is “player1 = player1” which really shocked me when I get this after play with processing for about more than a hour. Finally, I learned how to name different words, such as ’ player ‘, or ’ tune ‘, and I am pretty sure, no matter I need to give anything a meaning, I would done that in a minute just through my hundreds of mistakes.

The next thing I have to consider was the way people listen to the alarm and how can they turn it off. The alarm is supposed to be triggered by the clock when it arrives at the settled time. And people can turn it off, however because of the sound would be interesting or attractive for people, finally I decided to change the code from ’ stop ’ to ’ pause ’ to make sure if people want to listen them all, they do not need to listen the long time sound they have already heard before. This clock could not give people any chance to get bored of it. But it is not suppose to give the chance to people to listen the sound twice once. It will also keep their interest or fresh feelings of the alarm sound. One day, they may turn the twist controller on the same sound again.

Then, it is not necessary for me to get the control of the twist controller’s angle. But in order to add more sounds like a thousand into the system, I have to get a knowledge about the principal of how twist controller chose the sounds. If the controller could spin for 180, then 180 = 1024, which can be read in computer. If the controller could spin for 270, then 270 = 1024. Through this way, I can add as much sounds as I want into the system.

Till now, they are working separately. Recording sound first and people can hear the sound immediately through processing1, and put the sound into the processing2 folder which is data of the prepared alarm sounds. Finally, use arduino to switch to the unknown sound. Play and pause. These are all my works working now. But they are suppose to be in a linking which do not need me to copy the sound and paste into the data folder.

Future development

A website would be the final stage for people sharing their own alarm sound. People can not here the sound totally, but all the sound be upload on would be add tags and put into different groups, like ” encouragement”,” excited music”,”from moms”,” Your money have something to tell you”,or even could be weather forecast or system chose for you randomly. These are all depend on how creative the users are.

Then people can download them into there own alarm clock. The clock will have the usb link to computer. People can upload the sounds anytime.

Reference:

http://circadianrhythmsleepdisorder.info/category/sleep-phase-chronotherapy/

http://valleysleepcenter.com/blog/p79/

http://www.youtube.com/watch?v=hwohadcUv4A

See more practice of mine with Processing and Arduino, check my Responsive Environment page:

http://qianqianresponsiveenvironments.tumblr.com

1 year ago
0 notes

Finally it worked!!! I also made a box for it. but it not very fancy actually. my arduino seems not like the box, every time it been put into the box, the system would be in chaos….

1 year ago
0 notes

I was thinking it couldn’t be this hard!!!! God!!!! I linked the circuit, and start to do something now. but it seems these codes don’t know me, and I don’t know them at all as well…..

1 year ago
0 notes
the simple and only circuit of my work.

the simple and only circuit of my work.

1 year ago
0 notes

The final codes.

processing final play part:


import processing.serial.*;

import ddf.minim.*;

AudioPlayer player1;

AudioPlayer player2;

AudioPlayer player3;

AudioPlayer player4;

AudioPlayer player5;

AudioPlayer tune;

Minim minim;

AudioInput in;

Serial myPort;

int val;

boolean buttonPress;

int counter = 0;

void setup()

{

 size(250,250);

 textMode(SCREEN);

 minim = new Minim(this);

 println(Serial.list());

 String portName = Serial.list()[0];

 myPort = new Serial(this, portName, 9600); 

 minim = new Minim(this);

 player1 = minim.loadFile(“alarm 1.wav”, 2048);

 player2 = minim.loadFile(“alarm 2.mp3”, 2048);

 player3 = minim.loadFile(“alarm 3.mp3”, 2048);

 player4 = minim.loadFile(“alarm 4.wav”, 2048);

 //player5 = minim.loadFile(“alarm 5.mp3”, 2048);

}

void draw()

{

  background(0);

 if( myPort.available() > 0){

  val = myPort.read();

 } 

 println(val);

 background(500);

 if(val == 0){

   tune = player1;

 }

 else if(val == 1){

  tune = player2; 

 }

 else if(val == 2){

  tune = player3; 

 }

 else if(val == 3){

  tune = player4;

  counter = 0; 

 }

 if(key == ‘a’){

  tune.play(); 

 }

 else{

  tune.pause(); 

 }

 rect(50, 50, 100, 100);

}

Processing record part


/**

  * This sketch demonstrates how to an <code>AudioRecorder</code> to record audio to disk and then immediately 

  * play it back by creating a new <code>AudioPlayer</code> for the <code>AudioRecording</code> returned by <code>save</code>. 

  * To use this sketch you need to have something plugged into the line-in on your computer. Press ‘r’ to toggle 

  * recording on and off and the press ‘s’ to save to disk. The recorded file will be placed in the data folder of 

  * the sketch.

  */

import ddf.minim.*;

Minim minim;

AudioInput in;

AudioRecorder recorder;

AudioPlayer player;

void setup()

{

  size(512, 200, P3D);

  textMode(SCREEN);  

  minim = new Minim(this);

  recorder = minim.createRecorder(in, “myrecording.wav”, true);

  player = minim.loadFile(“myrecording.wav”, 2048);

  player.play();

  textFont(createFont(“Arial”, 12));

}

void draw()

{

  background(0); 

  stroke(255);

  for(int i = 0; i < in.left.size()-1; i++)

  {

    line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);

    line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);

  }

  if ( recorder.isRecording() )

  {

    text(“Now recording…”, 5, 15);

  }

  else

  {

    text(“Not recording.”, 5, 15);

  }

}

void keyReleased()

{

  if ( key == ‘r’ ) 

  {

    if ( recorder.isRecording() ) 

    {

      recorder.endRecord();

    }

    else 

    {

      recorder.beginRecord();

    }

  }

  if ( key == ‘o’ )

  {

    player.play();

  }

  if ( key == ‘s’ )

  {

    if ( player != null )

    {

        player.close();

    }

    player = recorder.save();

    player.play();

  }

}

void stop()

{

  in.close();

  if ( player != null )

  {

    player.close();

  }

  minim.stop();

  super.stop();

}

Arduino part

int switchPin = A0;

int sensorValue = 0;

void setup(){

 // pinMode(switchPin, INPUT);

Serial.begin(9600); 

}

void loop(){

  sensorValue = analogRead(switchPin);

  //Serial.println(sensorValue, 0);

  if(sensorValue == 0){

   Serial.print(0,0); 

  }

  else if(sensorValue >= 100 && sensorValue <= 200){

    Serial.print(1,0);

  }

  else if(sensorValue >= 201 && sensorValue <= 400){

    Serial.print(2,0);

  }

  else if(sensorValue >= 401 && sensorValue <= 600){

    Serial.print(3,0);

  }

  delay(100);

}

1 year ago
0 notes

Yesterday asked Adrew for help, Big thanks!!! This time I understand how the twist controller works, 1024, and I can give any section between 0-1024 a meaning in arduino. That’s really make sence for me. But when I link them together, the disaster happened again. and emailed andrew again. For how I made the mistake, it’s really a long story. I will introduce my mistake later. :/ I will never feel embarrassing to introduce my mistake lol!

1 year ago
0 notes

First important step: the circuit is working!!!

(Source: youtube.com)

1 year ago
0 notes

I am recording these codes. although they are still not right. but I can handle it!!!

(Source: youtube.com)

1 year ago
0 notes

I remember there’s a pratical class which I’ve learned how to connect twist controller with processing, but this one is for changing the color. so I still have a long way to go.

1 year ago
0 notes