Web Audio API Let your WebGL program dance. Announcement Final project proposal due in one week. Choice of demo date? Plan for the 12/23 class. 2.

Slides:



Advertisements
Similar presentations
HbbTV Hybrid broadcast broadband TV EBU / ETSI Hybrid Broadcast Broadband Workshop Amsterdam, 9 th September, 2009.
Advertisements

Animation and Input CSCI Day Six. Animation Basic Steps to Draw Something: var vertices = [ … ]; var BufferId = gl.CreateBuffer(); gl.bindBuffer.
An introduction to WebGL Viktor Kovács. Content A little 3D modeling. What is WebGL? Introducing Three.js. Visualizing GDL objects.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2010/2011.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
Creating Podcast By Mary A. Malinconico Gloucester County College By Mary A. Malinconico Gloucester County College.
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
Chapter 11 Adding Media and Interactivity. Flash is a software program that allows you to create low-bandwidth, high-quality animations and interactive.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
WebGL Patrick Cozzi University of Pennsylvania CIS Spring 2012.
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
Control Systems An Overview. Definition A control system is a device or set of devices that are coordinated to execute a planned set of actions.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Canvas academy.zariba.com 1. Lecture Content 1.What is Canvas? 2.Including Canvas in your HTML 3.Commands in Canvas 4.Drawing Shapes with Canvas 5.Animations.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
UX design for Google Glass Alena Kovárová PeWe Seminar
1 Graphics CSCI 343, Fall 2015 Lecture 1 Introduction to Graphics Read: Chapter 1 of textbook.
COMPUTER PARTS AND COMPONENTS INPUT DEVICES
Funativity CS 426 Fall Team Members David Smits – Lead Chintan Patel – Programmer Jim Gagliano – Programmer Ashleigh Wiatrowski - Artist.
1 Graphics CSCI 343, Fall 2015 Lecture 2 Introduction to HTML, JavaScript and WebGL.
CNIT 133 Interactive Web Pags – JavaScript and AJAX How to run JavaScript?
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Introduction to Multimedia Review 1 - Lecture Notes Semester 1.
Marketing Development Block 4 Dr. Uma Kanjilal. Stages of a Multimedia Project  Planning and costing- infrastructure, time, skills etc.  Designing and.
Computer Science and Software Engineering© 2014 Project Lead The Way, Inc. HTML5 Evolving Standards JavaScript.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
LAB 03: VISUALIZATION WITH D3 September 30, 2015 SDS 235 Visual Analytics.
How to Use Google Charts. Using Google Charts Google Charts is used to provide a way to visualize data on your website. You can choose to use simple line.
1 Graphics CSCI 343, Fall 2015 Lecture 3 Introduction to WebGL.
CompSci Introduction to Jam’s Video Game Package.
Attack of the Clones Image source:
Tim ADDING WEB TO WEBRTC.  Protocol Droid  Webrtc evangelist  Standards pusher  Consulting at Wire.com ABOUT: TIM PANTON.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
…Dedicated Micros has introduced a new Entry-Level DVR.
3D Objects in WebGL Loading 3D model files. Announcement Midterm exam on 12/2 –No Internet connection. –Example code and exam questions will be on USB.
CompSci 44.1 Game Package Introduction to Jam’s Video Game Package.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Let’s look what flash can do: OK, that wasn’t flash! That was HTML5.
Martin Kruliš by Martin Kruliš (v1.1)1.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
4.3. Code animations by using JavaScript Access data access by using JavaScript. Creating Animations, Working with Graphics, and Accessing Data.
Introduction of Scratch (1/4) You can find Scratch on the Web:
Week 10: Objects. Today’s Tasks  Upgrade your wonderful animal!
HTML5 Semantic
MPEG-4 Binary Information for Scenes (BIFS)
Video on the Web.
Obj: Introduction to Alice
Chapter 4: HTML5 Media - <video> & <audio>
Let your WebGL program dance
Understand Windows Forms Applications and Console-based Applications
Introduction to Alice Alice is named in honor of
Pre-Production Determine the overall purpose of the project.
HbbTV Hybrid broadcast broadband TV
Introduction to Computer Graphics with WebGL
Introduction to Alice Alice is named in honor of
Introduction to Programming
Introduction to Alice Alice is named in honor of
…Dedicated Micros has introduced a new Entry-Level DVR.
Introduction to Alice Alice is named in honor of
Today’s Objectives Week 12 Announcements ASP.NET
Introduction to Alice Alice is named in honor of
Interactive media.
OpenGL-Rendering Pipeline
Engine and functionalities
Presentation transcript:

Web Audio API Let your WebGL program dance

Announcement Final project proposal due in one week. Choice of demo date? Plan for the 12/23 class. 2

Final Projects Individual or Team of 2. Voting during the demo. Do NOT use THREE.js Themes for this semester: Interactive Art in WebGL –Animating objects with changing colors, positions, shapes, …etc. –Interacts with mouse input or audio input (music). 3

Possible Interactions Input: –Mouse, keyboard –Audio –Video or camera? Output – changing the following –Size, number, position, color, …etc. –Viewpoint –Lighting 4

For Further Reading Web Audio API: –Good introduction at: –More information on the frequency analyzer: three-js-webgl three-js-webgl Watch out for deprecated functions: –e.g., createJavaScriptNode() replaced by createScriptProcessor() 5

WEB AUDIO 6

Loading the Music: Option #1 Option #1: element in HTML The following code produces an audio element with playback controls. 7 Rotate X Rotate Y Rotate Z Pause Depth Test

A Simple Player // Experimenting with HTML5 audio var context = new AudioContext(); var audio = document.getElementById('myAudio'); var audioSrc = context.createMediaElementSource(audio); audioSrc.connect(context.destination); audio.play();

Adding Frequency Analyzer var context = new AudioContext(); var audio = document.getElementById('myAudio'); var audioSrc = context.createMediaElementSource(audio); var sourceJs = context.createScriptProcessor(2048); analyser = context.createAnalyser(); analyser.smoothingTimeConstant = 0.6; analyser.fftSize = 512; // Connect the MediaElementSource with the analyser audioSrc.connect(analyser); analyser.connect(sourceJs); sourceJs.buffer = audioSrc.buffer; sourceJs.connect(context.destination); audioSrc.connect(context.destination);

sourceJs.onaudioprocess = function(e) { // frequencyBinCount: how many values from the analyser frequencyData = new Uint8Array( analyser.frequencyBinCount); analyser.getByteFrequencyData( frequencyData ); };

Visualization function render() {... // update data in frequencyData analyser.getByteFrequencyData(frequencyData); // render frame based on values in frequencyData gl.uniform1f( volumeLoc, frequencyData[160] / 255 ); gl.drawArrays( gl.TRIANGLES, 0, numVertices ); requestAnimFrame( render ); }

Loading the Music: Option #2 Option #2: XMLHttpRequest() in JS 12 loadSound("your_song.mp3"); function loadSound(url) { var request = new XMLHttpRequest(); request.open('GET', url, true); request.responseType = 'arraybuffer'; // When loaded decode the data request.onload = function() { context.decodeAudioData( request.response, } request.send(); }

Lab Time! Download cube3_music.zip Change frequencyData[160] to other entry. –How does it respond to the music? Uncomment console.log(frequencyData) –What do you see in the console? How about visualizing the whole array of frequencyData[0..255]? 13