android.media.midi.MidiReceiver Java Examples

The following examples show how to use android.media.midi.MidiReceiver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MidiInputPortAndroid.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Registers this object to the underlying port so as to the C++ function will be called with
 * the given C++ object when data arrives.
 * @param nativeReceiverPointer a pointer to a midi::MidiInputPortAndroid object.
 * @return true if this operation succeeds or the port is already open.
 */
@CalledByNative
boolean open(long nativeReceiverPointer) {
    if (mPort != null) {
        return true;
    }
    mPort = mDevice.openOutputPort(mIndex);
    if (mPort == null) {
        return false;
    }
    mNativeReceiverPointer = nativeReceiverPointer;
    mPort.connect(new MidiReceiver() {
        @Override
        public void onSend(byte[] bs, int offset, int count, long timestamp) {
            nativeOnData(mNativeReceiverPointer, bs, offset, count, timestamp);
        }
    });
    return true;
}
 
Example #2
Source File: MidiDispatcher.java    From android-MidiSynth with Apache License 2.0 5 votes vote down vote up
@Override
public void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        try {
            receiver.send(msg, offset, count, timestamp);
        } catch (IOException e) {
            // if the receiver fails we remove the receiver but do not propagate the exception
            mReceivers.remove(receiver);
        }
    }
}
 
Example #3
Source File: MidiDispatcher.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
@Override
public void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        try {
            receiver.send(msg, offset, count, timestamp);
        } catch (IOException e) {
            // if the receiver fails we remove the receiver but do not propagate the exception
            mReceivers.remove(receiver);
        }
    }
}
 
Example #4
Source File: MidiDispatcher.java    From media-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        try {
            receiver.send(msg, offset, count, timestamp);
        } catch (IOException e) {
            // if the receiver fails we remove the receiver but do not propagate the exception
            mReceivers.remove(receiver);
        }
    }
}
 
Example #5
Source File: MainActivity.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
private void midiSend(byte[] buffer, int count, long timestamp) {
    if (mKeyboardReceiverSelector != null) {
        try {
            // send event immediately
            MidiReceiver receiver = mKeyboardReceiverSelector.getReceiver();
            if (receiver != null) {
                receiver.send(buffer, 0, count, timestamp);
            }
        } catch (IOException e) {
            Log.e(TAG, "mKeyboardReceiverSelector.send() failed " + e);
        }
    }
}
 
Example #6
Source File: MidiDispatcher.java    From media-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        try {
            receiver.send(msg, offset, count, timestamp);
        } catch (IOException e) {
            // if the receiver fails we remove the receiver but do not propagate the exception
            mReceivers.remove(receiver);
        }
    }
}
 
Example #7
Source File: MidiDispatcher.java    From android-MidiScope with Apache License 2.0 5 votes vote down vote up
@Override
public void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        try {
            receiver.send(msg, offset, count, timestamp);
        } catch (IOException e) {
            // if the receiver fails we remove the receiver but do not propagate the exception
            mReceivers.remove(receiver);
        }
    }
}
 
Example #8
Source File: MidiDispatcher.java    From android-MidiScope with Apache License 2.0 4 votes vote down vote up
@Override
public void flush() throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        receiver.flush();
   }
}
 
Example #9
Source File: MidiDispatcher.java    From android-MidiSynth with Apache License 2.0 4 votes vote down vote up
@Override
public void flush() throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        receiver.flush();
   }
}
 
Example #10
Source File: MidiFramer.java    From android-MidiSynth with Apache License 2.0 4 votes vote down vote up
public MidiFramer(MidiReceiver receiver) {
    mReceiver = receiver;
}
 
Example #11
Source File: MidiScope.java    From android-MidiScope with Apache License 2.0 4 votes vote down vote up
@Override
public MidiReceiver[] onGetInputPortReceivers() {
    return new MidiReceiver[] { mInputReceiver };
}
 
Example #12
Source File: MainActivity.java    From android-MidiScope with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }

    mLog = (TextView) findViewById(R.id.log);
    mScroller = (ScrollView) findViewById(R.id.scroll);

    // Setup MIDI
    MidiManager midiManager = (MidiManager) getSystemService(MIDI_SERVICE);

    // Receiver that prints the messages.
    MidiReceiver loggingReceiver = new LoggingReceiver(this);

    // Receiver that parses raw data into complete messages.
    MidiFramer connectFramer = new MidiFramer(loggingReceiver);

    // Setup a menu to select an input source.
    mLogSenderSelector = new MidiOutputPortSelector(midiManager, this, R.id.spinner_senders) {
        @Override
        public void onPortSelected(final MidiPortWrapper wrapper) {
            super.onPortSelected(wrapper);
            if (wrapper != null) {
                mLogLines.clear();
                MidiDeviceInfo deviceInfo = wrapper.getDeviceInfo();
                if (deviceInfo == null) {
                    log(getString(R.string.header_text));
                } else {
                    log(MidiPrinter.formatDeviceInfo(deviceInfo));
                }
            }
        }
    };
    mLogSenderSelector.getSender().connect(connectFramer);

    // Tell the virtual device to log its messages here..
    MidiScope.setScopeLogger(this);
}
 
Example #13
Source File: MidiInputPortSelector.java    From android-MidiScope with Apache License 2.0 4 votes vote down vote up
public MidiReceiver getReceiver() {
    return mInputPort;
}
 
Example #14
Source File: MainActivity.java    From media-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }

    mLog = (TextView) findViewById(R.id.log);
    mScroller = (ScrollView) findViewById(R.id.scroll);

    // Setup MIDI
    MidiManager midiManager = (MidiManager) getSystemService(MIDI_SERVICE);

    // Receiver that prints the messages.
    MidiReceiver loggingReceiver = new LoggingReceiver(this);

    // Receiver that parses raw data into complete messages.
    MidiFramer connectFramer = new MidiFramer(loggingReceiver);

    // Setup a menu to select an input source.
    mLogSenderSelector = new MidiOutputPortSelector(midiManager, this, R.id.spinner_senders) {
        @Override
        public void onPortSelected(final MidiPortWrapper wrapper) {
            super.onPortSelected(wrapper);
            if (wrapper != null) {
                mLogLines.clear();
                MidiDeviceInfo deviceInfo = wrapper.getDeviceInfo();
                if (deviceInfo == null) {
                    log(getString(R.string.header_text));
                } else {
                    log(MidiPrinter.formatDeviceInfo(deviceInfo));
                }
            }
        }
    };
    mLogSenderSelector.getSender().connect(connectFramer);

    // Tell the virtual device to log its messages here..
    MidiScope.setScopeLogger(this);
}
 
Example #15
Source File: MidiFramer.java    From android-MidiScope with Apache License 2.0 4 votes vote down vote up
public MidiFramer(MidiReceiver receiver) {
    mReceiver = receiver;
}
 
Example #16
Source File: MidiScope.java    From android-midisuite with Apache License 2.0 4 votes vote down vote up
@Override
public MidiReceiver[] onGetInputPortReceivers() {
    return new MidiReceiver[] { mInputReceiver };
}
 
Example #17
Source File: MidiSynthDeviceService.java    From android-midisuite with Apache License 2.0 4 votes vote down vote up
@Override
public MidiReceiver[] onGetInputPortReceivers() {
    return new MidiReceiver[] { mSynthEngine };
}
 
Example #18
Source File: MidiInputPortSelector.java    From android-midisuite with Apache License 2.0 4 votes vote down vote up
public MidiReceiver getReceiver() {
    return mInputPort;
}
 
Example #19
Source File: MidiDispatcher.java    From android-midisuite with Apache License 2.0 4 votes vote down vote up
@Override
public void flush() throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        receiver.flush();
   }
}
 
Example #20
Source File: MidiFramer.java    From android-midisuite with Apache License 2.0 4 votes vote down vote up
public MidiFramer(MidiReceiver receiver) {
    mReceiver = receiver;
}
 
Example #21
Source File: MidiInputPortSelector.java    From android-MidiSynth with Apache License 2.0 4 votes vote down vote up
public MidiReceiver getReceiver() {
    return mInputPort;
}
 
Example #22
Source File: MidiSynthDeviceService.java    From android-MidiSynth with Apache License 2.0 4 votes vote down vote up
@Override
public MidiReceiver[] onGetInputPortReceivers() {
    return new MidiReceiver[]{mSynthEngine};
}
 
Example #23
Source File: MidiScope.java    From media-samples with Apache License 2.0 4 votes vote down vote up
@Override
public MidiReceiver[] onGetInputPortReceivers() {
    return new MidiReceiver[] { mInputReceiver };
}
 
Example #24
Source File: MidiInputPortSelector.java    From media-samples with Apache License 2.0 4 votes vote down vote up
public MidiReceiver getReceiver() {
    return mInputPort;
}
 
Example #25
Source File: MidiFramer.java    From media-samples with Apache License 2.0 4 votes vote down vote up
public MidiFramer(MidiReceiver receiver) {
    mReceiver = receiver;
}
 
Example #26
Source File: MidiDispatcher.java    From media-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void flush() throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        receiver.flush();
   }
}
 
Example #27
Source File: MidiInputPortSelector.java    From media-samples with Apache License 2.0 4 votes vote down vote up
public MidiReceiver getReceiver() {
    return mInputPort;
}
 
Example #28
Source File: MidiSynthDeviceService.java    From media-samples with Apache License 2.0 4 votes vote down vote up
@Override
public MidiReceiver[] onGetInputPortReceivers() {
    return new MidiReceiver[]{mSynthEngine};
}
 
Example #29
Source File: MidiDispatcher.java    From media-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void flush() throws IOException {
   for (MidiReceiver receiver : mReceivers) {
        receiver.flush();
   }
}
 
Example #30
Source File: MidiFramer.java    From media-samples with Apache License 2.0 4 votes vote down vote up
public MidiFramer(MidiReceiver receiver) {
    mReceiver = receiver;
}