PortMidi.OpenOutput
-------------------

Opens an output device.

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

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

**MBS**( **"PortMidi.OpenOutput";** /\* Opens an output device. \*/  
**$DeviceID**; /\* The device ID, a number from 0 to [PortMidi.DeviceCount](PortMidiDeviceCount.md)-1.e.g. 0 \*/   
**$BufferSize**; /\* Optional; Optional, Specifies the number of output events to be buffered waiting for output. Default is 100 if you don't pass this parameter.e.g. 0 \*/   
**$Latency**) /\* Optional; The latency you want.  
Default is zero.  
Latency is the delay in milliseconds applied to timestamps to determine when the output should actually occur. (If latency is &lt; 0, 0 is assumed.)   
If latency is zero, timestamps are ignored and all output is delivered immediately. If latency is greater than zero, output is delayed until the message timestamp plus the latency.   
In some cases, PortMidi can obtain better timing than your application by passing timestamps along to the device driver or hardware. Latency may also help you to synchronize midi data to audio data by matching midi latency to the audio buffer latency.e.g. 10 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| DeviceID | The device ID, a number from 0 to [PortMidi.DeviceCount](PortMidiDeviceCount.md)-1. | 0 |  |
| BufferSize | Optional, Specifies the number of output events to be buffered waiting for output. Default is 100 if you don't pass this parameter. | 0 | Optional |
| Latency | The latency you want.   Default is zero.   Latency is the delay in milliseconds applied to timestamps to determine when the output should actually occur. (If latency is &lt; 0, 0 is assumed.)    If latency is zero, timestamps are ignored and all output is delivered immediately. If latency is greater than zero, output is delayed until the message timestamp plus the latency.    In some cases, PortMidi can obtain better timing than your application by passing timestamps along to the device driver or hardware. Latency may also help you to synchronize midi data to audio data by matching midi latency to the audio buffer latency. | 10 | Optional |

### Result

Returns StreamRef or error.

### Description

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

- [PortMidi.GetDefaultOutputDeviceID](PortMidiGetDefaultOutputDeviceID.md)
- [PortMidi.GetDeviceID](PortMidiGetDeviceID.md)
- [PortMidi.GetFilter](PortMidiGetFilter.md)
- [PortMidi.OpenInput](PortMidiOpenInput.md)
- [PortMidi.Poll](PortMidiPoll.md)
- [PortMidi.ReadMessage](PortMidiReadMessage.md)
- [PortMidi.SendMessage](PortMidiSendMessage.md)
- [PortMidi.SendSysExHex](PortMidiSendSysExHex.md)
- [PortMidi.SetFilter](PortMidiSetFilter.md)
- [Socket.SendMessage](SocketSendMessage.md)

### Example Databases

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

### Blog Entries

- [MBS FileMaker Plugin, version 6.4pr4](https://www.mbsplugins.de/archive/2016-08-20/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 25th January 2017

  
[PortMidi.OpenInput](PortMidiOpenInput.md) - [PortMidi.Poll](PortMidiPoll.md)

[HTML Version](PortMidiOpenOutput.shtml)