Package javax.sound.midi

Examples of javax.sound.midi.MidiMessage


            List<MidiEvent> midiEventList = (List<MidiEvent>)timeMap.get(time);
            if (midiEventList != null)
            {
                for (MidiEvent event : midiEventList)
                {
                    MidiMessage message = event.getMessage();
                    if ((message.getMessage().length >= 2) && (message.getMessage()[1] == 0x51) && (message instanceof MetaMessage))
                    {
                        int bpm = parseMicrosecondsPerBeat((MetaMessage)message, time);
                        timeFactor = TimeFactor.getTimeFactor(sequence, bpm);
                        System.out.println("TimeFactor is "+timeFactor);
                    }
View Full Code Here


            }

            for (Track track : tracks) {
                xhtml.startElement("p");
                for (int i = 0; i < track.size(); i++) {
                    MidiMessage message = track.get(i).getMessage();
                    if (message instanceof MetaMessage) {
                        MetaMessage meta = (MetaMessage) message;
                        // Types 1-15 are reserved for text events
                        if (meta.getType() >= 1 && meta.getType() <= 15) {
                            // FIXME: What's the encoding?
View Full Code Here

            }

            for (Track track : tracks) {
                xhtml.startElement("p");
                for (int i = 0; i < track.size(); i++) {
                    MidiMessage message = track.get(i).getMessage();
                    if (message instanceof MetaMessage) {
                        MetaMessage meta = (MetaMessage) message;
                        // Types 1-15 are reserved for text events
                        if (meta.getType() >= 1 && meta.getType() <= 15) {
                            // FIXME: What's the encoding?
View Full Code Here

public class MidiEventTest extends TestCase {
    public void test_getMessage() {
        byte[] bt = new byte[] {1, 2, 3, 4};
        MidiMessage1 message = new MidiMessage1(bt);
        MidiEvent event = new MidiEvent(message, 10L);
        MidiMessage mm = event.getMessage();
        assertEquals(1, mm.getMessage()[0]);
        assertEquals(2, mm.getMessage()[1]);
        assertEquals(3, mm.getMessage()[2]);
        assertEquals(4, mm.getMessage()[3]);
        bt[0] = 10;
        bt[1] = 20;
        bt[2] = 30;
        bt[3] = 40;
        /*
         * values change
         */
        assertEquals(10, mm.getMessage()[0]);
        assertEquals(20, mm.getMessage()[1]);
        assertEquals(30, mm.getMessage()[2]);
        assertEquals(40, mm.getMessage()[3]);
        byte[] nb = mm.getMessage();
        nb[0] = 45;
        nb[1] = -12;
        nb[2] = 90;
        nb[3] = 14;
        /*
         * values don't change
         */
        assertEquals(10, mm.getMessage()[0]);
        assertEquals(20, mm.getMessage()[1]);
        assertEquals(30, mm.getMessage()[2]);
        assertEquals(40, mm.getMessage()[3]);
       
        MidiEvent event1 = new MidiEvent(null, 10L);
        assertNull(event1.getMessage());
    }
View Full Code Here

        assertEquals(1, seq2.getTracks()[0].size());
        assertEquals(0, seq2.getTracks()[0].ticks());
       
        assertEquals(0, seq2.getTracks()[345].get(0).getTick());
       
        MidiMessage mes = seq2.getTracks()[345].get(0).getMessage();
        assertEquals(3, mes.getLength());
        assertEquals(255, mes.getStatus());
        assertEquals(3, mes.getMessage().length);
        assertEquals(-1, mes.getMessage()[0]);
        assertEquals(47, mes.getMessage()[1]);
        assertEquals(0, mes.getMessage()[2]);
    }
View Full Code Here

    public MfiEvent[] getIntervalMfiEvents(int mfiTrackNumber) {

        int interval = 0;
        MidiEvent midiEvent = midiEvents.get(midiEventIndex);

        MidiMessage midiMessage = midiEvent.getMessage();
        if (midiMessage instanceof ShortMessage) {
            // note
            interval = retrieveAdjustedDelta(mfiTrackNumber, midiEvent.getTick());
        } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 81) {
            // tempo
View Full Code Here

    public int getDelta(int mfiTrackNumber) {

        int delta = 0;
        MidiEvent midiEvent = midiEvents.get(midiEventIndex);

        MidiMessage midiMessage = midiEvent.getMessage();
        if (midiMessage instanceof ShortMessage) {
            // note
            delta = retrieveAdjustedDelta(mfiTrackNumber, midiEvent.getTick());
        } else if (midiMessage instanceof MetaMessage && ((MetaMessage) midiMessage).getType() == 81) {
            // tempo
View Full Code Here

                        return c1 - c2;
                    }
                }
                /** */
                int getChannel(MidiEvent e) {
                    MidiMessage m = e.getMessage();
                    if (m instanceof ShortMessage) {
                        return ((ShortMessage) m).getChannel();
                    } else {
                        return -1;
                    }
View Full Code Here

    public MidiEvent getNoteOffMidiEvent() throws NoSuchElementException {

        ShortMessage shortMessage = null;

        MidiEvent midiEvent = midiEvents.get(midiEventIndex);
        MidiMessage midiMessage = midiEvent.getMessage();
        if (midiMessage instanceof ShortMessage) {
            shortMessage = (ShortMessage) midiMessage;
        } else {
            throw new IllegalStateException("current is not ShortMessage");
        }
View Full Code Here

        int interval = 0;
        int track = 0;
        MidiEvent midiEvent = midiTrack.get(midiEventIndex);

        MidiMessage midiMessage = midiEvent.getMessage();
        if (midiMessage instanceof ShortMessage) {
            // note
            ShortMessage shortMessage = (ShortMessage) midiMessage;
            int channel = shortMessage.getChannel();
View Full Code Here

TOP

Related Classes of javax.sound.midi.MidiMessage

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.