Exercise 1
Your task is to complete the effect methods in the file.
The methods in this class take one AudioInputStream and return a new AudioInputStream. You can assume that the AudioInputStream passed to the methods is PCM encoded with 16 bits (big endian), a sample rate of 44.1 kHz, and 2 channels.
In each case, use pencil and paper, plus audio theory and pseudo-code, to specify/design solutions. Then begin coding.
effect2: This static method takes one AudioInputStream and adds the sound of a certain frequency to the START of it, for a certain length of time.
The method takes two additional parameters: frequency and lengthInMilliseconds.
The amplitude of the additional sound should be 64*256. Also note that the formula for a sound of a frequency f at time t (in seconds) is amplitude*sin(t 2 pi f) -- recall the theory from lectures.
effect3: This method takes no parameters and should simply play the tune of Happy Birthday.

The notes are
G G A G C B    Happy birthday to you
G G A G D C    Happy birthday to you
G G g E C B A   Happy birthday dear ------
F F E C D C    Happy birthday to you

You should experiment with suitable times for the lengths of the notes, or, if you solicit information from the web then please cite your sources clearly, in comments within the code that you submit. You will also need to add some spaces between the notes. In principle you can obtain full marks as long as your note lengths are about right.
The frequencies for the notes are as follows:
g 196.000
C 261.626
D 293.665
E 329.628
F 349.228
G 391.995
A 440.000
B 493.883

General instructions
You should complete the effect2 and effect3 methods. You can test your methods with different parameter values by editing the file.

To compile use: javac -classpath editor.jar:.
To run use: java -classpath editor.jar:. RunEffects

Exercise 2
Write some Java 3D code, in a file called, that satisfies the following specification: A standard cube of size (0.5,0.5,0.5) is fixed at the origin. An "airplane" is composed of a cube of size (1,1,1), the body, with green boxes that act as wings which are "attached" to the magenta and cyan opposite sides of the cube. The airplane should loop (fly continuously) around the fixed cube. Also the plane should continuously loop-the-loop by rotating around the axis that passes through the centre of the yellow and blue opposite sides of the body cube. (This axis is of course perpendicular to the axis that passes, centrally, from one wing tip to the other.) Hint: try placing a box of size (0.3f,1.4f,.1f) at the centre of the cube body; the parts that are visible will act as the wings.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import javax.sound.sampled.*;

public class AudioManipulation {

    public static AudioInputStream append(AudioInputStream ais1, AudioInputStream ais2){

byte[] a,b,c = null;
try {
a=new byte[(int) ais1.getFrameLength() *

// fill the byte array with the data of the AudioInputStream;
b=new byte[(int) ais2.getFrameLength() *

// fill the byte array with the data of the AudioInputStream;

c=new byte[a.length + b.length];
for (int i=0; i < c.length; i++) {
if (i < a.length) {
$110.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats