Set up a Matlab vector to play the .Parameter Values: notes in the C-major scale
ID: 2268416 • Letter: S
Question
Set up a Matlab vector to play the .Parameter Values: notes in the C-major scale o Play using soundsc o Spectrogram using. Set up a Matlab vector to play several different chords o Sample frequency: 8 kHz o Note duration for scale: 0.5 sec o Chord duration: 2 sec o Use the vales given in section 3.6 o Text p. 82 describes computing o Try different combinations and fine a good sounding 2-note chord o Play using soundsc o Spectrogram using. frequency from note index spectrogram function, Signal Analyzer App, or Spectrum Analyzer block ·Q2: Explain what you think makes a chord sound pleasant
Explanation / Answer
Code:
function y =nsound(note,duration)
note='C3'; % For example, you can use any.
duration=2;
% American standard for finding frequency for notes.
switch note
case 'C3'
f=130.81;
case 'C#3'
f=138.59;
case 'D3'
f=146.83;
case 'D#3'
f=155.56;
case 'E3'
f=164.81;
case 'F3'
f=174.61;
case 'F#3'
f=185.00;
case 'G3'
f=196.00;
case 'G#3'
f=207.65;
case 'A3'
f=220.00;
case 'A#3'
f=233.08;
case 'B3'
f=246.94;
case 'C4'
f=261.63;
case 'C#4'
f=277.18;
case 'D4'
f=293.66;
case 'D#4'
f=311.13;
case 'E4'
f=329.63;
case 'F4'
f=349.23;
case 'F#4'
f=369.99;
case 'G4'
f=392.00;
case 'G#4'
f=415.30;
case 'A4'
f=440.00;
case 'A#4'
f=466.16;
case 'B4'
f=493.88;
case 'C5'
f=523.25;
case 'C#5'
f=554.37;
case 'D5'
f=587.33;
case 'D#5'
f=622.25;
case 'E5'
f=659.26;
case 'F5'
f=698.46;
case 'F#5'
f=739.99;
case 'G5'
f=783.99;
case 'G#5'
f=830.61;
case 'A5'
f=880.00;
case 'A#5'
f=932.33;
case 'B5'
f=987.77;
case 'p'
f=000.00;
otherwise
error('Not a recognized note')
end
s=8000; % Sampling frequencyie 8kHz.
t=0:1/s:duration;
y=sin(2*pi*f*t);
sound(y,s) % MATLAB's SOUND function to produce the note on speakers
Output:
>> cnote
ans =
Columns 1 through 12
0 0.1026 0.2040 0.3034 0.3995 0.4914 0.5781 0.6588 0.7324 0.7984 0.8559 0.9045
Columns 13 through 24
0.9434 0.9725 0.9912 0.9996 0.9973 0.9846 0.9615 0.9282 0.8852 0.8328 0.7716 0.7023
Columns 25 through 36
0.6256 0.5423 0.4532 0.3594 0.2618 0.1615 0.0594 -0.0433 -0.1455 -0.2462 -0.3443 -0.4388
Columns 37 through 48
-0.5286 -0.6129 -0.6907 -0.7612 -0.8237 -0.8775 -0.9221 -0.9569 -0.9816 -0.9960 -0.9999 -0.9932
Columns 49 through 60
-0.9761 -0.9487 -0.9112 -0.8642 -0.8080 -0.7434 -0.6708 -0.5912 -0.5054 -0.4143 -0.3187 -0.2198
Columns 61 through 72
-0.1186 -0.0162 0.0865 0.1882 0.2879 0.3846 0.4772 0.5649 0.6465 0.7213 0.7886 0.8475
Columns 73 through 84
0.8974 0.9380 0.9686 0.9890 0.9989 0.9984 0.9873 0.9658 0.9341 0.8926 0.8416 0.7818
Columns 85 through 96
0.7137 0.6381 0.5558 0.4676 0.3745 0.2774 0.1774 0.0756 -0.0271 -0.1295 -0.2305 -0.3291
Columns 97 through 108
-0.4242 -0.5148 -0.6000 -0.6789 -0.7506 -0.8144 -0.8696 -0.9157 -0.9521 -0.9784 -0.9945 -1.0000
Columns 109 through 120
-0.9950 -0.9795 -0.9537 -0.9178 -0.8722 -0.8175 -0.7541 -0.6827 -0.6042 -0.5193 -0.4289 -0.3340
Columns 121 through 132
-0.2356 -0.1347 -0.0323 0.0703 0.1723 0.2724 0.3696 0.4630 0.5514 0.6341 0.7100 0.7785
Columns 133 through 144
0.8388 0.8902 0.9322 0.9644 0.9864 0.9981 0.9992 0.9897 0.9699 0.9398 0.8997 0.8502
Columns 145 through 156
0.7918 0.7250 0.6505 0.5692 0.4818 0.3894 0.2929 0.1933 0.0917 -0.0109 -0.1134 -0.2147
Columns 157 through 168
-0.3138 -0.4095 -0.5009 -0.5870 -0.6669 -0.7398 -0.8049 -0.8616 -0.9091 -0.9470 -0.9750 -0.9926
Columns 169 through 180
-0.9998 -0.9965 -0.9826 -0.9584 -0.9241 -0.8800 -0.8267 -0.7646 -0.6945 -0.6170 -0.5331 -0.4435
Columns 181 through 192
-0.3492 -0.2513 -0.1507 -0.0485 0.0542 0.1563 0.2568 0.3546 0.4486 0.5379 0.6215 0.6986
Columns 193 through 204
0.7683 0.8299 0.8827 0.9263 0.9600 0.9837 0.9969 0.9997 0.9919 0.9737 0.9452 0.9067
Columns 205 through 216
0.8586 0.8015 0.7360 0.6627 0.5824 0.4959 0.4043 0.3083 0.2092 0.1078 0.0052 -0.0974
Columns 217 through 228
-0.1989 -0.2984 -0.3947 -0.4868 -0.5738 -0.6548 -0.7289 -0.7952 -0.8532 -0.9022 -0.9417 -0.9712
Columns 229 through 240
-0.9905 -0.9994 -0.9977 -0.9855 -0.9629 -0.9301 -0.8876 -0.8357 -0.7749 -0.7060 -0.6297 -0.5467
Columns 241 through 252
-0.4579 -0.3643 -0.2669 -0.1666 -0.0646 0.0380 0.1403 0.2411 0.3394 0.4341 0.5242 0.6087
Columns 253 through 264
0.6869 0.7578 0.8207 0.8750 0.9200 0.9554 0.9806 0.9955 1.0000 0.9938 0.9772 0.9503
Columns 265 through 276
0.9134 0.8668 0.8111 0.7468 0.6747 0.5955 0.5099 0.4190 0.3237 0.2249 0.1238 0.0214
Columns 277 through 288
-0.0812 -0.1830 -0.2829 -0.3798 -0.4726 -0.5605 -0.6425 -0.7177 -0.7853 -0.8447 -0.8951 -0.9361
Columns 289 through 300
-0.9673 -0.9882 -0.9987 -0.9987 -0.9881 -0.9671 -0.9360 -0.8949 -0.8444 -0.7850 -0.7174 -0.6421
Columns 301 through 312
-0.5601 -0.4722 -0.3793 -0.2824 -0.1826 -0.0808 0.0219 0.1243 0.2254 0.3241 0.4194 0.5103
Columns 313 through 324
0.5958 0.6751 0.7472 0.8114 0.8671 0.9136 0.9505 0.9773 0.9939 1.0000 0.9955 0.9805
Columns 325 through 336
0.9552 0.9198 0.8748 0.8205 0.7575 0.6866 0.6084 0.5238 0.4336 0.3389 0.2407 0.1399
Columns 337 through 348
0.0376 -0.0651 -0.1671 -0.2673 -0.3648 -0.4583 -0.5471 -0.6300 -0.7064 -0.7752 -0.8359 -0.8878
Columns 349 through 360
-0.9303 -0.9630 -0.9856 -0.9977 -0.9994 -0.9905 -0.9711 -0.9415 -0.9020 -0.8530 -0.7950 -0.7285
Columns 361 through 372
-0.6545 -0.5735 -0.4864 -0.3942 -0.2979 -0.1984 -0.0969 0.0057 0.1082 0.2096 0.3088 0.4047
Columns 373 through 384
0.4964 0.5828 0.6630 0.7363 0.8018 0.8589 0.9069 0.9453 0.9738 0.9920 0.9997 0.9969
Columns 385 through 396
0.9836 0.9599 0.9261 0.8825 0.8296 0.7680 0.6982 0.6211 0.5375 0.4482 0.3541 0.2563
Columns 397 through 408
0.1558 0.0537 -0.0490 -0.1511 -0.2517 -0.3497 -0.4439 -0.5335 -0.6174 -0.6948 -0.7649 -0.8269
Columns 409 through 420
-0.8802 -0.9243 -0.9585 -0.9827 -0.9965 -0.9998 -0.9926 -0.9749 -0.9469 -0.9089 -0.8613 -0.8047
Columns 421 through 432
-0.7395 -0.6666 -0.5866 -0.5005 -0.4091 -0.3133 -0.2143 -0.1130 -0.0105 0.0921 0.1938 0.2934
Columns 433 through 444
0.3899 0.4823 0.5696 0.6509 0.7253 0.7921 0.8505 0.9000 0.9399 0.9700 0.9898 0.9992
Columns 445 through 456
0.9980 0.9864 0.9643 0.9321 0.8900 0.8385 0.7782 0.7097 0.6337 0.5510 0.4625 0.3692
Columns 457 through 468
0.2719 0.1718 0.0699 -0.0328 -0.1351 -0.2360 -0.3345 -0.4294 -0.5197 -0.6046 -0.6831 -0.7544
Columns 469 through 480
-0.8177 -0.8725 -0.9180 -0.9538 -0.9796 -0.9950 -1.0000 -0.9944 -0.9783 -0.9519 -0.9155 -0.8694
Columns 481 through 492
-0.8142 -0.7503 -0.6786 -0.5996 -0.5144 -0.4238 -0.3286 -0.2300 -0.1290 -0.0266 0.0760 0.1779
Columns 493 through 504
0.2779 0.3749 0.4680 0.5562 0.6385 0.7141 0.7821 0.8419 0.8928 0.9343 0.9659 0.9874
Columns 505 through 516
0.9984 0.9989 0.9889 0.9685 0.9378 0.8972 0.8472 0.7883 0.7210 0.6461 0.5645 0.4768
Columns 517 through 528
0.3842 0.2874 0.1877 0.0860 -0.0166 -0.1191 -0.2203 -0.3192 -0.4147 -0.5058 -0.5916 -0.6712
Columns 529 through 540
-0.7437 -0.8083 -0.8644 -0.9114 -0.9488 -0.9762 -0.9933 -0.9999 -0.9960 -0.9815 -0.9568 -0.9219
Columns 541 through 552
-0.8773 -0.8234 -0.7609 -0.6903 -0.6125 -0.5282 -0.4383 -0.3439 -0.2457 -0.1450 -0.0428 0.0599
Columns 553 through 564
.... and so on
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.