Java 8 Sequence - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Sequence class.

This code example shows how to use the following methods:getDivisionType
 
    static boolean test(float divisionType) {
        boolean result = false;
        try { 
            log("Testing divisionType == " + divisionType);
            Sequence sequence = new Sequence(divisionType, 16, 1);
            float div1 = sequence.getDivisionType();
 
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            MidiSystem.write(sequence, 1, outStream);
 
            InputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
 
            sequence = MidiSystem.getSequence(inStream);
            float div2 = sequence.getDivisionType();
 
            log("After write/read got divisionType == " + div2);
            if (Math.abs(div2 - div1) < 0.001f) {
                result = true;
            } 
5
CodeRank
This code example shows how to use the following methods:getDivisionType, getResolution
    public static double DEFAULT_BPM = 120.0d;
    public static int QUARTER_DURATIONS_IN_WHOLE = 4;
     
    public static final double getTimeFactor(Sequence sequence, double bpm)
    { 
        double divisionType = sequence.getDivisionType();
        double resolution = sequence.getResolution();
 
        // If division type is PPQ, resolution is ticks per beat. 
        // Since a beat is the length of time given to a one quarter note, this essentially 
        // means that ticks per beat == pulses per quarter note (PPQ or PPQN) 
        if (divisionType == Sequence.PPQ)
        { 
//            System.out.println("DivisionType is PPQ"); 
//            System.out.println("Resolution is "+resolution); 
        } else { 
//            System.out.println("DivisionType is SMPTE"); 
        } 
        // Useful resources: http://www.borg.com/~jglatt/tech/midifile/tempo.htm and http://www.borg.com/~jglatt/tech/midifile/ppqn.htm 
         
5
CodeRank
This code example shows how to use the following methods:getMicrosecondLength
        getSequencer().setMicrosecondPosition(microseconds);
    } 
 
    public long getSequenceLength(Sequence sequence)
    { 
        return sequence.getMicrosecondLength();
    } 
 
    public long getSequencePosition() 
    { 
        return getSequencer().getMicrosecondPosition();
    } 
 
    /** 
     * Saves the MIDI data from a pattern into a file. 
     * @param pattern the pattern to save 
     * @param file the File to save the pattern to.  Should include file extension, such as .mid 
     */ 
    public void saveMidi(Pattern pattern, File file) throws IOException
3
CodeRank
See Code Examples for Java 8 Sequence Methods: