User:Ssstephen/take-the-entrain: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 107: Line 107:
}
}
</pre>
</pre>
How do you embed audio on the wiki? [https://2223.mywdka.nl/roomforsound/sound/two-esp32s-beeping-and-buzzing/ Here's a link instead.]


==Get the computers to listen==
==Get the computers to listen==

Revision as of 19:27, 16 January 2023

this room for sound residency will be an exploration of tying digital connections and using them as an instrument. connexion used to be spelled with an x which shows the origin of the word: a binding or joining together. opening a network connexion creates a string of data which can and will be plucked. a work in the form of a net: strings interwoven and interconnetted. starting from short strings inside a single computer, over the two weeks this network will expand to cover the entire universe.

This is a two week residency in the Willem de Kooning Academy's Room for Sound, from 16th to 27th January 2023. I will be experimenting with networked music, in particular I plan to use some ESP32 boards and a Raspberry Pi to send and receive RTP-MIDI over LAN and hopefully WAN, and to translate this MIDI data to and from audio (via microphones, sensors, buzzers, speakers, etc). I would like to get other people involved in this process as well as getting the machines to interact: the machines could be not just musicians but also instruments.

Pseudocode

Get the computers to entrain to eachother dynamically, clap with eachother

While
    Countup++ per ms
    If(hearbeep) or (countup= random ~ 200ms)
        If(countup >40ms)
            Wait(countup ms)
            Sendbeep
            Countup=0

Day 1

Get the computers to sing

Today I am working with two Seeed Studios Xiao ESP32-C3 and some buzzers. Writing Arduino (C++) scripts for them to make beeps and also blinkenlights because they're fun.

/**
 * Singing 
 *
 * Plays predefined tones in a predefined order from a buzzer on pin D9.
 * Also flashes an LED on pin D8 just for fun.
 */
#include "Arduino.h"
// #include "pitches.h"

// Define some pitches of beeps, a basic time unit, a status
int dt1=200;
int dt2=90;
int dt3=360;
int dt4=400;
int duration=50;
int ledstatus=0;

void beep(int tone1,int length) {
  //this part switches the LED status
  if(ledstatus==0){
    digitalWrite(D8,HIGH);
    ledstatus=1;
  }else{
    digitalWrite(D8,LOW);
    ledstatus=0;
  }
  //This part pulses the buzzer.
   for (int tonecounter=1;tonecounter<=length;tonecounter=tonecounter+1){
     analogWrite(A0,127);
     delayMicroseconds(tone1);
     analogWrite(A0,0);
     delayMicroseconds(tone1);
   }
  //Or you could for more exact tones and lengths but no analog
  //tone(D9, tone1, length);
}

void setup()
{
  // initialize LED digital pin as an output.
  pinMode(D8, OUTPUT);
  pinMode(A0, OUTPUT);
}

void loop()
{
  //A sequence of buzzes
  beep(dt1,duration*2);
  beep(dt2,duration);
  beep(dt1,duration*2);
  beep(dt2,duration*2);
  beep(dt1,duration);
  beep(dt2,duration*4);
  beep(dt1,duration*2);
  beep(dt2,duration);
  beep(dt1,duration*2);
  beep(dt3,duration);
  beep(dt1,duration*2);
  beep(dt4,duration*4);
}

Someone else sending data from arduino xto ChucK

Get the computers to clap

Some tweaks to that code (tweaks only below) gave me two buzzers that beep at predefined tempi (metronomes I guess). They can make nice polyrhythms together. Timing is tricky!

int notelength=20;
int bpm = 100;
unsigned long delay1=(60000000/bpm) - (1000 * notelength);

void clap(int tone1,int bpm) {
  tone(A0, tone1, notelength);
  delayMicroseconds(delay1);
}

void loop()
{
  //A clapping speed
  clap(dt3,180);
}

How do you embed audio on the wiki? Here's a link instead.

Get the computers to listen