Examples of Chord


Examples of com.music.model.Chord

            List<ToneType> firstToneTypes = new ArrayList<>();
            boolean interMeasureChord = false;
            double measureChordLength = 0;
            boolean canHaveInterMeasureChords = ctx.getMetre()[0] > 3 && ctx.getMetre()[0] % 4 == 0;

            Chord chord = null;
            for (int i = 0; i < notes.length; i++) {
                // shuffle every time, so that we don't always get the same chord for a given note
                Collections.shuffle(scaleChords, random);
                Collections.shuffle(scaleSeventhChords, random);
                Collections.shuffle(scaleOtherChords, random);

                Note currentNote = notes[i];
                if (currentNote.getRhythmValue() == 0) {
                    continue; // rhythm value is 0 for the first notes of a (main-part) chord. So progress to the next
                }
                // inter-measure chords only for even-numbered, compound metres
                if (canHaveInterMeasureChords && currentMeasureSize == 0) {
                    interMeasureChord = Chance.test(18);
                }
                double chordLength = interMeasureChord ? normalizedMeasureSize / 2 : normalizedMeasureSize;
                boolean isHalfMeasure = currentMeasureSize == normalizedMeasureSize / 2;

                if (currentNote.getPitch() == 0) {
                    logger.warn("Pitch is 0 in main part.");
                    continue;
                }
                if (!currentNote.isRest() && (currentMeasureSize == 0 || (interMeasureChord && isHalfMeasure))) {
                    boolean preferStable = ToneResolver.needsContrastingChord(firstToneTypes, ToneGroups.UNSTABLE);
                    boolean preferUnstable = ToneResolver.needsContrastingChord(firstToneTypes, ToneGroups.STABLE);
                    Chord previous = chord;
                    chord = ChordUtils.getChord(ctx, currentNote.getPitch(), previous, scaleChords, scaleSeventhChords, scaleOtherChords, preferStable, preferUnstable);
                    if (chord != null && Chance.test(90)) {
                        if (Chance.test(20)) { // change the special note type
                            if (Chance.test(60)) { // to a new value
                                specialNoteType = SpecialNoteType.values()[random.nextInt(SpecialNoteType.values().length)];
View Full Code Here

Examples of com.music.model.Chord

    private int[] getRandomChord(ExtendedPhrase phrase, ScoreContext ctx, int pitch) {
        // making a copy, so that the original is not shuffled
        List<Chord> list = new ArrayList<>(ChordUtils.chords.get(phrase.getScale()));
        Collections.shuffle(list, random);
        Chord chord = ChordUtils.getChord(ctx, pitch, null, list, null, null, false, false);
        if (chord != null) {
            return chord.getPitches();
        } else {
            return null;
        }
    }
View Full Code Here

Examples of com.music.model.Chord

            List<ToneType> firstToneTypes = new ArrayList<>();

            int measures = 0;
            Note[] currentNotes = null;
            boolean useTwoNoteChords = Chance.test(14);
            Chord chord = null;
            for (int i = 0; i < notes.length; i++) {
                Note currentNote = notes[i];
                if (currentNote.getRhythmValue() == 0) {
                    continue; // rhythm value is 0 for the first notes of a (main-part) chord. So progress to the next
                }
                boolean lastMeasure = measures == ctx.getMeasures() - 1;
                if (currentMeasureSize == 0 && !currentNote.isRest() && !lastMeasure) {
                    boolean preferStable = ToneResolver.needsContrastingChord(firstToneTypes, ToneGroups.UNSTABLE);
                    boolean preferUnstable = ToneResolver.needsContrastingChord(firstToneTypes, ToneGroups.STABLE);
                    // change the chord only in 1/4 of the cases
                    if (currentNotes == null || Chance.test(25)) {
                        // no alternatives for now - only 3-note chords
                        Chord previous = chord;
                        chord = ChordUtils.getChord(ctx, currentNote.getPitch(), previous, scaleChords, scaleChords, scaleChords, preferStable, preferUnstable);
                        if (chord != null) {
                            int[] pitches = chord.getPitches();
                            //remove the middle note in some cases (but make it possible to have three-note chords in a generally two-note phrase)
                            if (pitches.length == 3 && useTwoNoteChords && Chance.test(90)) {
View Full Code Here

Examples of com.music.model.Chord

                // transpose back to the current key (+ctx.getKeyNote())
                int root = pitch - chordDefPitches[currentNoteIdx] + chordDefPitches[0] + ctx.getKeyNote();
                for (int i = 0; i < chordDefPitches.length; i++) {
                    chord[i] = root + (chordDefPitches[i] - chordDefPitches[0]) + ctx.getKeyNote();
                }
                Chord eligibleChord = new Chord();
                eligibleChord.setPitches(chord);
                eligibleChord.setFirstToneType(chordDef.getFirstToneType());
                eligibleChord.setChordType(chordDef.getChordType());

                if (invert) {
                    // sometimes invert all but the root, other times - only the final note(s)
                    for (int i = (Chance.test(50) ? 1 : 2); i < eligibleChord.getPitches().length; i ++) {
                        eligibleChord.getPitches()[i] = eligibleChord.getPitches()[i] - 12;
                    }
                }

                if (trimMiddleNote) {
                    ArrayUtils.remove(eligibleChord.getPitches(), 1);
                }

                // if the current chord doesn't match the preferences, store it as a temp result and continue
                if (preferStable && !ToneGroups.STABLE.getToneTypes().contains(eligibleChord.getFirstToneType())) {
                    alternativeEligibleChords.add(eligibleChord);
                    continue;
                }

                if (preferUnstable && !ToneGroups.UNSTABLE.getToneTypes().contains(eligibleChord.getFirstToneType())) {
                    alternativeEligibleChords.add(eligibleChord);
                    continue;
                }
                eligibleChords.add(eligibleChord);
            }
        }
        for (Iterator<Chord> it = eligibleChords.iterator(); it.hasNext();) {
            Chord chord = it.next();
            if (isDisallowedInProgression(chord, previousChord) && Chance.test(95)) {
                it.remove();
                if (alternativeEligibleChords.isEmpty()) {
                    alternativeEligibleChords.add(chord);
                }
            }
        }

        Chord result = null;
        if (!eligibleChords.isEmpty()) {
            result = eligibleChords.get(random.nextInt(eligibleChords.size()));
        } else  if (eligibleChords.isEmpty() && !alternativeEligibleChords.isEmpty()) { // if no suitable chord is found that matches the preferences, but there's one that's otherwise suitable, return it
            result = alternativeEligibleChords.get(random.nextInt(alternativeEligibleChords.size()));
        }
View Full Code Here

Examples of com.music.model.Chord

                            otherChordDef = Chords.AUGMENTED; // nothing specific - use default
                        }

                        if (chordDef != null) { // chords in some scales (e.g. Turkish) may not be classified in the above 4 groups. Skip those
                            ToneType firstToneType = ToneType.forDegree(Arrays.binarySearch(scale.getDefinition(), note));
                            Chord chord = getChordDef(note, chordDef);
                            chord.setChordType(ChordType.values()[chordType]);
                            chord.setFirstToneType(firstToneType);
                            scaleChords.add(chord);

                            Chord seventhChord = getChordDef(note, seventhChordDef);
                            seventhChord.setFirstToneType(firstToneType);
                            chord.setChordType(ChordType.values()[chordType]);
                            scaleSeventhChords.add(seventhChord);

                            Chord otherChord = getChordDef(note, otherChordDef);
                            otherChord.setFirstToneType(firstToneType);
                            chord.setChordType(ChordType.values()[chordType]);
                            scaleOtherChords.add(otherChord);
                        }
                    }
                }
View Full Code Here

Examples of com.music.model.Chord

        int[] chordPitches = new int[chordDef.length + 1];
        chordPitches[0] = note;
        for (int k = 0; k < chordDef.length; k++) {
            chordPitches[k + 1] = chordPitches[0] + chordDef[k];
        }
        Chord chord = new Chord();
        chord.setPitches(chordPitches);
        return chord;
    }
View Full Code Here

Examples of datasoul.serviceitems.song.Chord

        LinkedList<Chunk> images = new LinkedList<Chunk>();
        LinkedList<File> filesToDelete = new LinkedList<File>();
        LinkedList<Paragraph> ret = new LinkedList<Paragraph>();

        for(int i=0; i<chordsName.size();i++){
            Chord chord = chordsDB.getChordByName(chordsName.get(i));
            if(chord!=null){
                ChordShapePanel csp = new ChordShapePanel(2, chord.getName(),chord.getShape());
                BufferedImage im = csp.createImage();
                try{
                    File tmp = File.createTempFile("datasoul-img", ".png");
                    tmp.deleteOnExit();
                    filesToDelete.add(tmp);
View Full Code Here

Examples of info.textgrid.lab.noteeditor.mei2013.Chord

    lpd.setDescription(MusicMessages.MEI_documentation_note_artic);
    descriptors.add(lpd);
  }

  private void createDefaultChord() {
    setMeiNode(new Chord());
  }
View Full Code Here

Examples of info.textgrid.lab.noteeditor.mei2013.Chord

            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof ChordGroupForm) {
      ChordGroupForm contentForm = (ChordGroupForm) childForm;
      Chord contentNode = (Chord) contentForm.getMeiNode();
      contentNode.getRestoresAndArticsAndUnclears().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getRestoresAndArticsAndUnclears().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      if(contentNode.getArtics().isEmpty()) {
        contentNode.unsetArtics();
      }
      return contentNode;
    } else if (childForm instanceof BeamGroupForm) {
      BeamGroupForm contentForm = (BeamGroupForm) childForm;
      Beam contentNode = (Beam) contentForm.getMeiNode();
      contentNode.getFTremsAndChordsAndDamages().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getFTremsAndChordsAndDamages().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof NoteForm) {
      NoteForm contentForm = (NoteForm) childForm;
      Note contentNode = (Note) contentForm.getMeiNode();
      if (contentNode.getArtics().isEmpty())
        contentNode.unsetArtics();
      return contentNode;
    } else if (childForm instanceof RestForm) {
      RestForm contentForm = (RestForm) childForm;
      Rest contentNode = (Rest) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof MRestForm) {
      MRestForm contentForm = (MRestForm) childForm;
      MRest contentNode = (MRest) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof SpaceForm) {
      SpaceForm contentForm = (SpaceForm) childForm;
      Space contentNode = (Space) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof DynamForm) {
      DynamForm contentForm = (DynamForm) childForm;
      Dynam contentNode = (Dynam) contentForm.getMeiNode();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getContent().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof TieForm) {
      TieForm contentForm = (TieForm) childForm;
View Full Code Here

Examples of instantbach.data.Chord

        //represents all possible chords
        ChordTemplate fullSpectrum[] = new ChordTemplate[progression.size()];

        //represent the current chords
        Chord chordArray[] = new Chord[progression.size()];

        //allows the program to step back as many times as possible to revoice a progression
        ArrayList<Chord> backupVector[] = new ArrayList[progression.size()];

        //times that a current chord has been checked and has 0 voicings
        int times[] = new int[progression.size()];

        //initialize all times to zero
        for (int i = 0; i < times.length; i++)
            times[i] = 0;

        //For the entire progression....
        for (int i = progression.size() - 1; i > -1; i--) {

            parent.appendInfo("i = " + i + ", ");

            String currentSymbolID = progression.getIdentifier(i);
            String nextSymbolID = progression.getIdentifier(i+1);

            if (i != progression.size() - 1) {
                parent.appendInfo(nextSymbolID + " to " + currentSymbolID + " = ");
            } else {
                parent.appendInfo(currentSymbolID + " = ");
            }

            backupVector[i] = new ArrayList<Chord>();

            //get the starting note
            startingNote = getStartingNote(currentSymbolID);

            //get all the possible notes for that chord
            fullSpectrum[i] = new ChordTemplate();
            fullSpectrum[i] = createChord(currentSymbolID,
                                          startingNote,
                                          fullSpectrum[i]);

            //get all possible combinations of that chord (and doublings)
            Chord allChords[] = createAllChords(fullSpectrum[i],
                                                currentSymbolID);

            parent.appendInfo(allChords.length + " number of doublings, ");

            if (i != progression.size() - 1) {

                allChords = checkMotion(allChords, chordArray[i + 1]);
                parent.appendInfo(allChords.length + " correct motions");
                parent.appendInfo("\r\n");

            }

            if (allChords.length != 0) {

                //if the very last chord...
                if (i != progression.size() - 1) {
                    chordArray[i] = compareChords(allChords, chordArray[i + 1]);
                } else {

                    //create prefered last chord (For cadence)
                    Voice bassVoice = new Voice(NotePosition.ROOT, new Note("C2"));
                    Voice tenorVoice = new Voice(NotePosition.FIFTH, new Note("G2"));
                    Voice altoVoice = new Voice(NotePosition.THIRD, new Note("E3"));
                    Voice sopranoVoice = new Voice(NotePosition.ROOT, new Note("C4"));

                    //if the last chord is I....
                    if (progression.getIdentifier(i).equals("I")) {
                        chordArray[i] = new Chord("I", bassVoice, tenorVoice, altoVoice, sopranoVoice);
                        parent.appendInfo("\r\n");
                    } else {
                        chordArray[i] = compareChords(allChords,new Chord("I", bassVoice, tenorVoice, altoVoice, sopranoVoice));
                        parent.appendInfo("\r\n");
                    }
                }

                for (int j = 0; j < allChords.length; j++)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.