Assignment 7: Sound with Meaning

To develop ‘sound with meaning,’ I wrote a sketch using the tone() function to replicate the ‘wah wah wah’ trombone sound. Sketch and video below.

 

void setup() {

  tone(7, 293.66, 1000);
  delay(1000);
  noTone(7);
  delay(500);
  tone(7,277.18,1000);
  delay(1000);
  noTone(7);
  delay(500);
  tone(7,261.63,1000);
  delay(1000);
  noTone(7);
  delay(500);
  tone(7,246.94,3000);
  delay(1500);
  noTone(7);
  delay(3000);
}

void loop() {


}

 

I had a 60 hertz hum with the original power supply I used the first time around. Switching to another power reduced the issue, but it’s still there.

Resources

More background on the Teensy audio library and MQS:

https://melp242.blogspot.com/2020/10/audio-output-on-teensy-4x-boards.html

Note frequencies:

https://pages.mtu.edu/~suits/notefreqs.html

Assignment 7: Sound that has meaning

Description:

This project was meant to convey emotions through sound by playing a song corresponding to the user’s emotions when a button is pressed. Currently there are only 3 buttons for 3 different sounds/songs but the idea is to be able to hook up more and more as songs stick out as conveying your emotions. The main components for this build are buttons, resistors, a speaker and amplifier, and the Teensy 4.1. When each button is pressed, a certain song corresponding to a different emotion will start to play through. When the song is over, it waits for the next button to be pressed and does not repeat the current sound. When each button is pressed, the current song being played will stop playing and switch to the next song corresponding to the button press. As of now, button 0 plays the Jaws intense sound that signifies a stress and anxiety. Button 1 plays an African Safari game sound that signifies being happy and adventurous. Button 2 plays a relaxing song to convey peace and relaxation.

Video:

Demo Video

Images:

Code:

/*
 * Assignment 7: Sound with Meaning
 * Judson Kyle
 * judsonk
 * 
 * Description: This sketch plays a sound corresponding to the users mood at the
 *              time. Depending on the button pressed, a sound corresponding to
 *              one of three emotions will play. These emotions are intense/stressed,
 *              happy/upbeat, and peaceful/relaxed corresponding to buttons 0, 1,
 *              and 2 respectively. Each sound will only play once through to the
 *              end and not repeat after that.
 */

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioPlaySdWav           playWav1;
AudioMixer4              mixer1;         //xy=647,408
AudioOutputMQS           mqs1;           //xy=625,279
AudioConnection          patchCord1(playWav1, 0, mqs1, 0);
AudioConnection          patchCord2(playWav1, 1, mqs1, 1);

#define SDCARD_CS_PIN    BUILTIN_SDCARD
#define SDCARD_MOSI_PIN  11  // not actually used
#define SDCARD_SCK_PIN   13  // not actually used

#define SWITCH0   33
#define SWITCH1   34
#define SWITCH2   35
#define SWITCH3   37
#define SWITCH4   38
#define SWITCH5   39

#define BUTTON0   16
#define BUTTON1   17
#define BUTTON2   18

unsigned long currTime = 0;
unsigned long debounceTime = 0;
volatile unsigned long startTime = 0;

volatile bool DEBOUNCE = false;

int numButtons = 3;

volatile int state = 0;

const char* currFileName = "Shark Attack Shortened.WAV";

void setup(void)
{
  // Wait for at least 3 seconds for the USB serial connection
  Serial.begin (9600);

  AudioMemory(8);

  pinMode(SWITCH0, INPUT);
  pinMode(SWITCH1, INPUT);
  pinMode(SWITCH2, INPUT);
  pinMode(SWITCH3, INPUT);
  pinMode(SWITCH4, INPUT);
  pinMode(SWITCH5, INPUT);

  attachInterrupt(digitalPinToInterrupt(BUTTON0), button0Pressed, CHANGE);
  attachInterrupt(digitalPinToInterrupt(BUTTON1), button1Pressed, CHANGE);
  attachInterrupt(digitalPinToInterrupt(BUTTON2), button2Pressed, CHANGE);

  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    // stop here, but print a message repetitively
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }

}

void loop (void)
{
  currTime = millis();
  static int prevState = 0;

  if (prevState != state) {
    if (playWav1.isPlaying()) {
      playWav1.stop();
    }
    switch (state) {
      case 0: //Play intense sound
        currFileName = "Shark Attack Shortened.WAV";
        playWav1.play(currFileName);
        printPlayState(currFileName);
        delay(5);
        break;
      case 1: //Play fun/upbeat sound
        currFileName = "African_fun_long.WAV";
        playWav1.play(currFileName);
        printPlayState(currFileName);
        delay(5);
        break;
      case 2: //Play peaceful sound
        currFileName = "With-You-in-My-Arms-SSJ011001.WAV";
        playWav1.play(currFileName);
        printPlayState(currFileName);
        delay(5);
        break;
    }
  }
  prevState = state;
  
  //Update debounce state
  DEBOUNCE = abs(currTime - startTime) < debounceTime;
}

//Button 0 interrupt function
void button0Pressed() {
  if ((digitalRead(BUTTON0) < 1) && !DEBOUNCE) {
    state = 0;
    startTime = currTime;
    DEBOUNCE = true;
  }
}

//Button 1 interrupt function
void button1Pressed() {
  if ((digitalRead(BUTTON1) < 1) && !DEBOUNCE) {
    state = 1;
    startTime = currTime;
    DEBOUNCE = true;
  }
}

//Button 2 interrupt function
void button2Pressed() {
  if ((digitalRead(BUTTON2) < 1) && !DEBOUNCE) {
    state = 2;
    startTime = currTime;
    DEBOUNCE = true;
  }
}

//Print out the current cong being played or return an error message if the song isn't being played
void printPlayState(const char* fileName) {
  if (!playWav1.isPlaying()) {
    Serial.print("Error playing: ");
    Serial.println(fileName);
    delay(5);
  }
  else {
    Serial.print("Playing: ");
    Serial.println(fileName);
    delay(5);
  }
}

Electrical Schematic:

Assignment 7: Sound with Meaning – James Kyle

Concept:

For my sound with meaning, I tried to recreate the jaws “duuuuuuuuuh…duh” tune on an interrupt as an indication that someone is approaching. I tried creating my own tune using the tone() function and playing F1 for 1 second and then and F1# for a quarter second but it wasn’t realistic enough for me. I ended up using an SD card loaded with some ambient noise and a clip from the Jaws theme song to indicate the states of the device. When the button is pressed, it triggers the Jaws snippet and then goes back to ambient noise once the tune is finished.

Demo Video:

Circuit Diagram:

Woes:

I faced a lot of issues getting the sound to play from the amplifier and here are some things I learned. First and foremost, the amplifier needs to be tuned to the correct volume so that you can clearly hear you sound. When it wasn’t tuned correctly, I would get a lot of static or muffled versions of the sound I was trying to play. I also ran into the problem of playing the tunes too fast which gave me a beeping machine error type f sound. From experimenting with the circuit and code a little, I have pinned this problem down to playing tunes too fast in succession (not waiting for the tunes to finish before playing it again).

 

Sound Crit

Generate sounds related to an environment that make the environment easier to use for people who might not have good data parsing, sight, or physical capabilities.

These can be mechanical sounds made with solenoids, motors, or fans; or sounds created from within the Teensy.

For amplifying sounds sent to speakers there is also the option of using a power transistor the same way you’d power a large motor.

 

Class Notes, 24 Mar 2022

perception differences based on genetics.  Look at how people with various types of color blindness see the world:

https://www.color-blindness.com/coblis-color-blindness-simulator/

How sound effects are used in music:

MIA, this is the song I heard while we were waiting on a concert to let in.  I couldn’t hear the music but I could hear the FX:

Kraftwerk using samples of bicycles in Tour de France:

There’s also a link to genre conflation in MIA’s work.  She’s not from an American city where she grew up with hip-hop, she found a lot of different genres of music she liked and tied them all together.  Here’s a video shot in Morocco of Saudis (and others) drifting and marching in the street:

Why are these machines so quiet?  Why doesn’t it sound like a Chuck E Cheese or an arcade?

A mapping of pitches to frequencies https://pages.mtu.edu/~suits/notefreqs.html

It’s easy to create sounds without speakers:

Start looking at wider range of interaction with sites like Buxton’s collection of interaction design devices:

https://www.microsoft.com/buxtoncollection/browse.aspx

 

Class Notes, 22 Mar 2022

Genre Conflation

This is a counter to sampling and using electronics to invent new music.  Instruments from one style of music are used to perform a style of music from a completely unrelated genre.  My favorite examples are “pirate metal” or the band Orkestra Obsolete playing famous pop music.

Another take on this is how Kraftwerk inspired so many artist in other genres.  Probably the most influential is a sample from “Trans Europe Express” used by Africa Bambatta as the base melody for “Planet Rock“.

I’m skipping EDM, IDM, dub, liquid trap, future soul, and so many types of music.  Again, there’s an entire class in this topic, but Ishkur’s Guide is one place to start exploring the genealogy of music: http://music.ishkur.com/

From the earliest days of theater, foley artists have made a wide variety of sounds by hand (or foot):  https://www.youtube.com/watch?v=UO3N_PRIgX0

Mini-assignment:  What sounds would you add to your house to make it more accessible?

 

Beats Headphones Noises – James Kyle

When pairing and unpairing my headphones, I noticed that it plays a little jingle that ends on a high note when paired and a low note when unpaired. It seems natural at this point that a higher note at the end would indicate a connection because I have been using them for so long but it makes me wonder if that would have always been the case. I don’t know much about music and chord progressions but I would think that a higher note ending would convey happiness consistent with how the manufacturer wants you to feel when you use their products, and a lower note ending would convey sadness or some type of negative motion for stopping use of their product.

 

On the topic of pairing noises, I noticed the sound another speaker makes when in paring mode resembles a radar blip which is a cool experience to give the user. I think the sound adds a layer to the experience of pairing a device by tying it to searching for non-visible objects.

Error Sounds – MATLAB’s Assortment of Error Noises

When running a MATLAB script, there are a few things that trigger a sound to go off. The first of these is when a break in the code is set for debugging which for a while triggered a nice sounding double beat almost like a wooden percussion instrument. The second is when an error happens in the code and it stops running as a result invoking the same noise. While the first use case is very informative, the second case is not so. Recently, my perspective on these sounds changed as I listened to another friends computer make a screaming sound as the program encounters an error. This slight change in the error noise changed my whole perspective on what was happening in the script.

Assignment 7: sound with meaning

For this assignment, using a Teensy, generate sound-over-time and sound-by-interrupt that conveys meaning, feeling, or specific content.  You can generate sound with a speaker or a kinetic device (ex: door chime) or some other novel invention.  I should be able to figure out what I’m hearing and what it means with no advise/help.

This is a good time to use push buttons or other inputs to trigger sound and another input to define the type of sound.

This is also where interrupts are very useful.

My  phone *doesn’t* do this well.  If I am listening to music and someone rings my doorbell at home, my phone continues to play music *and* the doorbell notification sound at the same time.  What it should do is stop the music, play the notification, then give me the opportunity to talk to the person at the door, then continue playing music.

Due next class.

Class Notes, 17 Mar 2022

Getting sound out of a Teensy

Using MQS is pretty easy, here’s an example:

https://github.com/TeensyUser/doc/wiki/Audio-Example-using-MQS-on-Teensy-4.0-or-4.1

The Teensy can drive a tiny speaker but it’s not very loud.  Use the amplifier I distributed to drive a small speaker.

Psychological effects of sound

Is it genetics that cause us to respond to the sound of a crying human baby?  Can you think of an “angry” noise?  A “happy” noise? a “relaxing” noise?

Experimental / avant-garde sound

Mark Applebaum’s experimental instruments and scoring.

Nikoli Voinov who composed music by drawing on paper, creating animation that made sound.

The Variophone: https://www.youtube.com/watch?v=4r4WqAf-X8Y

Musique concrete using early technology to record and modify sound, including the original soundtrack to “Doctor Who”.  Some great examples of recording found sound and reusing it for music.

Some experimental music is a do-over of something from a previous generation.  Brian Eno and Robert Fripp “invented” Frippertronics, but people have been experimenting with looped tape for decades.

Live demonstration: https://www.youtube.com/watch?v=kaKgj9DqxhE

Fripp/Eno live performance: https://www.youtube.com/watch?v=xso_RoigibA

Some music you should listen to as background music while you’re doing other tasks.  Avant-garde and futurism is a rather wide grouping, like saying “rock” or “country”:

Aphex Twin (Richard James) wants to make music instruments that don’t exist, so he creates them with synthesizers:  https://www.youtube.com/watch?v=_AWIqXzvX-U

The Development of Rap/Hip-Hop

Using street technology to change and create new genres of music.  Entertainment and environmental sounds can come from other contexts with the use of equipment to record, store, modify, and replay.

Turntables used to create hip hop and the 1.5 hour documentary.

The Orchestral Hit.  Please watch all of this as it goes in to early interaction design

The Amen Break.  Also watch all of this, it’s not only a great story about a break beat but how to tell a story about music using film/editing techniques.

Rob Base (of Rob Base and DJ EZ Rock  https://www.youtube.com/watch?v=phOW-CZJWT0) teaching DJ at The New school:  https://www.youtube.com/watch?v=I15WVyhoCHo

Assignment

Assignment 7: sound with meaning