Package javax.sound.midi

Examples of javax.sound.midi.Sequence


      ByteArrayInputStream bai = new ByteArrayInputStream(bytes);

      try {
        sequencer = MidiSystem.getSequencer();
        Sequence sequence = MidiSystem.getSequence(new DataInputStream(bai));

        sequencer.open();
        sequencer.setSequence(sequence);

        Painter painter = new Painter();
View Full Code Here


        xhtml.startDocument();

        // MidiSystem expects the stream to support the mark feature
        InputStream buffered = new BufferedInputStream(stream);
        try {
            Sequence sequence = MidiSystem.getSequence(buffered);

            Track[] tracks = sequence.getTracks();
            metadata.set("tracks", String.valueOf(tracks.length));
            // TODO: Use XMPDM.TRACKS?

            Patch[] patches = sequence.getPatchList();
            metadata.set("patches", String.valueOf(patches.length));

            float type = sequence.getDivisionType();
            if (type == Sequence.PPQ) {
                metadata.set("divisionType", "PPQ");
            } else if (type == Sequence.SMPTE_24) {
                metadata.set("divisionType", "SMPTE_24");
            } else if (type == Sequence.SMPTE_25) {
View Full Code Here

  protected void playIt() throws Throwable {
    /*
     * We read in the MIDI file to a Sequence object. This object is set at
     * the Sequencer later.
     */
    Sequence sequence = MidiSystem.getSequence(file);

    /*
     * Now, we need a Sequencer to play the sequence. Here, we simply
     * request the default sequencer without an implicitly connected
     * synthesizer
 
View Full Code Here

      return;
    }

    URL url = playList.get(currentSoundIndex);

    Sequence sequence = MidiSystem.getSequence(url);

    sm_sequencer = MidiSystem.getSequencer();

    if (sm_sequencer == null) {
      _logger.info("can't get a Sequencer");
View Full Code Here

     */
    public void test_add() throws Exception {
        /*
         * create an empty Track
         */
        Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
        Track tr = seq.createTrack();
        assertEquals(1, tr.size());
        assertEquals(0, tr.ticks());
       
        byte[] bt = new byte[] {1, 2, 3};
        MidiMessage1 message = new MidiMessage1(bt);
View Full Code Here

    /**
     * test method get(int)
     * @throws Exception
     */
    public void test_get() throws Exception {
        Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
        Track tr = seq.createTrack();
       
        /*
         * numeration of events begin with 0, and so the first
         * event gets with index 0, the second - with index 1
         * and so on
View Full Code Here

     */
    public void test_remove() throws Exception {
        /*
         * create an empty Track
         */
        Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
        Track tr = seq.createTrack();
       
        byte[] bt = new byte[] {1, 2, 3};
        MidiMessage1 message = new MidiMessage1(bt);
        MidiEvent event1 = new MidiEvent(message, 10L);
        MidiEvent event2 = new MidiEvent(new MidiMessage1(new byte[] {23, -16, 4}), 0);
View Full Code Here

     */
    public void test_size() throws Exception {
        /*
         * create an empty Track
         */
        Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
        Track tr = seq.createTrack();
        assertEquals(1, tr.size());
        MidiEvent event1 = new MidiEvent(new MidiMessage1(new byte[] {1, 2, 3}), 10L);
        MidiEvent event2 = new MidiEvent(new MidiMessage1(new byte[] {23, -16, 4}), 0);
        MidiEvent event3 = new MidiEvent(new MidiMessage1(new byte[] {3, -67, -1}), 6L);
        tr.add(event1);
View Full Code Here

     */
    public void test_ticks() throws Exception {
        /*
         * create an empty Track
         */
        Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
        Track tr = seq.createTrack();
        assertEquals(0, tr.ticks());
        MidiEvent event1 = new MidiEvent(new MidiMessage1(new byte[] {1, 2, 3}), -10L);
        MidiEvent event2 = new MidiEvent(new MidiMessage1(new byte[] {23, -16, 4}), 2L);
        MidiEvent event3 = new MidiEvent(new MidiMessage1(new byte[] {3, -67, -1}), 6L);
        /*
 
View Full Code Here

    /**
     * test constructor Sequence(float, int)
     */
    public void test_constructor1() throws Exception {
       
        Sequence seq0 = new Sequence(Sequence.PPQ, 10, 2);
        seq0.getTracks();
       
        new Sequence(Sequence.PPQ, 10);
        Sequence seq2 = new Sequence(Sequence.SMPTE_24, -10);
        new Sequence(Sequence.SMPTE_25, 9854);
        new Sequence(Sequence.SMPTE_30, -82534);
        new Sequence(Sequence.SMPTE_30DROP, 0);
       
        try {
            new Sequence(32.0f, 16);
            fail("InvalidMidiDataException expected");
        } catch (InvalidMidiDataException e) {}
       
        assertEquals(24.0f, seq2.getDivisionType(), 0f);
        assertEquals(0, seq2.getMicrosecondLength());
        assertEquals(-10, seq2.getResolution());
        assertEquals(0, seq2.getTickLength());
        assertEquals(0, seq2.getPatchList().length);
        assertEquals(0, seq2.getTracks().length);
    }
View Full Code Here

TOP

Related Classes of javax.sound.midi.Sequence

Copyright © 2018 www.massapicom. 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.