PortMidi.Close
--------------

Closes a midi stream, flushing any pending buffers.

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

MBS( "PortMidi.Close"; StreamRef ) 

**MBS**( **"PortMidi.Close";** /\* Closes a midi stream, flushing any pending buffers. \*/  
**$StreamRef**) /\* The reference to the midi stream. You create those with [PortMidi.OpenInput](PortMidiOpenInput.md) or [PortMidi.OpenOutput](PortMidiOpenOutput.md) and finally close them with PortMidi.Close.e.g. $stream \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| StreamRef | The reference to the midi stream. You create those with [PortMidi.OpenInput](PortMidiOpenInput.md) or [PortMidi.OpenOutput](PortMidiOpenOutput.md) and finally close them with PortMidi.Close. | $stream |

### Result

Returns OK or error.

### Description

Closes a midi stream, flushing any pending buffers.  
Don't use the StreamRef after this call as stream is gone.  
### See also

- [PortMidi.GetDeviceID](PortMidiGetDeviceID.md)
- [PortMidi.GetDeviceName](PortMidiGetDeviceName.md)
- [PortMidi.OpenInput](PortMidiOpenInput.md)
- [PortMidi.OpenOutput](PortMidiOpenOutput.md)
- [PortMidi.ReadMessage](PortMidiReadMessage.md)
- [PortMidi.SendMessageRaw](PortMidiSendMessageRaw.md)
- [PortMidi.SendSysExHex](PortMidiSendSysExHex.md)
- [PortMidi.SetChannelMask](PortMidiSetChannelMask.md)
- [PortMidi.SetDataAvailableEvaluate](PortMidiSetDataAvailableEvaluate.md)
- [PortMidi.SetDataAvailableHandler](PortMidiSetDataAvailableHandler.md)

### Example Databases

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

This function checks for a license.

Created 18th August 2014 , last changed 18th August 2014

  
[PortMidi.ClearDataAvailableHandler](PortMidiClearDataAvailableHandler.md) - [PortMidi.CurrentEvent](PortMidiCurrentEvent.md)

[HTML Version](PortMidiClose.shtml)