1 / 5

Introduction to sound using processing

Introduction to sound using processing. Minim A sound library which uses javasound library Provide convenient but flexible way to play, , synthesize and recode sound. Loadfile.

Download Presentation

Introduction to sound using processing

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. Introduction to sound using processing

  2. Minim • A sound library which uses javasound library • Provide convenient but flexible way to play, , synthesize and recode sound

  3. Loadfile • The loadFile method of Minim class allows you to specify the file you want to load with a String and optionally specify what you want the buffer size of the returned AudioPlayer to be. • Minim is able to play wav files, au files, aif files, snd files, and mp3 files. • Parameter • Filename • When you call loadFile, if you just specify the filename it will try to load the file from the data folder of your sketch. • However, you can also specify an absolute path (such as "C:\foo\bar\thing.wav") • You can also specify a URL (such as "http://www.mysite.com/mp3/song.mp3") • Buffer size • Size of a buffer which will be used by minim • Default: 1024

  4. AudioPlayer • AudioPlayer • A class which can control audio play • Returened by loadFile • play() • Play the sound • stop() • Stop playing the sound • left, right • Represent sound buffer of left and right speaker • get(int position) • Reurn the sound value at position • Returned value is between -1, 1

  5. import ddf.minim.*; AudioPlayer player; Minim minim; void setup() { size(1024, 200, P2D); minim = new Minim(this); // load a file, give the AudioPlayer buffers that are 1024 samples long // player = minim.loadFile("groove.mp3"); // load a file, give the AudioPlayer buffers that are 2048 samples long player = minim.loadFile("groove.mp3", 1024); // play the file player.play(); } void draw() { background(0); stroke(255); // draw the waveforms // the values returned by left.get() and right.get() will be between -1 and 1, // so we need to scale them up to see the waveform // note that if the file is MONO, left.get() and right.get() will return the same value for(int i = 0; i < player.left.size()-1; i++) { line(i, 50 + player.left.get(i)*50, i+1, 50 + player.left.get(i+1)*50); line(i, 150 + player.right.get(i)*50, i+1, 150 + player.right.get(i+1)*50); } } void stop() { // always close Minim audio classes when you are done with them player.close(); minim.stop(); super.stop(); }

More Related