Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implementation Details The only Python libraries you are permitted to use for this assignment are os and sys. You are to write a Python Program

Implementation Details The only Python libraries you are permitted to use for this assignment are os and sys. You are to write a Python Program that takes a command line argument indicating the path to a score file containing the periods over which the noise sources are playing. Using this and a number of sources in a provided sources folder you are to then construct what the resulting wave is.

It is important to note that your program will be marked automatically, so make sure that you follow the assignment specification carefully, your programs output must exactly match that shown in the examples. An arbitrarily placed command line argument should be a path to the score file. python waveform.

py No score file specified.

python waveform.py qwop Invalid path to score file.

python waveform.py --character=b No score file specified.

With a score file score: piano |*********************| And instrument file piano: 3 --- 2 / \ 1 / \ 0 --- \ --- -1 \ / -2 \ / -3 --- Note that the character directly after the number is a tab character (\t) and the rest of the characters in the line are either spaces, slashes or dashes.

We can then print the final waveform python waveform.py score piano: 3: *** 2: * * 1: * * 0: *** * *** -1: * * -2: * * -3: *** Modifying the score we can see that the source gets interrupted and restarted.

piano |*********-***********| piano: 3: *** *** 2: * * * * 1: * * * * 0: *** **** * Introduction to Programming Page 2 of 7 INFO1110 / COMP9001 Taking a second example, we have the following kazoo file in the instruments folder. Once again the character directly after the amplitude is a tab.

6 --- 5 / \ 4 / \ 3 / \ 2 / \ 1 / \ 0 --- --- Heres the score for our kazoo: kazoo |---*******---********---| And we can see how the kazoo wave gets restarted when the asterisks stop in the score. kazoo: 5: * 4: * * * 3: * * * * 2: * * * * 1: * * * * 0: ****** ****** *** If an instrument is specified in the score file that doesnt have a corresponding file in the instruments folder it should print Unknown Source. pian0000 |*********-***********| python waveform.py score Unknown source. Our score file should be able to specify multiple channels, these waves should be additive. piano |*********----------| |-----------********| piano: 3: *** *** 2: * * * 1: * * * 0: *** ***** Introduction to Programming Page 3 of 7 INFO1110 / COMP9001 piano |****************---| |--*****************| piano: 6: * 5: * * 4: * * 3: * * 2: * * 1: * * 0: *** * -1: * -2: * * -3: * ** -4: * * -5: * * -6: * With a judiciously selected score we can also see the waves cancel out completely. piano |-*******************-| |---------***********-| piano: 3: *** 2: * * 1: * * 0: **** ********** You should also be able to display multiple instruments separately (in the same order that they are specified in the score file). Introduction to Programming Page 4 of 7 INFO1110 / COMP9001 piano |****************---| violin |--*****************| piano: 3: *** 2: * * 1: * * 0: *** * *** -1: * * -2: * * -3: *** violin: 3: *** 2: * * 1: * * 0: ***** *** -1: * -2: * -3: ** The character flag should be able to change the character that is used to print the wave. piano |*************---| python waveform.py score --character=q piano: 3: qqq 2: q q 1: q q 0: qqq q qqq -1: q q -2: q If more than one character is specified, only the first is printed python waveform.py score --character=wq piano: 3: www 2: w w 1: w w 0: www w www -1: w w -2: w Introduction to Programming Page 5 of 7 INFO1110 / COMP9001 The total flag instead adds all the instruments into a single wave piano |*************---| violin |**************| python waveform.py ./score --total Total: 6: *** 5: * * 4: * * 3: * * 2: * * 1: * * 0: *** * ** -1: * * -2: * Of course Both of these flags may be combined in any order python waveform.py --total score --character=2 Total: 6: 222 5: 2 2 4: 2 2 3: 2 2 2: 2 2 1: 2 2 0: 222 2 22 -1: 2 2 -2: 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

The brain emits large, slow delta waves during sleep.

Answered: 1 week ago

Question

using signal flow graph

Answered: 1 week ago