C++代写:NFE2140 MIDI Scale Player

Introduction

结合MIDI的lib,写一个Player,能让电子琴发出不同的声音。由于我没有电子琴,所以这个代码的调试过程都是写好几个程序,然后拿去lab跑效果。

Requirement

A fully working console application should be written in C++ which presents a main menu to a user asking if they would like to:

  1. Enter new data and play scale
  2. Load data from file and play scale
  3. Quit the application

For options 1 and 2, the scale should be played by outputting a series of appropriate MIDI messages.
Your program should be able to play scales with the following options:

  1. Scale type (chromatic, major or minor).
  2. Starting note of the scale (any valid)
  3. Whether the scale ascends or descends
  4. Length of each note (100 to 2000 milliseconds)
  5. Instrument used to play the scale (either piano, trumpet, guitar or violin)
  6. How many times the scale should be played (1 to 5)

For main menu option 1 – the user should enter the data required above and then the scale should play. After playing the scale, the user should be given the option to save their input choices to a file for later playback. Filename should be input by the user. They will then be returned to the main menu.
For main menu option 2 – the user should type the name of the file they wish to play. After loading and playing, they will be returned to the main menu.
Main menu option 3 should exit the program.
Note: All files can be read from/written to the current working direction. You do not need to handle full file paths.
Higher marks will be awarded for:

  • Efficient code
  • Use of functions
  • Loops
  • Arrays/Vectors
  • Classes
  • Error checking for appropriate values on all user input
  • Adhering to the house style

Summary

虽然代码都是用的都是C++的基本用法,class,loop,function等等,不过做出来的Player跑在电子琴上,还是挺有意思的。