class SetHatMidiPatternEvent implements IEventChain {

    @Override
    public QueueState set(QueueState queueState) {

        for(ProgressionUnit pUnit : queueState.getStructure()) {
            String jfugueStr = "T" + queueState.getQueueItem().getBpm() + " ";

            for (ProgressionUnitBar pBar : pUnit.getProgressionUnitBars()) {
                for (Integer k : pBar.getHatPattern().getAsIntegerArray()) {
                    jfugueStr += intToDuration(pUnit.getKey(), k) + " ";
                }

                pBar.setHatMidiPattern(new Pattern(jfugueStr));
            }
        }

        return queueState;
    }

}