Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem A. (10 points) Musical Key Conversion The chromatic scale is a 12-note scale in music in which all notes are evenly spaced: that is,

Problem A. (10 points) Musical Key Conversion

The chromatic scale is a 12-note scale in music in which all notes are evenly spaced: that is, the ratio of the frequency between any two consecutive notes is constant. The notes are typically labelled in the following sequence:

A, A#, B, C, C#, D, D#, E, F, F#, G, G#

After G#, the labels loop back and start over with A (one octave higher). To convert between musical keys, you can shift all notes in a piece of music a constant number of steps along the scale above. For example, the sequence of notes

E, E, F, G, G, F, E, D, C, C, D, E, E, D, D

can be converted to another musical key by shifting everything up three steps:

E, E, F, G, G, F, E, D, C, C, D, E, E, D, D

G, G, G#, A#, A#, G#, G, F, D#, D#, F, G, G, F, F

Notice that G was converted to A#, since going three steps up required us to loop off of the top of the scale back to the bottom: G -> G# -> A -> A#. Technically we should note that this would be A# of the next octave up, but well ignore that for this problem.

Write a function convert(notes, up) which takes in a list of strings notes, each of which represents one of the 12 possible musical notes listed above, and an integer up, which represents how many steps up the scale the notes should be shifted (if up is a negative number, then need to shift notes down instead). convert should return a new list of strings representing the notes shifted an appropriate number of times.

Hints:

  • This will probably go easier if you have some system to convert notes into numbers and back again, and just use modular arithmetic ( %).

  • Use this list:

scale = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']

Constraints:

  • Do not import/use any Python modules

  • Your submission should have no code outside of function definitions except for comments

Examples:

>>> convert(['G', 'G', 'D', 'D', 'E', 'E', 'D'], 2)

['A', 'A', 'E', 'E', 'F#', 'F#', 'E']

>>> convert(['A', 'A', 'A', 'F', 'C', 'A', 'F', 'C', 'A'], -4)

['F', 'F', 'F', 'C#', 'G#', 'F', 'C#', 'G#', 'F']

>>> convert(['E', 'E', 'F', 'G', 'G', 'F', 'E', 'D', 'C', 'C', 'D', 'E', 'E', 'D', 'D'], 3)

['G', 'G', 'G#', 'A#', 'A#', 'G#', 'G', 'F', 'D#', 'D#', 'F', 'G', 'G', 'F', 'F']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To solve this problem you need to develop a function that shifts musical notes within the chromatic scale by a specified number of steps accounting fo... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago