Question
Please include a method call for a new project in Java! Many thanks!! Source code for Sound.java package BookClasses; /** * Class that represents a
Please include a method call for a new project in Java! Many thanks!!
Source code for Sound.java
package BookClasses;
/** * Class that represents a sound. This class is used by the students * to extend the capabilities of SimpleSound. * * Copyright Georgia Institute of Technology 2004 * @author Barbara Ericson ericson@cc.gatech.edu */ public class Sound extends SimpleSound { /////////////// consructors //////////////////////////////////// /** * Constructor that takes a file name * @param fileName the name of the file to read the sound from */ public Sound(String fileName) { // let the parent class handle setting the file name super(fileName); } /** * Constructor that takes the number of samples in * the sound * @param numSamples the number of samples desired */ public Sound (int numSamples) { // let the parent class handle this super(numSamples); } /** * Constructor that takes the number of samples that this * sound will have and the sample rate * @param numSamples the number of samples desired * @param sampleRate the number of samples per second */ public Sound (int numSamples, int sampleRate) { // let the parent class handle this super(numSamples,sampleRate); } /** * Constructor that takes a sound to copy */ public Sound (Sound copySound) { // let the parent class handle this super(copySound); } ////////////////// methods //////////////////////////////////// /** * Method to return the string representation of this sound * @return a string with information about this sound */ public String toString() { String output = "Sound"; String fileName = getFileName(); // if there is a file name then add that to the output if (fileName != null) output = output + " file: " + fileName; // add the length in frames output = output + " number of samples: " + getLengthInFrames(); return output; } public static void main(String[] args) { Sound sound1 = new Sound(FileChooser.pickAFile()); sound1.explore(); }
public int setSampleValueAt(int i) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } public void zeroAlternatingSamples() { } } // this } is the end of class Sound, put all new methods before this
2) Create a new method called zeroAlternatingSamples in your Sound.java file that transforms the sound by setting every second sample to 0, as pictured below: Page 1 of 9 ITSC 1213 Lab 3 The method needs to create a new Sound object with the same length as the original Sound object, and copy values of samples from the original sound into the new sound, and then return the new sound at the end. Note that in Sound.java, to refer to the original Sound object, we use this reference variable. For example, to get the length of the current Sound object, we can use this.getLength0). Here is some pseudocode to help you create your new method 3) REMEMBER create a new sound object to hold a sound with the same length as the current sound REPEAT- for each sample in the current sound object: CALCULATE whether this sample index is odd or even CHOOSE- if index is even: REMEMBER -copy the value of this sample to the new sample CHOOSE- if index is odd: REMEMER-put 0 in the new sample REMEMBER return the new sound object 2) Create a new method called zeroAlternatingSamples in your Sound.java file that transforms the sound by setting every second sample to 0, as pictured below: Page 1 of 9 ITSC 1213 Lab 3 The method needs to create a new Sound object with the same length as the original Sound object, and copy values of samples from the original sound into the new sound, and then return the new sound at the end. Note that in Sound.java, to refer to the original Sound object, we use this reference variable. For example, to get the length of the current Sound object, we can use this.getLength0). Here is some pseudocode to help you create your new method 3) REMEMBER create a new sound object to hold a sound with the same length as the current sound REPEAT- for each sample in the current sound object: CALCULATE whether this sample index is odd or even CHOOSE- if index is even: REMEMBER -copy the value of this sample to the new sample CHOOSE- if index is odd: REMEMER-put 0 in the new sample REMEMBER return the new sound object
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started