/** * Returns the Note at the specified index across all parts * * @param index the index of the Note to get * @return the Note at the specified index */ public Note getNote(int index) { int sizeOfPart = chordProg.size(); int partNum = index / sizeOfPart; int indexWithinPart = index % sizeOfPart; MelodyPart part = partList.get(partNum); return part.getNote(indexWithinPart); }
/** * Adds the specified Part to the Score. * * @param part Part to add */ public void addPart(MelodyPart part) { Trace.log(2, "adding existing melody part to score"); if (length < part.size()) { setLength(part.size()); } partList.add(part); }
@Override public String toString() { StringBuilder buffer = new StringBuilder(); for (MelodyPart part : parts) { buffer.append(part.toString()); } return buffer.toString(); }
/** * Creates a new Command that can bar line shift a melody part. * * @param source the Part to paste * @param startSlot the slot to start pasting over in the dest * @param stopSlot the slot to end pasting over in the dest * @param direction the direction ("up" or "down") to transpose the second half * @param distance the number of half steps to transpose the melody * @param keySig the key signature that the solo is being played in * @param cm the command manager used */ public SideSlipCommand( MelodyPart source, String direction, int distance, int keySig, CommandManager cm) { this.source = source; this.dest = source.copy(); this.original = source.copy(); this.direction = direction; this.distance = distance; this.keySig = keySig; this.cm = cm; }
/** * Adds the specified number of empty Parts to the Score. * * @param parts the number of Parts to add */ public void addParts(int parts) { // Trace.log(0, "adding " + parts + " new parts to score"); for (int i = 0; i < parts; i++) { MelodyPart mp = new MelodyPart(length); if (partList.size() > 0) { mp.setInstrument(partList.get(0).getInstrument()); } partList.add(mp); } }
/** Calls makeSwing on each individual Part. */ public void makeSwing() { ListIterator<MelodyPart> i = partList.listIterator(); while (i.hasNext()) { MelodyPart m = i.next(); Style style = chordProg.getStyle(); if (style != null) { m.setSwing(style.getSwing()); } m.makeSwing(chordProg.getSectionInfo()); } }
public void checkLength() { int maxLength = length; if (chordProg.size() > maxLength) maxLength = chordProg.size(); ListIterator<MelodyPart> i = partList.listIterator(); while (i.hasNext()) { MelodyPart part = i.next(); if (part.size() > maxLength) maxLength = part.size(); } setLength(maxLength); }
/** applies the transformation to the source MelodyPart */ public void execute() { Trace.log(2, "executing SideSlipCommand"); int start = original.getSize(); if (direction.equals("up")) { // slide up cm.execute(new ShiftPitchesCommand(distance, dest, 0, start, 0, 128, keySig)); } else if (direction.equals("down")) { // slide down cm.execute(new ShiftPitchesCommand(-1 * distance, dest, 0, start, 0, 128, keySig)); } // add two of the same melodies with one transposed source.setSize(dest.getSize() * 2); source.pasteOver(dest, start); }
/** Redoes the side slip. */ public void redo() { if (source != null && dest != null) { dest.pasteOver(source, source.getSize()); } }