Question

In this quiz, you will work as an audio engineer to process sampled audio signals. Remember, a signal is a function of time,PLEASE FAST. WRITE IN C LANGUAGE I WILL RATE YOU UP!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have implemented the Signal sampling program , per the given description.

NOTE :PLEASE NOTE THE GIVE OUTPUT IS FOR COSINE VALUE [YOU CAN CHECK cos(0) is '1' ] SO I HAVA

PROVIDED BOTH sin and CoSine output.

Please find the following Code Screenshot, Output, and Code.

ANY CLARIFICATIONS REQUIRED LEAVE A COMMENT

1.CODE SCREENSHOT :

: : Sin Signal Mix.cx 1 /* 2. Name 3 Date 4. Quiz6 : 5 L*/ 6 #include<stdio.h> 7 #include <math.h> //to create sample of size

الية لارا لیا Sin Signal Mix.c x 28 //to mix the two signals 29 şvoid mix(int n, float a, float in1[], float b,float in2[],fl

Sin Signal Mix.cx 53 54 55 56 57 58 59 60 61 62 63 64 65 66 \n); //tmax for ending time, maxVal repsents maxval in clip func

78 79 80 81 82 83 84 85 86 87 88 89 90 91 printArray (n,t,t); //create samples of two Cosine waves getcosinSamples (n,t,y1,

2.OUTPUT :

C. C:\WINDOWS\system32\cmd.exe D:\csrc>gcc SinSignalMix.c P:\csrca -The Sine Sample data- it y1 y2 ymix yclip 0.00 0.00 0.00

3.CODE :

/*
Name  :
Date  :
Quiz6 :
*/
#include<stdio.h>
#include <math.h>
//to create sample of size 'step' and return the number of samples created
int getTimeSamples(float tmin,float tmax,float step,float t[]){
        int j;
        float i;
        for(j=0,i=tmin;i<=tmax+step;j++,i=i+step)
                t[j]=i;
        return j;
}
//to get the sine samples
void getSineSamples(int n,float t[],float y[],float f0){
        //calculate the sin(2*pi*f0*t) for each value of t
        for(int i=0;i<n;i++)
                y[i]=sin(2.0*(22.0/7.0)*f0*t[i]);
}
//to get the CoSine samples
void getCosinSamples(int n,float t[],float y[],float f0){
        //calculate the cos(2*pi*f0*t) for each value of t
        for(int i=0;i<n;i++)
                y[i]=cos(2.0*(22.0/7.0)*f0*t[i]);
}
//to mix the two signals
void mix(int n,float a,float in1[],float b,float in2[],float out[]){
        for(int i=0;i<n;i++)
                out[i]=a*in1[i]+b*in2[i];
}
//the clip function to assign maxVal or in
void clip(int n,float in[],float out[],float maxVal){
        for(int i=0;i<n;i++){
                if(in[i]<maxVal)
                        out[i]=in[i];
                else
                        out[i]=maxVal;
        }
}
//print the array
void printArray(int n,float x[],char label[]){
        int i;
        printf("\n%-6s:  ",label);
        for(i=0;i<n;i++)
                printf("\t%3.2f",x[i]);
}
int main(){
        //variable
        //tmin for starting time
        float tmin=0;
        //tmax for ending time,maxVal repsents maxVal in Clip function
        float tmax=1.0,maxVal=1;
        //the increment of step in sampleing
        float step=0.1;
        //arrays to store time ,sample1,sample2,mix,out
        float t[100],y1[100],y2[100],ymix[100],out[100];;
        int n,a=1,b=1;
        printf("------------------------------------The Sine Sample data------------------------------------\n");
        //Sample the time axis between 0 and 1 with step size of 0.1
        n=getTimeSamples(tmin,tmax,step,t);
        printArray(n,t,"t");
        //create samples of two sin waves
        getSineSamples(n,t,y1,1.0);
        printArray(n,y1,"y1");
        getSineSamples(n,t,y2,2.0);
        printArray(n,y2,"y2");
        //mix the two signals with equals weight a=b=1
        mix(n,a,y1,b,y2,ymix);
        printArray(n,ymix,"ymix");
        //clip the signal
        clip(n,ymix,out,maxVal);
        printArray(n,out,"yClip");
        printf("\n\n------------------------------------The CoSine Sample data------------------------------------\n");
        //Sample the time axis between 0 and 1 with step size of 0.1
        n=getTimeSamples(tmin,tmax,step,t);
        printArray(n,t,"t");
        //create samples of two CoSine waves
        getCosinSamples(n,t,y1,1.0);
        printArray(n,y1,"y1");
        getCosinSamples(n,t,y2,2.0);
        printArray(n,y2,"y2");
        //mix the two signals with equals weight a=b=1
        mix(n,a,y1,b,y2,ymix);
        printArray(n,ymix,"ymix");
        //clip the signal
        clip(n,ymix,out,maxVal);
        printArray(n,out,"yClip");
}

/*
OUTPUT:
D:\csrc>gcc SinSignalMix.c

D:\csrc>a
------------------------------------The Sine Sample data------------------------------------

t     :         0.00    0.10    0.20    0.30    0.40    0.50    0.60    0.70    0.80    0.90    1.00
y1    :         0.00    0.59    0.95    0.95    0.59    -0.00   -0.59   -0.95   -0.95   -0.59   0.00
y2    :         0.00    0.95    0.59    -0.59   -0.95   0.00    0.95    0.58    -0.59   -0.95   0.01
ymix  :         0.00    1.54    1.54    0.36    -0.36   0.00    0.36    -0.37   -1.54   -1.54   0.01
yClip :         0.00    1.00    1.00    0.36    -0.36   0.00    0.36    -0.37   -1.54   -1.54   0.01

------------------------------------The CoSine Sample data------------------------------------

t     :         0.00    0.10    0.20    0.30    0.40    0.50    0.60    0.70    0.80    0.90    1.00
y1    :         1.00    0.81    0.31    -0.31   -0.81   -1.00   -0.81   -0.31   0.31    0.81    1.00
y2    :         1.00    0.31    -0.81   -0.81   0.31    1.00    0.31    -0.81   -0.81   0.31    1.00
ymix  :         2.00    1.12    -0.50   -1.12   -0.50   -0.00   -0.50   -1.12   -0.50   1.12    2.00
yClip :         1.00    1.00    -0.50   -1.12   -0.50   -0.00   -0.50   -1.12   -0.50   1.00    1.00
D:\csrc>

*/

ANY CLARIFICATIONS/MODIFICATIONS REQUIRED LEAVE A COMMENT

IF YOU ARE SATISFIED WITH THE ASNWER PLEASE LIKE THE POST

Add a comment
Know the answer?
Add Answer to:
PLEASE FAST. WRITE IN C LANGUAGE I WILL RATE YOU UP!! In this quiz, you will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please I need help in C language, I am trying to modify the code per the...

    Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions:                  1.      First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....

  • What to do Write a C program that computes Pi with the approximation algorithm that I...

    What to do Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways: The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get_pi_for(void); The second version will break out of a while loop depending on whether a pair of...

  • For this computer assignment, you are to write a C++ program to implement a class for...

    For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...

  • using C++ language!! please help me out with this homework In this exercise, you will have...

    using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the...

    COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the algorithm for a AppStore programming assignment. The details of the assignment, a sample algorithm, and its outline, are located below. Make the algorithm at least half a page, easy to read, and to understand, how it works. I just want the algorithm, not the programming code, I have that. I only need the ALGORITHM. Thanks for helping me out, I apprieciate it, have a...

  • LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which...

    LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which has six working functions that use looping (for, while, or do loops) to repeat the same set of statements multiple times. You will create six equivalent functions that use recursion instead of looping. Although looping and recursion can be interchanged, for many problems, recursion is easier and more elegant. Like loops, recursion must ALWAYS contain a condition; otherwise, you have an infinite recursion (or...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • The following results were obtained from an undrained shear box test carried out on a set...

    The following results were obtained from an undrained shear box test carried out on a set of undisturbed soil samples. 0.2 0.8 Normal Load (N) Strain (%) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 0 21 46 70 89 107 121 131 136 138 138 137 136 0.4 Shearing force (N) 0 33 72 110 139 164 180 192 201 210 217 224 230 234 237 236 0 45...

  • The following results were obtained from an undrained shear box test carried out on a set...

    The following results were obtained from an undrained shear box test carried out on a set of undisturbed soil samples. 0.2 0.8 Normal Load (N) Strain (%) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 0 21 46 70 89 107 121 131 136 138 138 137 136 0.4 Shearing force (N) 0 33 72 110 139 164 180 192 201 210 217 224 230 234 237 236 0 45...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT