public static int[] getSecondPassChords(final Phrase phrase,
                                            final double beatLength,
                                            final int tonic,
                                            final int[] scale) {
        Possible[] chords = getChords(phrase, beatLength, tonic, scale);
        int[] returnChords = new int[chords.length];
        int index = chords.length - 1;
        if (index < 0) {
            return new int[0];
        }
        while (chords[index] == null) {
            returnChords[index] = 7;
            index--;
            if (index < 0) {
                return returnChords;
            }
        }
        returnChords[index] = chords[index].getBestChord();
        int previousChord = returnChords[index];
        index--;
        outerLoop:
        while (index > 0) {
            while (chords[index] == null) {
                returnChords[index] = 7;
                index--;
                if (index < 1) {
                    break outerLoop;
                }
            }
            int dominantIndex = (previousChord + 4) % scale.length;
            if (acceptableChange(chords[index].chords, dominantIndex,
                    chords[index].getBestChord())) {
                returnChords[index] = dominantIndex;
            } else {
                returnChords[index] = chords[index].getBestChord();
            }
            previousChord = returnChords[index];
            index--;
        }
        if (chords[0] == null) {
            returnChords[0] = 7;
        } else {
            returnChords[0] = chords[0].getBestChord();
        }
        return returnChords;
    }