Sampled Audio in MATLAB A vector of samples in MATLAB can be played as an audio
ID: 2266952 • Letter: S
Question
Sampled Audio in MATLAB A vector of samples in MATLAB can be played as an audio signal using: sound (x, fs, BITS) where x is the vector (or sequence) of samples, fs is the sampling frequency of the sequence, and BITS is the number of bits used to represent the audio signal in the digital-to-analog converter (DAC) of your sound card. If fs and BITS are not specified, they default to 8192 samples/second and 16 bits/sample. Sinusoids Run MATLAB and create an index vector that will correspond to 2 seconds of time. fs = 8192; % fs # 8192 samples/second, default sample rate % sample period Ts = 1/fs seconds/sample & is inverse of fs % max time is 2 seconds t, max = 2; N tmax/c?> % determine the number of samples that corresponds to 2 seconds of a sampled sequence (care must be taken that n_max is an integer; here the values are arranged so it will be, but try help round and doc ceil for common ways to convert floating point numbers to integer values) n = 0:11(N-1); % maximum value is N-1 since we start at 0 % alternatively we can define N-fs*t-max - Now we create the sine wave signal. Let's create a 440 Hz (concert pitch "A") tone. We take the desired frequency and multiply it by 2n/fs or 2.Ts, which are equivalent. Note that Ts*n is the sampled time in seconds % concert pitch A is 440 Hz We can listen to the signal through the computer's sound card using sound down the volume on your computer before playing a sound. The full scale volume is very loudl sound (x1, fs) sound (e.1*x1, fs) scale the output voltage by 0.1. We would expect this to result in The second call attempts to 20xlog1o(0.1) --20 dB power gain, which would clearly give an audible difference. This rests on a few assumptions, the key one being that the sound card driver isn't one that automatically increases the gain for quiet sounds in an attempt to be helpful.Explanation / Answer
1.
fs = 8192;
Ts = 1/fs;
t_max = 2;
N = t_max/Ts;
f_A1 = 880;
n = 0:1:(N-1);
x2 = sin(2*pi*f_A1*Ts*n);
2. The difference between the two sounds is their pitch. x2 is the octave of x1.
The pitch is synonymous with the frequency and it is the frequency that causes the difference in perception of the two sound.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.