Starting from:

$35

COMP2300-Assignment 2 Part-1 Solved

In assignment 2 you need to program your discoboard to schedule/trigger a sequence of “notes”, each with a different pitch/duration/loudness. As in assignment 1, the focus is on controlling the behaviour of your discoboard with assembly code rather than doing a bunch of music theory.

This assignment will again have two parts: in Part 1, you need to play a specific sequence of notes with specific timing. In Part 2, you can generate a new sequence of your own creation to demonstrate the capabilities of your sequencer.

Background
Sequencers are tools for “scheduled execution”, playing the right note at the right time, and they have been instrumental in electronic music history. Drum sequencers, like the classic Roland TR-909 drum sequencer—a piece of electronic hardware designed for sequencing drum patterns—led to the development of electronic dance music, such as Daft Punk’s Revolution 909 from their classic album Homework (1997).

Sequencers aren’t limited to making drum sounds—the pattern they generate might be a sequence of musical notes, like in a bassline or melody line. In fact, this core concept is not even unique to music—the same ideas are found in scheduling, robotics, cyberphysical systems, and a bunch of other domains. The key idea is that sequencing is a way of controlling a device to perform certain actions at certain times.

Part 1 (50%)
In Part 1, you must program your discoboard to play a specific sequence of notes—and you have 2 options this time, pick 1:

In the Hall of the Mountain King from “Peer Gynt”
Song of Storms from Legend of Zelda
All options are considered of equal difficulty and will be marked to the same standard (see the marking section for part 1)—ie. you will not gain or lose marks for picking one option over another.

We have provided a list of note names, frequencies, and durations for each song (including the gaps/silence in between the notes). These “pitch tables” contain the timing and frequencies we will use to mark part-1.

We have also included a list of the notes (as letter names), just in case you would like to sing/play them yourself, but please use the frequency/duration tables for producing your solution.

No matter which song you pick, your sequencer must:

use an audible square wave sound (you can re-use your code from Assignment 1, but make sure to note it in the SoO) (the duty cycle is not important)
loop forever—i.e. such that when the sequence finishes playing, it starts again from the beginning (with no interruption to the timing)
Setting up and playing audio is the exact same as assignment 1.

In the Hall of the Mountain King - Peer Gynt
 
We’ve also done these in an online sequencing software for your preview-ing pleasure.

Note
Frequency
Duration
B2
123.47 Hz
0.22 s
C#3
138.59 Hz
0.22 s
D3
146.83 Hz
0.22 s
E3
164.81 Hz
0.22 s
F#3
184.99 Hz
0.22 s
D3
146.83 Hz
0.22 s
F#3
184.99 Hz
0.44 s
F3
174.61 Hz
0.22 s
C#3
138.59 Hz
0.22 s
F3
174.61 Hz
0.44 s
E3
164.81 Hz
0.22 s
C3
130.81 Hz
0.22 s
E3
164.81 Hz
0.44 s
B2
123.47 Hz
0.22 s
C#3
138.59 Hz
0.22 s
D3
146.83 Hz
0.22 s
E3
164.81 Hz
0.22 s
F#3
184.99 Hz
0.22 s
D3
146.83 Hz
0.22 s
F#3
184.99 Hz
0.22 s
B3
246.94 Hz
0.22 s
A3
220 Hz
0.22 s
F#3
184.99 Hz
0.22 s
D3
146.83 Hz
0.22 s
F#3
184.99 Hz
0.22 s
A3
220 Hz
0.44 s
silence
0 Hz
0.44 s
If you feel like going the extra mile, for street cred.

Song of Storms - Legend of Zelda
 
We’ve also done these in an online sequencing software for your preview-ing pleasure.

Note
Frequency
Duration
D4
293.66 Hz
0.15 s
F4
349.23 Hz
0.15 s
D5
587.33 Hz
0.6 s
D4
293.66 Hz
0.15 s
F4
349.23 Hz
0.15 s
D5
587.33 Hz
0.6 s
E5
659.25 Hz
0.45 s
F5
698.46 Hz
0.15 s
E5
659.25 Hz
0.15 s
F5
698.46 Hz
0.15 s
E5
659.25 Hz
0.15 s
C5
523.35 Hz
0.15 s
A4
440 Hz
0.45 s
silence
0 Hz
0.15 s
A4
440 Hz
0.3 s
D4
293.66 Hz
0.3 s
F4
349.23 Hz
0.15 s
G4
392.00 Hz
0.15 s
A4
440 Hz
0.75 s
silence
0 Hz
0.15 s
A4
440 Hz
0.3 s
D4
293.66 Hz
0.3 s
F4
349.23 Hz
0.15 s
G4
392.00 Hz
0.15 s
E4
329.63 Hz
0.9 s
Part 1 Marks
Marks will be awarded for:

generating notes with a square wave (duty cycle does not matter)
playing the notes with the correct pitches (frequency)
playing the notes at the correct tempo (timing)
code structure, readability & modularity (including comments & use of functions)
how modular your sequencer is—that is how easy is it to change what sequence / song is played (to have the possibility of full marks for this part you will need to use a data structure, such as an array, to store the song’s data).
For questions around frequency accuracy, please read this section.

Part 2 (50%)
In Part 2, your task is to make a more advanced sequencer. Your program must generate a musical signal which plays indefinitely (either by “looping” a finite sequence or by coming up with a continuous stream of new notes). You may extend the sequences from part 1, but the sequence must demonstrate the more advanced features of your sequencer.

Keep in mind that your job here is to make a cool sequencer, not a cool song, or a cool synth. As written above, a sequencer’s focus is scheduled execution of musical patterns, so you need to create a program than can schedule execution of more complex, or multiple, musical patterns, or do so with more utility than the very simple sequencer you create for part-1.

Here are a few ideas, in roughly increasing order of difficulty:

Create a sequencer that sequences more aspects of music than just pitch and duration. E.g., it could continuously change another aspect of music such as dynamics (loudness/softness) or timbre (type of waveform) on a note-by-note basis.
Create a sequencer that plays songs that are stored in a more interesting format (or a subset of the format), e.g., ASCII text - see ABC notation, or MIDI bytes.
Create a sequencer that can play multiple notes simultaneously to create harmony (also called polyphony in synth lingo). This could also be used to play multiple instrument tracks of the same song at the same time (e.g., keyboard and bass).
create a sequencer that uses an amplitude envelope to change the “shape” of your notes, with envelope parameters that change during playback.
create a polyphonic drum machine that sequences non-pitched (e.g., percussive) sounds with sequenceable envelopes and synthesis parameters.
Marks for Part 2 will be awarded for a design document describing what you’re doing and how you implemented it in ARM assembly language. You need to explain the “what”, “how” and “why” (design, implementation, and analysis) of what you have done. Although it’s ok if you don’t do something super-complex, we do take the sophistication of your sequencer into account. Using images/diagrams is encouraged. Your design document must be in pdf format (2 pages content + appendix + references) with the filename design-document.pdf in top-level folder on the part-2 branch.

Please note that your design document should focus on the sequencer you have created and not on the song you have played. If you have chosen a specific song to showcase the capabilities of your sequencer then talk about those capabilities and how they are demonstrated. For more tips on how to write a design document, check out this page.

 

Checklist

the code in my part-1 branch generates one sequence of notes of the songs described in Part 1
the code in my part-2 branch generates a different sequence as described in Part 2 and I’ve committed my design-document.pdf to the repo under the base folder of the part-2 branch as well
my statement-of-originality.yml files for both Part 1 and Part 2 include all the necessary references/acknowledgements, and everything not mentioned in there is my own work
both branches of my completed project have been pushed to the GitLab server
both branches pass the Gitlab CI test (the pipeline does not fail)
FAQ
You can ask a question on the COMP2300 forum and if it’s popular enough I’ll put it up here.

Also, remember that there’s lots of helpful info on the FAQ page which applies to all assignments. You should check it (and the rest of that page) out—I think it’ll really help.

Sample plotter
In general you shouldn’t need to use the sample plotter in assignment 2. However, if you want to use the sample plotter, then you need to comment out some of the code in lib/init.S. Specifically line 23 to line 28.

We’ve included this delay because there is a small amount of time after init has been called, in which samples are not actually played. Having this delay means that the first note you hear is not slightly shorter than it should be.

Make sure you do not leave this uncommented as this will result in the sequence not playing correctly and will leave you with timing issues on the initial note (and thus lose you marks).

Part 1
Is the setup code (init and BSP_AUDIO_OUT_Play_Sample) the same as in assignment 1?
Yes. Pretty much, unless you’re using the sample plotter.

How close to the exact frequencies & timings does my sequence have to be?
 

As close to what’s achievable in a whole number of samples (so you don’t have to do multi-cycle period averaging this time around) but if you’re off by more than that you will still lose marks.

Similarly for the timings; if a human, looking at their watch, would agree that the timings are correct, then that’s ok. If the timing is way off, however, then that’s a problem.

Assignment 2 isn’t primarily about the base waveform (that’s what assignment 1 was about). In this assignment the most important thing is the way you trigger the sequence—getting the start & stop times of the various notes right, making sure it loops seamlessly (i.e., that you can tap your foot along to the sequence, even across the loop boundary).

Is there a requirement on the dynamic range this time around?
No, although if you look above it says that the waveform must be audible—i.e. that a person with normal hearing can hear it comfortably using headphones. If you use a similar amplitude to what you used for your wave in assignment 1 then you’ll be fine.

If I generate the right sequence of notes, then I get 100% for Part 1, right?
No, that’s not how it works. As described above, code structure, modularity & readability are part of the marking criteria as well.

Part 2
Can I use a part 1 song in part 2?
 

You may use songs from part 1 in your part 2, but, since part 2 requires a more advanced sequencer, you will have to extend the song in some way (e.g., sequencing volume and timbre, playing multiple notes at once) to demonstrate the changes you have made with your sequencer. If you simply play a different part 1 song without adding extra information or a more advanced sequencer you will not get any marks for part 2.

You don’t have to reuse the songs, your sequence(s) for part 2 can be as simple (chromatic scale) or complex (Beethoven Symphony No. 9) as you like—but it has to demonstrate your new sequencer.

I’m not musical—does that mean I can’t get a good mark for Part 2?
No—there are heaps of things you can do which don’t require musical knowledge. As always, start thinking about this stuff early, experiment and see what sounds good to your ears, and ask for help early if you get stuck.

The most important thing for Part 2 is that you clearly explain in your design document what (if anything) is special about the sequence you’re generating (use pictures!) and how you designed your assembly program (sequencer) to generate this sequence.

Can I play a song for Part 2?
Yes. Hooray!

How can I play my favourite song?
Note: The sequence you generate in part 2 doesn’t have to be a song—there are lots of ways to make interesting patterns in frequency & time

A note has three basic dimensions: the pitch, the loudness and the duration. If you want to play a part of your favourite song, you need to find out the pitch, loudness and duration of each note in the sequence and get your program to generate those notes, one after the other (potentially with gaps in between).

Here are a few tips:

by playing successive notes with slightly different loudness, you can create accents
it’s ok to have periods of silence between notes
the relationship between frequency and the notes on the piano keyboard isn’t linear, although the relationship between the piano keys and MIDI note numbers is linear, and you can use this handy conversion widget (or write an asm function which does the same thing in your program)
Midi note number   = 440.00Hz (2 decimal places)

Can I use the FPU (or some other peripheral on the discoboard we haven’t covered in class)?
Your program can use any part of the discoboard—as long as it still meets the requirements for part 2 and generates the signal you describe in your design document. However, if you decide to use any features we haven’t yet covered (or don’t cover at all) in the course (e.g. the floating-point unit, the timers, the accelerometer, etc.) then you’re on your own to make it work.

If you’re up for a challenge then doing that can be a great learning experience, but you need to know what you’re getting yourself in for—and you need to give yourself plenty of time (in case things don’t work out as planned).

A backing track for In the Hall of the Mountain King
While if you complete this, we encourage you to submit it alongside your part-1 you will not get any extra marks for it. It will also probably may get you a street cred, but that is no guarantee (and I say this again no extra marks).

In the Hall of the Mountain King is not really complete without the dramatic bass line which plods, creeps, and builds throughout the piece. So, we’ve transcribed it for you to optionally put alongside the main theme in part-1.

Here we go:

Note
Frequency
Duration
B2
123.47 Hz
0.44 s
F#3
184.99 Hz
0.44 s
B2
123.47 Hz
0.44 s
F#3
184.99 Hz
0.44 s
B2
123.47 Hz
0.44 s
F#3
184.99 Hz
0.44 s
B2
123.47 Hz
0.44 s
F#3
184.99 Hz
0.44 s
B2
123.47 Hz
0.44 s
F#3
184.99 Hz
0.44 s
B2
123.47 Hz
0.44 s
F#3
184.99 Hz
0.44 s
D3
146.83 Hz
0.44 s
A3
220 Hz
0.44 s
D3
146.83 Hz
0.66 s
silence
0 Hz
0.22 s
and here it is at onlinesequencer.net.

make sure you clone your own fork (i.e. the one with your uni ID in the url) to your local machine, not the template (because obviously you aren’t able to change the template for everyone—GitLab won’t let you) ↩

More products