
Chords.txt
1.0 350.0 440.0
2.0 440 480
4.0 0 0
2.0 440 480
4.0 0 0
2.0 440 480
4.0 0 0
0.5 480 620
0.5 0 0
0.5 480 620
0.5 0 0
0.5 480 620
0.5 0 0
// Play.java
package chord; //Please give name of your package
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Play {
private static final String
FILENAME="D:\\WS17.2\\Sample\\src\\chord\\Chords.txt"; //give the
absulate path of //file
public static void playChord(double duration, double[]
frequencies)
{
final int sliceCount =
(int)(StdAudio.SAMPLE_RATE * duration);
final double[] slices= new
double[sliceCount + 1];
for(int
i=0;i<=sliceCount;i++)
{
double
chord=0.0;
for(double
frequency:frequencies)
{
chord +=
Math.sin(2*Math.PI*i*frequency/StdAudio.SAMPLE_RATE);
}
slices[i] =
chord/frequencies.length;
}
StdAudio.play(slices);
}
public static void main(String[] args)
{
BufferedReader br = null;
FileReader fr = null;
try {
fr = new
FileReader(FILENAME);
br = new
BufferedReader(fr);
String sCurrentLine;
br = new
BufferedReader(new FileReader(FILENAME));
while
((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
StringTokenizer st = new
StringTokenizer(sCurrentLine, " ");
double []freq = new double[2];
double duration =
Double.parseDouble(st.nextToken());
int i=0;
while(st.hasMoreTokens())
{
freq[i] =
Double.parseDouble(st.nextToken());
i++;
}
playChord(duration,freq);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)
br.close();
if (fr != null)
fr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
//I am assuing you have StdAudio class with you, If you do not have this class please let me know.
//output:

Chords.txt 1.0 350.0 440.0 2.0 440 480 4.0 0 0 2.0 440 480 4.0 0 0...
Given a set of values representing a complete population, the standard deviation is found by taking the square root of the average of the squared deviations of the values from their average value. For an example of what that means, see the following Wikipedia page; in particular, see the "Basic Example". As discussed in Wikipedia, given the following complete population: 2.0 4.0 4.0 4.0 5.0 5.0 7.0 9.0 then the standard deviation is 2.0 Your task is to write a...
Use two files for this lab: your C program file, and a separate text file containing the integer data values to process. Use a while loop to read one data value each time until all values in the file have been read, and you should design your program so that your while loop can handle a file of any size. You may assume that there are no more than 50 data values in the file. Save each value read from...
void insertion_sort(int array[], int length, int & count_comp, int & count_move); void merge_sort(int array[], int length, int & count_comp, int & count_move); void heap_sort(int array[], int length, int & count_comp, int & count_move); void quick_sort_sort(int array[], int length, int & count_comp, int & count_move); // YOUR // Implementation // should // go // here // or be put in separated .cpp files typedef void (*sort_algo_type)(int array[], int length, int& count_comp, int & count_move); void run_sort_algo(int array[], int length, sort_algo_type sorting,...
You are to write three functions for this lab: mean, remove, display. Download the main.cpp file provided to get started. Read the comments in the main function to determine exactly what the main function should do. //include any standard libraries needed // - Passes in an array along with the size of the array. // - Returns the mean of all values stored in the array. double mean(const double array[], int arraySize); // - Passes in an array, the size...
java
Binary files The binary file data.dat contains characters and numbers- it has 16 characters, followed by numbers of type int alternating with numbers of type double -so after the first 16 characters, there will be an int, followed by a double, followed by an int, followed by a double, and so on. Write a program to open the file and until the end of file is reached, read in the values in the appropriate data types (that is, read...
In the code shown above are
two parts of two different exercises. HOW WE CAN HAVE BOTH OF THEM
ON THE SAME CLASS BUT SO WE CAN RECALL them threw different
methods. Thank you.
1-First exercise
import java.util.Scanner;
public class first {
public static int average(int[] array){
int total = 0;
for(int x: array)
total += x;
return total / array.length;
}
public static double average(double[] array){
double total = 0;
for(double x: array)
total += x;
return total /...
Please program in C++ and document the code as you go so I can understand what you did for example ///This code does~ Your help is super appreciated. Ill make sure to like and review to however the best answer needs. Overview You will revisit the program that you wrote for Assignment 2 and add functionality that you developed in Assignment 3. Some additional functionality will be added to better the reporting of the students’ scores. There will be 11...
#include <stdio.h>
// Define other functions here to process the filled array: average, max, min, sort, search
// Define computeAvg here
// Define findMax here
// Define findMin here
// Define selectionSort here ( copy from zyBooks 11.6.1 )
// Define binarySearch here
int main(void) {
// Declare variables
FILE* inFile = NULL; // File pointer
int singleNum; // Data value read from file
int valuesRead; // Number of data values read in by fscanf
int counter=0; // Counter of...
Make sure to create the code with the given functions, and do not overlook them, do not create your own functions. This is an assignment that I did on my own and that's passed due, therefore, for educational purposes, I am interested to know what are other ways to properly program this. Please follow instructions as I am doing my best to fully understand every crucial detail in order to become a better programmer who is able to come up...
c++ question, i put the txt attachment picture for this
question... please include comments on calculations and
varibles
Description In this program, you will write a program to emulate a vending machine (somewhat). In this version of the program, you will use a struct type defined below struct snackType string name; string code; double price; int remaining; Where name contains the snack's name, code contains the 2 digit code for the item, price holds the item's price, and remaining holds...