You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: projects/m1/011-note-to-frequency/README.md
+34-10Lines changed: 34 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,35 @@ with their frequencies.
14
14
| B4 | 493.88 |
15
15
16
16
17
-
Begin by writing a program that reads the name of a note from the user and displays the note’s frequency.
18
-
Your program should support all of the notes listed previously.
17
+
Begin by writing a program that **reads the name of a note** from the user and **displays the note’s frequency**.
18
+
Your program should support all the notes listed previously.
19
19
20
-
Once you have your program working correctly for the notes listed previously you should add support for all of the notes from C0 to C8.
21
-
While this could be done by adding many additional cases to your if statement, such a solution is cumbersome, inelegant and unacceptable for the purposes of this exercise.
20
+
Once you have your program working correctly for the notes listed previously
21
+
you should add support for all the notes from C0 to C8.
22
+
While this could be done by adding many additional cases to your if statement, such a solution is cumbersome,
23
+
inelegant and unacceptable for the purposes of this exercise.
22
24
Instead, you should exploit the relationship between notes in adjacent octaves.
23
-
In partic- ular, the frequency of any note in octave n is half the frequency of the corre- sponding note in octave n + 1.
24
-
By using this relationship, you should be able to add support for the additional notes without adding additional cases to your if statement.
25
+
In particular, **the frequency of any note in octave n is half the frequency of the corresponding note in octave n + 1.**
26
+
By using this relationship, you should be able to add support for the additional notes without
27
+
adding additional cases to your if statement.
25
28
26
-
Hint: You will want to access the characters in the note entered by the user individually when completing this exercise.
27
-
Begin by separating the letter from the octave.
28
-
Then compute the frequency for that letter in the fourth octave using the data in the table above. Once you have this frequency you should divide it by 2<sup>4−x</sup> ,
29
-
where x is the octave number entered by the user. This will halve or double the frequency the correct number of times.
29
+
Hint:
30
+
You will want to access the characters in the note entered by the user individually when completing this exercise.
31
+
Begin by separating the letter from the octave.
32
+
Then compute the frequency for that letter in the fourth octave using the data in the table above.
33
+
Once you have this frequency you should divide it by 2<sup>4−x</sup> ,
34
+
where x is the octave number entered by the user.
35
+
This will halve or double the frequency the correct number of times.
30
36
37
+
Example:
38
+
Input = F6
39
+
Output = 1396.9
31
40
41
+
42
+
Input = B0
43
+
Output = 30.8
44
+
45
+
https://pages.mtu.edu/~suits/notefreqs.html
32
46
# Documentation
33
47
34
48
For this project solution you may use:
@@ -38,6 +52,16 @@ For this project solution you may use:
0 commit comments