Rewrite the Program so that you normalize the first second of a sound, then slowly decrease the sound in steps of 1=5 for each following second. (How many samples are in a second? getSamplingRate() is the number of samples per second for the given sound.)
What will be an ideal response?
```
public void changeVolume (double f a c t o r ,
int s t a r t ,
int end )
{
int value = 0 ;
for ( int i = s t a r t ; i < end ; i++)
{
value = this . getSampleValueAt ( i ) ;
this . setSampleValueAt ( i , ( int ) ( value ¤ f a c t o r ) ) ;
}
}
public void normal i z e ( int s t a r t , int end )
{
int max = s t a r t ;
int value = 0 ;
// loop from s t a r t to end l o o k i n g f o r the max
for ( int i = s t a r t ; i < end ; i++)
{
value = this . getSampleValueAt ( i ) ;
i f (Math . abs ( value ) > Math . abs (max) )
max = value ;
}
// determine the mu l t i p l i e r
double mu l t i p l i e r = 32767.0 / max ;
// change the volume by the mu l t i p l i e r
this . changeVolume ( mu l t i p l i e r , s t a rt , end ) ;
}
public void normSecThenDecrease ( )
{
int numInSec = ( int ) this . getSampl ingRate ( ) ;
double r educ t i on = 1 . 0 / 5 . 0 ;
double t o t a lReduc t i on = r educ t i on ;
int numSecs = this . getLength ( ) / numInSec ;
i f ( numSecs > 5)
numSecs = 5 ;
// normal i z e the f i r s t second
this . normal i z e ( 0 , numInSec ) ;
// loop changing the volume
for ( int i = 1 ; i < numSecs ; i++)
{
this . changeVolume ( 1 . 0 ¡ totalReduc t ion ,
i * numInSec ,
( i + 1)*numInSec ) ;
totalReduction = totalReduction + r eduction ;
}
}
```
You might also like to view...
Which wireless security protocol is considered to be too weak for use inmost network settings?
A. WAP B. WPA C. WPA2 D. WEP
Use Visible Analyst or the Repository Web page to view the COMPUTER MASTER data store. Jump to the data structure and browse the elements and structural records.
What will be an ideal response?
A(n) ____________________ plan is a set of Start and Finish dates that you can save periodically as your project progresses.
Fill in the blank(s) with the appropriate word(s).
To apply complex criteria to a single column, use a(n) ________
A) custom filter B) advanced filter C) AutoFilter D) extracting filter