Week 10 - Timers, Computational Poetry

Today

  • timers
  • workshop: generative music maker
  • use camera apps
  • Computational poetry

Timers with millis()

p5.js has a single command for working with time:

millis()

millis() always returns the amount of milliseconds that have elapsed since your program started running.

print("it's been " + millis() + " seconds since our program started");

We can use millis() to create timers.

//check if it's been 3 seconds since our program started
if (millis() > 3000){
  //do something
}

We can make a repeating timer if it’s in our draw and we increase the timer each time it’s triggered. This is like the ‘snooze’ feature on an alarm. It keeps adding a bit more time.

let timer = 3000;
if (millis() > timer){
  //do something
  timer+=3000; //add 3 more seconds to the timer each time it goes off
}

How would we have a random timer?

//pick a random time between 1 and 10 seconds
let timer = random(1000,10000); 

if (millis() > timer){
  //do something
}

challenge: Ambient Music Generator

Starter code

Goal: create an ambient sound generator.

Use a timer. Have a random sound get selected when timer goes off and play that sound.

“One of the notes repeats every 23 1/2 seconds. It is in fact a long loop running around a series of tubular aluminum chairs in Conny Plank’s studio. The next lowest loop repeats every 25 7/8 seconds or something like that. The third one every 29 15/16 seconds or something. What I mean is they all repeat in cycles that are called incommensurable — they are not likely to come back into sync again.” — Brian Eno

Resources

Introduction to Generative Music article How Mubert (Probably) Works article

Brian Eno - How to Make Original Ambient Music video

Generative.fm

References

  • tint in the p5.js reference
  • Bonus: scanner camera scanner effect

Generative Text

Please view the online exhibitions of Taper and some of the previous editions. Taper is an online literary journal for computational poetry and literary art published twice yearly by Bad Quarto. This is the 6th edition since it started.

Read:

About Taper.

Review the work.

Recommendations: for the pool players at the Golden Shovel by Lillian-Yvonne Bertram - interactive, click the button from Taper #1

God by Milton Laufer, from Taper #1

US by Nick Montfort, from Taper #1

A Storm in 2k by J.R. Carpenter

Whalefall by Katya Ilonka Gero, from Taper #5

Pope Lost Hope by Yohana Joseph Waliya, from Taper #5

everything gets eaten by Eirian Friedkin, from Taper #3 –Think about: How does this one work? How would you code this?

Additional bonus works:

((((0)))) by Eugenio Tisselli, from Taper #4

your balcony, maybe five years ago by kit buckley, from Taper #3

Rules of Three by Ross Goodwin, uses the camera!, from Taper #3

Read: We asked a computational poet if machines will ever replace human writers - on Nick Montfort, founder of Taper

Method:

“Read” or view the selections from Taper above. Read about Taper. Read the article about Nick Montfort, founder of Taper. Are there particular pieces you like? Think about how some of these are made. If you are completely uncertain, look at everything gets eaten linked above. That one you should definitely be able to figure out an idea of how the code works.

After reading (playing?) all of the above computational works, now design an experimental computational poem-artwork.

  • What is the title?
  • What is the concept?
  • You may want to plan with a sketch on paper first

Turn in:

  • Title
  • Short description (up to 1 paragraph)
  • Link to piece working fullscreen
  • Link to code