Giter Site home page Giter Site logo

musiceditor's Introduction

Project: Music Editor

Stack: Java

Team: Muigai Unaka and Will Kent

Summary: This project was my first dive into Software development using the Model-View-Controller Design Pattern. I worked on this project for 6 weeks with my partner Will Kent.

SETUP

Running this program requires Java to be installed on your device. Download the MusicEditor.jar file in the root directory. Open up the Command prompt or terminal and change into the directory that holds the jar file. Run this command:

java -MusicEditorCollab.jar "mystery-2.txt" "audiovisual"

Options for the first argument: "mystery-1.txt", "mystery-2.txt", "mystery-3.txt",

Options for the second argument: "audiovisual", "midi"

More documentation to follow shortly

Javadocs below

###MusicEditorModel interface

METHODS:

void addNote(K note); Adds a note to the music editor’s tree map

void removeNote(K note); Removes a note from the music editor’s tree map

void editNote(K note); Edits the given note

int getHighestBeat(); Finds the last beat that a note is played at

String showMusic(); Renders a music composition to the console as a string of the note range, from the note with the lowest pitch and octave to the note with the highest pitch and octave

void playSimultaneously(MusicEditorModel model); Plays music notes from other compositions at the same time as these notes

void playConsecutively(MusicEditorModel model); Plays music notes from other compositions after this music model's notes

List getNotesStartingAt(int time); Gets all the notes that start at the given beat

List getAllNotes(); Gets all the notes in the music piece

List getNotesAtTime(int time); Gets the list of notes that are played at the given beat

K getLowestNote(); Gets the lowest note in the piece of music

K getHighestNote(); gets the highest note in the piece of music

List getBeatsFor(K note); gets all of the beats that a given note is played during

int getLength(); gets the length of the piece in beats

int getTempo(); gets the tempo of the piece

List<?> getPitches(); gets the range of pitches in the piece

###MusicEditorModelImpl: MusicEditorModel is implemented by MusicEditorModelImpl.

FIELDS: int length: the number of beats in the music piece

pitch lowest: the pitch of the lowest note in the piece

pitch highest: the pitch of the highest note in the piece

list<Pitch> pitches: a list of pitches from lowest to highest

TreeMap<Integer, List<Note>> song: a map of all of the notes in the piece by beat
int tempo: the speed of the piece

METHODS: All methods from the interface plus: private void setLength(int newLength); Makes the piece of music longer if notes are added that go beyond the current length private void setLowest(Note note); Extends the range of the piece downward if a note is added below the current lowest note. private void setHighest(Note note); Extends the range of the piece upward if a note is added above the current highest note.

public boolean containsNote(Note note); Determines if this music piece contains the given note

###Private Class Builder This class also contains a private static Builder class that sets the tempo and can add notes and then constructs new MusicEditorModelImpls from that information. The other fields in the model are set based on the notes in the model (highest and lowest are the highest and lowest notes in the list, length is the latest beat at which a note is being played and pitches is a list of pitches from the pitch of the lowest note to the pitch of the highest note).

###Note: Note implements comparable We decided not to include an end time for notes because it can be easily calculated from the start time and the duration. Having and end time as well as those two made keeping track of the fields complicated because if one changed the others may also have to change to keep the note consistent. FIELDS: Pitch pitch: a pitch for the note

int startTime: the beat the note starts on

int duration: the number of beats the note plays for

int instrument: the instrument the note is played with

int volume: the volume of the note

METHODS: CompareTo() the interface plus:

void higher(); increases the pitch of this note by one

void lower(); decreases the pitch of this note by one

int getDuration(); getter method of the duration of this note

int getInstrument(); getter method for the instrument of this method

Pitch getPitch(); getter method for the pitch of this note

int getStartTime(); getter method for the start beat of this note

void setDuration(int duration); setter method for the duration of a note

void setInstrument(int instrument); setter method for the instrument of a note

void setPitch(Pitch pitch); Setter method for the Pitch of a note

void setStartTime(int startTime); Setter method for the start time of a note

int getVolume(); gets the volume of this note

###Pitch: Pitch implements comparable Pitch is a combination of an enum Tone which is C through GSHARP and an octave. There are two constructors for a pitch. One takes a Tone and an int octave and constructs the note from that. The other takes an int and then calculates the tone and octave values from it using math.

FIELDS: Tone t; the tone of the pitch int octave; the octave of the pitch

METHODS: Overridden toString(), equals(), hashCode() and compareTo()

public void higher();increases the pitch by one letter, when going from B to C it also increase the octave

public void lower(); decreases the pitch by one letter, when going from C to B it also decreases the octave

public int getInt(); get an integer value of the pitch

public Tone getTone(); get the tone of the pitch

###Tone: Tone is an enumeration for each of the letters that represent pitches without octaves.

METHODS: Overridden toString

int getToneValue(); get the ordinal value of the tone

String getToneLetter(int pitch); get the letter value of the tone from the given pitch

Tone getNext(); returns the next letter in the enum and wraps if at the end

Tone getPrev();returns the previous letter in the enum and wraps if at the beginning

###View interface: Most of the methods in the view interface are there to show the user where they are in the edit process. The graphical views don’t do anything with these methods since they show all of the notes at once but the Midi view tracks through the beats and can play them individually or pause at a certain beat. METHODS:

void initialize(); Sets up the view with any default parameters and displays any relevant
information

void play(); Plays the song

void pause(); Pauses the song at the current beat

void rewind(); Moves backwards through the song

void skip(); Skips to the end of the song

void next(); Moves to the next beat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.