1 / 12

Fundamentals of Programming

Fundamentals of Programming. SM1204 Semester A 2012. Due date 21 Dec 2012 Collection via ACS. Assignment 3. Requirements. Create your own music visualization (20%) Select your audio / music Design your visualization Use of Minim audio library (30%) Program complexity (20%)

merton
Download Presentation

Fundamentals of Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fundamentalsof Programming SM1204 Semester A 2012

  2. Due date 21 Dec 2012 Collection via ACS Assignment 3

  3. Requirements • Create your own music visualization (20%) • Select your audio / music • Design your visualization • Use of Minim audio library (30%) • Program complexity (20%) • Creative graphics (30%)

  4. Example • http://www.youtube.com/watch?v=KW5D9IVfb1k&feature=related

  5. Example • http://www.youtube.com/watch?v=1JkN3Uwgqi4&feature=related

  6. Example • http://www.youtube.com/watch?v=0AVyhytUy7k&feature=related

  7. Sample Program

  8. Sample Program • Import library • Define player and beat detector objects import ddf.minim.*; import ddf.minim.analysis.*; Minim minim; AudioPlayer player; BeatDetect beat; int n = 5; float[][] a = new float[n][n];

  9. Sample Program • Create objects & Initialize array elements void setup() { size(400, 400); minim = new Minim(this); player = minim.loadFile("test2.mp3"); beat = new BeatDetect( player.bufferSize(), player.sampleRate() ); player.play(); // initialize item size for (inti=0; i<n; i++) { for (int j=0; j<n; j++) { a[i][j] = 40; } } }

  10. Sample Program • Beat detection and rendering void draw() { beat.detect(player.mix); background(0); strokeWeight(4); for (inti=0; i<n; i++) { for (int j=0; j<n; j++) { // enlarge corresponding circle if onset if (beat.isOnset(i*5+j)) { a[i][j] = 80; } float s = a[i][j]; float c = map(s, 40, 80, 200, 255); noFill(); stroke(c); ellipse(i*80+40, j*80+40, s, s); fill(c); noStroke(); ellipse(i*80+40, j*80+40, s / 2, s / 2); // decrease circle sizes if (a[i][j] > 40) { a[i][j] *= 0.95; } } } }

  11. Sample Program • Do not forget to add the stop( ) function void stop() { player.close(); minim.stop(); super.stop(); }

  12. Useful Functions & References • map (value, low1, high1, low2, high2) • Re-maps a number from one range to another • constrain(value, min, max) • Constrains a value to not exceed a maximum and minimum value. • abs(value) • Calculates the absolute value (always position) of a number.

More Related