private int addRhythm(double duration, int pitch, boolean stemup, int currentTick, int row, int newXPos) {
        int tick = currentTick;
        int velocity = 71;
        boolean silence = false;

        final int TEXT = 0x01;
        String text = "off";
        int tmpdiv = 1;
        int tmpnum = 4;
        if (selectedGame == RHYTHMREADING) {
            silence = rhythmLevel.getSilence();
            tmpdiv = rhythmLevel.getTimeDivision();
            tmpnum = rhythmLevel.getTimeSignNumerator();
            rhythmLevel.getTimeSignDenominator();

        } else if (selectedGame == SCOREREADING) {
            silence = scoreLevel.getSilence();
            tmpdiv = scoreLevel.getTimeDivision();
            tmpnum = scoreLevel.getTimeSignNumerator();
            scoreLevel.getTimeSignDenominator();
        }

        if (duration == 0.333) // do not handle pauses into triplets for now
        {
            silence = false;
        }

        System.out.println("[addRhythm] pitch: " + pitch + "duration: " + duration + "stemup " + stemup);

        double tmpsilence = Math.random();
        if (!silence || (silence && tmpsilence < 0.85) || (duration == 3 && tmpnum != 3)) {

            rhythms.add(new Rhythm(duration, newXPos, pitch, row, stemup, false, false, 0));

            track.add(createNoteOnEvent(pitch, velocity, tick));
            mutetrack.add(createNoteOnEvent(pitch, 0, tick));
            tick += (int)((duration * tmpdiv) * ppq);
            addEvent(track, TEXT, text.getBytes(), tick);
            addEvent(mutetrack, TEXT, text.getBytes(), tick);
            track.add(createNoteOffEvent(pitch, tick));
            mutetrack.add(createNoteOffEvent(pitch, tick));

        } else { // silence
            rhythms.add(new Rhythm(duration, newXPos, pitch, row, false, false, true, 0));

            track.add(createNoteOffEvent(pitch, tick));
            mutetrack.add(createNoteOffEvent(pitch, tick));

            tick += (int)((duration * tmpdiv) * ppq);
            addEvent(track, TEXT, text.getBytes(), tick);
            addEvent(mutetrack, TEXT, text.getBytes(), tick);
        }

        return tick;
    }