d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Help With Assignment
Add Reply New Topic New Poll
Member
Posts: 467
Joined: Nov 18 2013
Gold: 0.00
Apr 1 2014 10:09am
What were trying to do is make a Sound class that can do all these commands and there is also another class thats being used called WavIO. So we take in an array of doubles that are samples of the sounds and use them to do these methods. Here's my code:
Code

/**
* Write a description of class Sound here.
*
* @Author AryaAtighehchian
* @version 3/31/14
*/
public class Sound
{
private String fileName;
private double [] samples;
public Sound(){
samples = new double[0];
}

public Sound(Sound s){

}

public double[] get(){

WavIO.read(fileName);
return samples;
}

public void increaseVol(double percent){
percent = percent/100;
for(int i = 0; i<samples.length;i++){
samples[i] = samples[i] * (1 + percent);
}
}

public void lengthen(){

}

public void reduceVol(double percent){
percent = percent/100;
for(int i = 0; i<samples.length;i++){
samples[i] = samples[i] * (1 - percent);
}
}

public void reverse(){

}

public void set(double[] mySamples){

}

public void shorten(){
}

public void wavRead(String fileName){
WavIO.read(fileName);
//return samples;
}

public void wavSave(String fileName){
WavIO.write(fileName,samples);
}

public static void main(String[] args){

}
}


WavIO

Constructor Summary
WavIO()

Method Summary
static double[] read(java.lang.String fileName)
Read the WAV file and return its samples in an array.
static void write(java.lang.String fileName, double[] samples)
Write the given array to a WAV file.

Sound class

Constructor Summary
Sound()
When a Sound object is instantiated, it has an empty samples array.
Sound(Sound s)
Make this new Sound object a duplicate of the given Sound object.


Method Summary
double[] get()
Get the array of sound samples.
void increaseVol(double percent)
Increase volume of the sound by the given percent.
void lengthen()
Lengthen the sound's duration by two times.
void reduceVol(double percent)
Reduce the volume of the sound by the given percent.
void reverse()
Reverse the sound.
void set(double[] mySamples)
Set the array of sound samples to the given array.
void shorten()
Shorten the sound's duration by half.
void wavRead(java.lang.String fileName)
Read a WAV file of the given file name.
void wavSave(java.lang.String fileName)
Save this Sound's samples to a WAV file using the given name.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll