[SOLVED] 代写 C matlab scala theory Background

30 $

File Name: 代写_C_matlab_scala_theory_Background.zip
File Size: 367.38 KB

SKU: 4223897331 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Background
BMME 201 Summer 20189 PA3: Jukebox
Due: Friday, 5/31, at 8 pm
Kids these days have no appreciation for the old 8-bit musical masterpieces of yesteryear. Once upon a time, simple MIDI music was the default, and we loved it. We weren’t all about that bass, we were all about tinny synthesized music. And if we wanted to hear music, we couldn’t use iPods, Pandoræ, or Spotifys. Put a nickel into the jukebox, choose your groovy tunes, and then show off your bellbottoms, not your stanky legs or nae naes, at the discotheque.
Simple notes are easy to create in MATLAB (see Theory section and zyBooks 6.2), and you have several music files that former students and I have written for you. Your goal is to make a souped-up jukebox that not only plays the tune but can also modify it.
Note that once a song starts playing, you have to wait until it is finished. You cannot Ctrl- C out of it. Prepare to hate some songs, and consider checking your code with the scale.
Problem
Create a jukebox using at least 8 pieces posted as functions online. Catch any non-valid choices; e.g., if you ask for a number between 1 and 10 and they type 42.1, keep prompting until they get it right. The file “jukebox_outline.m” is a template for your program in which you will need to fill in the sections so that your code does the following:
1. Prompts the user to enter a number that corresponds to a particular song with a menu. Catch any non-valid numerical entries, including decimals, but don’t worry about strings/characters. Continue to prompt until the user enters a valid option. Then, depending on the number they select, call one of the musical functions and save it to the variable song.
2. Ask the user if they want to increase/decrease the volume, then do/don’t do it.
3. Ask the user if they want to play the song backwards, then do/don’t do it.
4. Ask the user if they want to add a diminuendo (fade) over the last two bars, then
do/don’t do it.
5. Play the song using sound(y,rate), where y is the output of the musical
functions, and rate is the sampling frequency, 32768 Hz.
6. Wait until the song is finished, then say some kind/mean parting words at the end
(or show your menu again).
You do NOT have to catch bad inputs in steps 2-4 (and the extra parts), only in step 1. Also, feel free to disregard the template file, since some things are easier to do by asking the user for all their selections BEFORE reading the song function.
Doing the above steps perfectly will earn a 75/100. For a higher score, add the features listed below. Each is worth up to 5 points.
 Add random song choice (hint: use the function randi).
 Create your own melody in a separate .m file. Include it in your submission. It
does NOT have to be complex, but it should be more than a few random notes.
 Enclose almost all of the code in a loop so that it continues until the user decides
to quit. When asking to select a song, have an option to quit. The user should

BMME 201 Summer 20189 PA3: Jukebox
Due: Friday, 5/31, at 8 pm
NOT have to listen to a song first before quitting. This may be an opportunity for
the forbidden break…
 Give the user an option to play the song as a two-part round. A round is when
one part starts, then the other starts (in this case) one second later; e.g., “Row
Row Row Your Boat.”
 Give the user another modification option melody besides diminuendo/fade,
volume change, flipping, and round. Cannot be crescendo (opposite of fade).
Please submit ONLY your jukebox.m script and any song(s) you create. You do not need to submit .m files for the songs that were posted.
Theory
Sound waves are sinusoidal longitudinal waves, and the pitch is determined by the frequency. The lowest note is a C0, which has an approximate frequency of 16.3516 Hz. A C1 would be 16.3516*2^1 = 32.7032 Hz; a C3 would be 16.3516*2^3 = 130.8128 Hz, etc. See https://en.wikipedia.org/wiki/A_(musical_note) for more details about octaves. Note that you don’t have to worry about this yet, but it may help with composition.
To make music in MATLAB at the most basic level, I’ve used the anonymous function note to create a sine wave whose frequency is defined by the function call. The playback sample rate is 32,768 Hz (close to the CD standard but lower for easy music writing), so that there are 32,768 points per second of playback time. A sample waveform is shown below for a fraction of a second:
5 Hz wave (below your hearing)
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8
-10 0.5 1 1.5 2 2.5 3 3.5 4 4.5
Samples
x 104
Normalized intensity

BMME 201 Summer 20189 PA3: Jukebox
Due: Friday, 5/31, at 8 pm
To write your own music, you’ll define the music note, pitch, and length. See the examples that I’ve written. The easiest way is to write a melody in the first row of a matrix and the harmony in the second row. Technically you’re writing the audio file for a left and right speaker for stereo sound, but it’s easier to create single notes instead of modulating several voices in one single waveform. The program then combines the two rows at the end into a single vector. See the Passacaglia for a more complicated way of defining chords. The function note takes the duration, note, and octave.
Hints
 TEST YOUR CODE INCREMENTALLY. Don’t try to code all steps at once. First test the regular song and make sure it works after user selection. Then change the volume, then play it backwards, then add the diminuendo (see the siren code for an example). By building your code a few lines at a time, you can make debugging much easier.
 When testing code, it’s best to comment out the input line and hardcode the value. That way when you run a later part of the code, you do not have to type an input at each step along the way. Don’t forget to uncomment your code and remove the hardcoded inputs before submitting your program.
 Be sure to open a song function and read the comments about inputs and outputs. Also, you may want to play the song from the command window to make sure that it works. For example, sound(DiesIrae(0,0,32768),32768) will play Dies Irae in the default octave and at the default speed.
 You want them to enter a scalar for the song selection. How can you verify that the number is a scalar? The function isinteger will NOT work as you’re hoping, but there are several other ways.
 The audio playback becomes garbled and metallic sounding for large volumes. This is normal; don’t worry about it.
 For the round, recall that you can play as many songs at once as you’d like using the sound function.
 There are many ways to write this code, so if you prefer, you do not have to use my outline.
 Achieve immortality by making a good extra song and being featured in the BME jukebox forever.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 C matlab scala theory Background
30 $