1 / 16

JPIANO

JPIANO. By Adam Harlow. Overview. What is JPiano ? Program design Some basic music concepts The Note model Formulas and algorithms used The JPiano file extension Code examples Limitations and bugs Future work, Conclusion. What is JPiano ?. A virtual keyboard spanning one scale

terena
Download Presentation

JPIANO

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JPIANO By Adam Harlow

  2. Overview • What is JPiano? • Program design • Some basic music concepts • The Note model • Formulas and algorithms used • The JPiano file extension • Code examples • Limitations and bugs • Future work, Conclusion

  3. What is JPiano? • A virtual keyboard spanning one scale • A composing tool • A keyboard learning tool • A toy for tinkering with notes

  4. Program design

  5. Some basic music concepts 4 4 Number of beats Total number of beats per measure Value of beat Duration of a note, usually a multiple of four (4, 8, 16) Sharp Raises note by one semitone Dot Increases duration of a note by half

  6. The Note model • A musical note has two basic properties: • Duration • Tone • The Note class stores these variables, among others, in the model.

  7. The Note model (cont’d) 4 4 B G# A E Vector: (qtr)B (qtr)G# (8th)A (qtr*)E Note: The note vector stores Note objects only. The output you see here is stored in a separate String vector.

  8. Formulas and algorithms used • Length of one whole note • duration = 4*(60/bpm)*1000 • Pitch calculation • pitch = MIN_PITCH+(12*octave) • MIN_PITCH at C0 is 12 • Regular expression pattern for text output • \([(wh)(hf)(qtr)(8th)(16th)]\*?\)(r|[ABCDEFGc]\#?)

  9. The JPiano file extension (.pno) • Output is generated based on each note’s attributes and is stored into a Note vector. • File uses mentioned regex pattern to read and write from a file. • Can be any length. • Can be created by hand in a text file.

  10. Note constructor public Note(intbpm, int value, char noteLetter) { this.setBpm(bpm); try { assignDurations(); } catch (NoteDurationExceptionnde) {} try { this.setValue(value); } catch (UndefinedNoteExceptionune) {} this.setNoteLetter(noteLetter); this.isDotted(); this.isSharp(); }

  11. Assigning durations from bpm public void assignDurations() throws NoteDurationException{ double ibpm = this.getBpm().intValue(); //note duration in milliseconds is 4*(60/bpm)*1000 defaultDuration= 4*(60/ibpm)*1000; if (defaultDuration <= 0) { throw new NoteDurationException(); } for (Values v : Values.values()) { durations[v.ordinal()] = defaultDuration; defaultDuration /= 2; } }

  12. Part of the “insert” Action if (!toggle) { noteString= noteString + "(" + note.getPrefix(); if (note.isDotted()) { noteString= noteString + "*)"; else noteString= noteString + ")"; noteString= noteString + note.getNoteLetter(); if (note.isSharp()) noteString= noteString + "#"; noteString= noteString + " "; noteText.add(noteString); output.append(noteText.lastElement()); note.setNoteOutput(output.getText()); SimpleSynthsynth = new SimpleSynth(); synth= new SimpleSynth((int)note.getDuration(note.getValue()), note.getPitch()); } notes.add(note);

  13. Sound playback public SimpleSynth(int duration, int pitch) { //receives parameters from Note attributes … MidiMessagenoteOn = getNoteOnMessage(pitch); rcvr.send(noteOn, 0); try { Thread.sleep(duration); } catch(InterruptedExceptione) { e.printStackTrace(); } MidiMessagenoteOff= getNoteOffMessage(pitch); rcvr.send(noteOff, 0); }

  14. Limitations and bugs • Currently no sound output for “Free Play” • Cannot play chords or simultaneous key presses • Octave is not represented in text output • Key binding is wonky at best • Sound cuts off/dies easily if keys are pressed too quickly • No time signatures are supported • Cannot do odd note groupings (e.g. triplets)

  15. Future work • Fix the “Free Play” bug • Ensure that notes are properly removed from text area as well as the vectors • Add ability to change instruments • Implement multi-threading in synthesizer • Make a cleaner control layout

  16. Conclusion, final thoughts • Object Oriented Programming is ideal for many music-based programs • Can probably make other types of programs with Note model, such as a chord calculator • JPiano did not satisfy original expectations, but came pretty close

More Related