• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MidiManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.media.midi.MidiManager的典型用法代码示例。如果您正苦于以下问题:Java MidiManager类的具体用法?Java MidiManager怎么用?Java MidiManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MidiManager类属于android.media.midi包,在下文中一共展示了MidiManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onPortSelected

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:MidiInputPortSelector.java


示例2: findDevice

import android.media.midi.MidiManager; //导入依赖的package包/类
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:20,代码来源:MidiTools.java


示例3: findMidiDevice

import android.media.midi.MidiManager; //导入依赖的package包/类
private void findMidiDevice() {
    MidiDeviceInfo[] infos = midiManager.getDevices();
    for(MidiDeviceInfo info : infos) {
        String name = info.getProperties().getString(MidiDeviceInfo.PROPERTY_NAME);
        logger.log("Found MIDI device named " + name);
        if(TEENSY_MIDI_NAME.equals(name)) {
            logger.log("^^^ using this device ^^^");
            isConnecting = true;
            midiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
                public void onDeviceOpened(MidiDevice device) {
                    if (device == null) {
                        logger.log("Error, unable to open MIDI device");
                    } else {
                        logger.log("Opened MIDI device successfully!");
                        midiDevice = device;
                    }
                    isConnecting = false;
                }
            }, null);
            break;
        }
    }
}
 
开发者ID:google,项目名称:walt,代码行数:25,代码来源:MidiTest.java


示例4: onActivityResult

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode,
        Intent data) {
    if (requestCode == REQUEST_BLUETOOTH_SCAN && resultCode == RESULT_OK) {
        final BluetoothDevice fBluetoothDevice = (BluetoothDevice) data
                .getParcelableExtra("device");
        if (fBluetoothDevice != null) {
            Log.i(TAG, "Bluetooth device name = "
                    + fBluetoothDevice.getName()
                    + ", address = "
                    + fBluetoothDevice.getAddress());
            mMidiManager.openBluetoothDevice(fBluetoothDevice,
                    new MidiManager.OnDeviceOpenedListener() {
                        @Override
                        public void onDeviceOpened(MidiDevice device) {
                            onBluetoothDeviceOpen(fBluetoothDevice, device);
                        }
                    }, null);
        }
    }
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:22,代码来源:MainActivity.java


示例5: MidiReceiver

import android.media.midi.MidiManager; //导入依赖的package包/类
public MidiReceiver(Context context, CloseableReceiver listener) {
    this.listener = listener;
    MidiManager midiManager = (MidiManager) context.getSystemService(Context.MIDI_SERVICE);
    stream(midiManager.getDevices())
            .filter(device -> device.getOutputPortCount() > 0).findFirst()
            .ifPresentOrElse(device -> openDevice(midiManager, device),
                             () -> registerDeviceAddedCallback(midiManager));
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:9,代码来源:MidiReceiver.java


示例6: registerDeviceAddedCallback

import android.media.midi.MidiManager; //导入依赖的package包/类
private void registerDeviceAddedCallback(final MidiManager midiManager) {
    midiManager.registerDeviceCallback(new MidiManager.DeviceCallback() {
        @Override
        public void onDeviceAdded(MidiDeviceInfo device) {
            if (device.getOutputPortCount() > 0) {
                midiManager.unregisterDeviceCallback(this);
                openDevice(midiManager, device);
            }
        }
    }, null);
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:12,代码来源:MidiReceiver.java


示例7: onPortSelected

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    Log.i(MidiConstants.TAG, "onPortSelected: " + wrapper);
    close();

    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {

                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mOutputPort = device.openOutputPort(wrapper.getPortIndex());
                    if (mOutputPort == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open output port for " + info);
                        return;
                    }
                    mOutputPort.connect(mDispatcher);
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openOutputPort might take a while.
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:29,代码来源:MidiOutputPortSelector.java


示例8: MidiOutputPortConnectionSelector

import android.media.midi.MidiManager; //导入依赖的package包/类
/**
 * @param midiManager
 * @param activity
 * @param spinnerId
 * @param type
 */
public MidiOutputPortConnectionSelector(MidiManager midiManager,
        Activity activity, int spinnerId,
        MidiDeviceInfo destinationDeviceInfo, int destinationPortIndex) {
    super(midiManager, activity, spinnerId,
            MidiDeviceInfo.PortInfo.TYPE_OUTPUT);
    mDestinationDeviceInfo = destinationDeviceInfo;
    mDestinationPortIndex = destinationPortIndex;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:MidiOutputPortConnectionSelector.java


示例9: connectToDevicePort

import android.media.midi.MidiManager; //导入依赖的package包/类
/**
 * Open a source device and connect its output port to the
 * destinationInputPort.
 *
 * @param sourceDeviceInfo
 * @param sourcePortIndex
 * @param destinationInputPort
 */
private void connectToDevicePort(final MidiDeviceInfo sourceDeviceInfo,
        final int sourcePortIndex,
        final MidiInputPort destinationInputPort,
        final OnPortsConnectedListener listener, final Handler handler) {
    mMidiManager.openDevice(sourceDeviceInfo,
            new MidiManager.OnDeviceOpenedListener() {
                @Override
                public void onDeviceOpened(MidiDevice device) {
                    if (device == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open " + sourceDeviceInfo);
                        safeClose();
                        if (listener != null) {
                            listener.onPortsConnected(null);
                        }
                    } else {
                        Log.i(MidiConstants.TAG,
                                "connectToDevicePort opened "
                                        + sourceDeviceInfo);
                        // Device was opened so connect the ports.
                        mSourceDevice = device;
                        mConnection = device.connectPorts(
                                destinationInputPort, sourcePortIndex);
                        if (mConnection == null) {
                            Log.e(MidiConstants.TAG, "could not connect to "
                                    + sourceDeviceInfo);
                            safeClose();
                        }
                        if (listener != null) {
                            listener.onPortsConnected(mConnection);
                        }
                    }
                }
            }, handler);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:44,代码来源:MidiPortConnector.java


示例10: setupMidi

import android.media.midi.MidiManager; //导入依赖的package包/类
private void setupMidi() {
    // Setup MIDI
    mMidiManager = (MidiManager) getSystemService(MIDI_SERVICE);

    MidiDeviceInfo synthInfo = MidiTools.findDevice(mMidiManager, "AndroidTest",
            "SynthExample");
    int portIndex = 0;
    mPortSelector = new MidiOutputPortConnectionSelector(mMidiManager, this,
            R.id.spinner_synth_sender, synthInfo, portIndex);
    mPortSelector.setConnectedListener(new MyPortsConnectedListener());
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:12,代码来源:MainActivity.java


示例11: checkUsbMidi

import android.media.midi.MidiManager; //导入依赖的package包/类
public static boolean checkUsbMidi(Context context) {
  MidiManager midiManager = (MidiManager) context.getSystemService(Context.MIDI_SERVICE);
  if (midiManager != null) {
    final MidiDeviceInfo[] infos = midiManager.getDevices();
    if (infos.length > 0) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:14,代码来源:MemeMIDI.java


示例12: onItemSelected

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
    System.out.println(i);
    m.openDevice(infos[midiDevice], new MidiManager.OnDeviceOpenedListener() {
        @Override
        public void onDeviceOpened(MidiDevice device) {
            if (device == null) {
                Toast.makeText(getApplicationContext(), "Could not open device!",
                        Toast.LENGTH_LONG).show();
            } else {
                inputPort = device.openInputPort(0);
            }
        }
    }, new Handler(Looper.getMainLooper()));
}
 
开发者ID:MartiniMoe,项目名称:MIDICtrl,代码行数:16,代码来源:ControlActivity.java


示例13: MidiTest

import android.media.midi.MidiManager; //导入依赖的package包/类
MidiTest(Context context) {
    super(context);
    inputRepetitions = getIntPreference(context, R.string.preference_midi_in_reps, 100);
    outputRepetitions = getIntPreference(context, R.string.preference_midi_out_reps, 10);
    midiManager = (MidiManager) context.getSystemService(Context.MIDI_SERVICE);
    findMidiDevice();
}
 
开发者ID:google,项目名称:walt,代码行数:8,代码来源:MidiTest.java


示例14: openDevice

import android.media.midi.MidiManager; //导入依赖的package包/类
private void openDevice(final MidiDeviceInfo info) {
    mManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
        @Override
        public void onDeviceOpened(MidiDevice device) {
            MidiManagerAndroid.this.onDeviceOpened(device, info);
        }
    }, mHandler);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:9,代码来源:MidiManagerAndroid.java


示例15: onCreate

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

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

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

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

    // Receivers that parses raw data into complete messages.
    mConnectFramer = new MidiFramer(mLoggingReceiver);

    // Setup a menu to select an input source.
    mLogSenderSelector = new MidiOutputPortSelector(mMidiManager, this,
            R.id.spinner_senders) {

        @Override
        public void onPortSelected(final MidiPortWrapper wrapper) {
            super.onPortSelected(wrapper);
            if (wrapper != null) {
                log(MidiPrinter.formatDeviceInfo(wrapper.getDeviceInfo()));
            }
        }
    };

    mDirectReceiver = new MyDirectReceiver();
    mLogSenderSelector.getSender().connect(mDirectReceiver);

    // Tell the virtual device to log its messages here..
    MidiScope.setScopeLogger(this);
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:37,代码来源:MainActivity.java


示例16: setupMidi

import android.media.midi.MidiManager; //导入依赖的package包/类
private void setupMidi() {
    // Setup MIDI
    mMidiManager = (MidiManager) getSystemService(MIDI_SERVICE);

    MidiDeviceInfo synthInfo =  MidiTools.findDevice(mMidiManager, "Mobileer",
            "SynthExample");
    int portIndex = 0;
    mPortSelector = new MidiOutputPortConnectionSelector(mMidiManager, this,
            R.id.spinner_synth_sender, synthInfo, portIndex);
    mPortSelector.setConnectedListener(new MyPortsConnectedListener());
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:12,代码来源:MainActivity.java


示例17: onPortSelected

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();

    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {

                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mOutputPort = device.openOutputPort(wrapper.getPortIndex());
                    if (mOutputPort == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open output port for " + info);
                        return;
                    }
                    mOutputPort.connect(mDispatcher);
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openOutputPort might take a while.
    }
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:28,代码来源:MidiOutputPortSelector.java


示例18: MidiDeviceMonitor

import android.media.midi.MidiManager; //导入依赖的package包/类
private MidiDeviceMonitor(MidiManager midiManager) {
    mMidiManager = midiManager;
    if (mUseProxy) {
        Log.i(TAG,"Running on M so we need to use the workaround.");
        mMyDeviceCallback = new MyDeviceCallback();
        mMidiManager.registerDeviceCallback(mMyDeviceCallback,
                new Handler(Looper.getMainLooper()));
    }
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:10,代码来源:MidiDeviceMonitor.java


示例19: openDevice

import android.media.midi.MidiManager; //导入依赖的package包/类
private void openDevice(final MidiManager midiManager, MidiDeviceInfo device) {
    midiManager.openDevice(device, this, null);
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:4,代码来源:MidiReceiver.java


示例20: onCreate

import android.media.midi.MidiManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    setActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar = getActionBar();
    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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:45,代码来源:MainActivity.java



注:本文中的android.media.midi.MidiManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RunAsWork类代码示例发布时间:2022-05-22
下一篇:
Java NullProviderFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap