PortMidi.OpenInput
------------------

Opens an input device.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [PortMidi](component_PortMidi.md) | [4.2](newinversion42.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "PortMidi.OpenInput"; DeviceID { ; BufferSize; Latency } ) 

**MBS**( **"PortMidi.OpenInput";** /\* Opens an input device. \*/  
**$DeviceID**; /\* The device ID, a number from 0 to [PortMidi.DeviceCount](PortMidiDeviceCount.md)-1.e.g. 0 \*/   
**$BufferSize**; /\* Optional; Optional, number of events to buffer. Default is 100 if you don't pass this parameter.e.g. 0 \*/   
**$Latency**) /\* Optional; The desired latency. By default 0 is used which means no latency.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| DeviceID | The device ID, a number from 0 to [PortMidi.DeviceCount](PortMidiDeviceCount.md)-1. | 0 |  |
| BufferSize | Optional, number of events to buffer. Default is 100 if you don't pass this parameter. | 0 | Optional |
| Latency | The desired latency. By default 0 is used which means no latency. | 0 | Optional |

### Result

Returns StreamRef or error.

### Description

Opens an input device.  
Midi reference numbers are starting at 17000 and counting up for each new midi stream.  
### See also

- [PortMidi.GetChannelMask](PortMidiGetChannelMask.md)
- [PortMidi.GetFilter](PortMidiGetFilter.md)
- [PortMidi.OpenOutput](PortMidiOpenOutput.md)
- [PortMidi.Poll](PortMidiPoll.md)
- [PortMidi.ReadMessage](PortMidiReadMessage.md)
- [PortMidi.SendMessageRaw](PortMidiSendMessageRaw.md)
- [PortMidi.SendSysExHex](PortMidiSendSysExHex.md)
- [PortMidi.SetDataAvailableEvaluate](PortMidiSetDataAvailableEvaluate.md)
- [PortMidi.SetDataAvailableHandler](PortMidiSetDataAvailableHandler.md)
- [PortMidi.SetFilter](PortMidiSetFilter.md)

### Example Databases

- [Midi/Midi Receive](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Midi/Midi%20Receive.shtml#1ScriptAnchor_)

This function checks for a license.

Created 18th August 2014 , last changed 9th January 2015

  
[PortMidi.List](PortMidiList.md) - [PortMidi.OpenOutput](PortMidiOpenOutput.md)

[HTML Version](PortMidiOpenInput.shtml)