<< Chapter < Page Chapter >> Page >

Let us analyze the Processing code that implements the Sound Chooser in its salient aspects. The Sonia.start(this) command is necessary to activate the Sonia audio engine. The line Sample mySample1 declares a variable aimed at containing audio samples. Several methods can be applied to suchvariable. Among these, the play methods plays the sound sample back. In the draw() code section the graphic aspect of the applet is defined. Finally, by thefunction mouseReleased() , we detect when the mouse is released after being pressed, and where it has beenreleased. At this point a sequenceo of if conditions finds what instrument/timbre has been selected according to the clicking point. Moreover, within the function mouseReleased() the function filtra(float[] DATAF, float[]DATA, float RO, float WC) is invoked. This function, which is implemented in the lastsegment of the code listing, performs a sound filtering. More precisely, it is a low-pass filter, thus a filter that leavesthe low frequencies unaltered and reduces the intensity of the high frequencies. According to the radial position of themouse click, the filtering effect changes, being more dramatic (that is the sound becomes darker) as the mouse is released closer and closer to thecentre. A lighter realization of the Sound Chooser by means of the library Minim is proposed in problem [link] . The problem [link] explores the recent library Beads.

Trumpet
Oboe
Violin
Flute
Applet: choosing a timbre and controlling its brightness
import pitaru.sonia_v2_9.*;Sample mySample1, mySample2, mySample3, mySample4; Sample mySample1F, mySample2F, mySample3F, mySample4F;float[] data1, data2, data3, data4;float[] data1F, data2F, data3F, data4F;int sr = 11025; // sampling rate void setup(){ size(200, 200);colorMode(HSB, 360, height, height); Sonia.start(this);mySample1 = new Sample("flauto.aif"); mySample2 = new Sample("oboe.wav");mySample3 = new Sample("tromba.wav"); mySample4 = new Sample("violino.wav");mySample1F = new Sample("flauto.aif"); // ... OMISSIS ...data1 = new float[mySample1.getNumFrames()];// creates new arrays the length of the sample // for the original sound// ... OMISSIS ... data1F = new float[mySample1.getNumFrames()]; // creates new arrays the length of the sample// for the filtered sound // ... OMISSIS ...mySample1.read(data1); // ... OMISSIS ...} void draw(){ // ... OMISSIS ...} void mouseReleased(){ float ro;float roLin; float wc;// FLAUTO if ((mouseX>95)&&(mouseX<105)&&(mouseY>50)&&(mouseY<90)) { roLin = (mouseY-49.99)/41;ro = pow(roLin,.33); wc = 298*(TWO_PI/sr);filtra(data1F, data1, wc, ro); mySample1F.write(data1F);mySample1F.play(); }// ... OMISSIS ... }//filtra = new function void filtra(float[]DATAF, float[] DATA, float WC, float RO) {float G; float RO2;RO2 = pow(RO, 2); G = (1-RO)*sqrt(1-2*RO*cos(2*WC)+RO2)*4; // (*4) is for having it louderfor(int i = 3; i<DATA.length; i++){ DATAF[i]= G*DATA[i]+2*RO*cos(WC)*DATAF[i-1]-RO2*DATAF[i-2];//recursive filtering }} // safely stop the Sonia engine upon shutdown.public void stop(){ Sonia.stop();super.stop(); }

Questions & Answers

how to create a software using Android phone
Wiseman Reply
how
basra
what is the difference between C and C++.
Yan Reply
what is software
Sami Reply
software is a instructions like programs
Shambhu
what is the difference between C and C++.
Yan
yes, how?
Hayder
what is software engineering
Ahmad
software engineering is a the branch of computer science deals with the design,development, testing and maintenance of software applications.
Hayder
who is best bw software engineering and cyber security
Ahmad
Both software engineering and cybersecurity offer exciting career prospects, but your choice ultimately depends on your interests and skills. If you enjoy problem-solving, programming, and designing software syste
Hayder
what's software processes
Ntege Reply
I haven't started reading yet. by device (hardware) or for improving design Lol? Here. Requirement, Design, Implementation, Verification, Maintenance.
Vernon
I can give you a more valid answer by 5:00 By the way gm.
Vernon
it is all about designing,developing, testing, implementing and maintaining of software systems.
Ehenew
hello assalamualaikum
Sami
My name M Sami I m 2nd year student
Sami
what is the specific IDE for flutter programs?
Mwami Reply
jegudgdtgd my Name my Name is M and I have been talking about iey my papa john's university of washington post I tagged I will be in
Mwaqas Reply
yes
usman
how disign photo
atul Reply
hlo
Navya
hi
Michael
yes
Subhan
Show the necessary steps with description in resource monitoring process (CPU,memory,disk and network)
samuel Reply
What is software engineering
Tafadzwa Reply
Software engineering is a branch of computer science directed to writing programs to develop Softwares that can drive or enable the functionality of some hardwares like phone , automobile and others
kelvin
if any requirement engineer is gathering requirements from client and after getting he/she Analyze them this process is called
Alqa Reply
The following text is encoded in base 64. Ik5ldmVyIHRydXN0IGEgY29tcHV0ZXIgeW91IGNhbid0IHRocm93IG91dCBhIHdpbmRvdyIgLSBTdGV2ZSBXb3puaWFr Decode it, and paste the decoded text here
Julian Reply
what to do you mean
Vincent
hello
ALI
how are you ?
ALI
What is the command to list the contents of a directory in Unix and Unix-like operating systems
George Reply
how can i make my own software free of cost
Faizan Reply
like how
usman
hi
Hayder
The name of the author of our software engineering book is Ian Sommerville.
Doha Reply
what is software
Sampson Reply
the set of intruction given to the computer to perform a task
Noor
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Media processing in processing. OpenStax CNX. Nov 10, 2010 Download for free at http://cnx.org/content/col10268/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Media processing in processing' conversation and receive update notifications?

Ask