ICM Final

Figuring out the code for this was pretty difficult. Thankfully I had a lot of help from my instructor and we got the code up and running! I still haven’t come up with a suitable name for the project but I think that by the time I combine this with the pComp side I should have a better idea of what it should be called. I’m very happy with the results I have so far, and I certainly learned a lot putting it together.

Two more links in case the embedded version above doesn’t load:

http://alpha.editor.p5js.org/marcowylie/sketches/ryw1cVclz

http://alpha.editor.p5js.org/full/ryw1cVclz

let playbutton, stopbutton, nextbutton, backbutton;
let slider;
let songAFileNames = ['BabyDidABadBadThing', 'RunThroughTheJungle', 'MySweetLord',
'UnderPressure', 'YouNeedLove', 'LastNight', 'SurfinUSA',
'DaniCalifornia', 'WalkAndTalkIt', 'WhatIGot',
'SteppinOut', 'SemiCharmedLife', 'Mmmbop', 'GetOnYourBoots',
'WhyDontYouGetAJob', 'Taurus', 'TheAirThatIBreathe',
'PictureBook', 'LetForeverBe', 'LittleMermaid'];
let songBFileNames = ['SpiritInTheSky', 'TheOldManDownTheRoad', 'HesSoFine',
'IceIceBaby', 'WholeLottaLove', 'AmericanGirl', 'SweetLittleSixteen',
'MaryJanesLastDance', 'BrownSugar', 'LadyMadonna',
'DontStopTilYouGetEnough', 'TwoPrinces', 'Unpretty', 'PumpItUp',
'ObLaDiObLaDa', 'StairwayToHeaven', 'Creep',
'Warning', 'TomorrowNeverKnows', 'Nude'];
let songAs = [];
let songBs = [];
let albumAs = [];
let albumBs = [];
let currentIndex = 0;
function preload() {
for (let i = 0; i < songAFileNames.length; i++) { songAs[i] = loadSound("assets/sounds/" + songAFileNames[i] + ".mp3"); songBs[i] = loadSound("assets/sounds/" + songBFileNames[i] + ".mp3"); albumAs[i] = loadImage("assets/images/" + songAFileNames[i] + ".jpg"); albumBs[i] = loadImage("assets/images/" + songBFileNames[i] + ".jpg"); } } function setup() { createCanvas(400, 400); background(215); // slider slider = createSlider(0, 255, 100); slider.position(125, 320); // play button playbutton = createButton('Play'); playbutton.position(140, 350); playbutton.mousePressed(playsound); // stop button stopbutton = createButton('Stop'); stopbutton.position(200, 350); stopbutton.mousePressed(stopsound); // last set button backbutton = createButton('Last Set'); backbutton.position(50, 350); backbutton.mousePressed(lastsetsound); //next set button nextbutton = createButton('Next Set'); nextbutton.position(275, 350); nextbutton.mousePressed(nextsetsound); } function draw() { checkSliderAndUpdateSound(); } function checkSliderAndUpdateSound() { let slidervalue = slider.value(); let volumeA = map(slidervalue, 0, 255, 0, 1); let volumeB = map(slidervalue, 0, 255, 1, 0); songAs[currentIndex].setVolume(volumeA); songBs[currentIndex].setVolume(volumeB); tint(255,255); image(albumBs[currentIndex], 55, 20); tint(255, slidervalue); image(albumAs[currentIndex], 55, 20); } function playsound() { songAs[currentIndex].loop(); songBs[currentIndex].loop(); } function stopsound() { songAs[currentIndex].stop(); songBs[currentIndex].stop(); } function nextsetsound() { stopsound(); currentIndex++; if (currentIndex > songAs.length - 1) {
currentIndex = 0;
}
playsound();
}
function lastsetsound() {
stopsound();
currentIndex--;
if (currentIndex < 0) {
currentIndex = songAs.length - 1;
}
playsound();
}

Open ended questions for class:

  1. What buttons are useful? Should any be taken away?
  2. Which sets of songs are clearly related and which aren’t?
  3. Did you learn anything new about songs you might have heard before after playing with the sketch?
  4. How did the interface feel?

Leave a Reply

Your email address will not be published. Required fields are marked *