---
title: "MIDIDeviceNewEntity(_:_:_:_:_:_:_:)"
framework: coremidi
role: symbol
role_heading: Function
path: "coremidi/mididevicenewentity(_:_:_:_:_:_:_:)"
---

# MIDIDeviceNewEntity(_:_:_:_:_:_:_:)

Adds a new entity to a device.

## Declaration

```swift
func MIDIDeviceNewEntity(_ device: MIDIDeviceRef, _ name: CFString, _ protocol: MIDIProtocolID, _ embedded: Bool, _ numSourceEndpoints: Int, _ numDestinationEndpoints: Int, _ newEntity: UnsafeMutablePointer<MIDIEntityRef>) -> OSStatus
```

## Parameters

- `device`: The device that owns the new entity.
- `name`: The name of the new entity.
- `protocol`: The MIDI protocol variant used by the sources and destinations that make up this entity.
- `embedded`: A Boolean value that indicates whether this entity is inside the device. If you specify doc://com.apple.documentation/documentation/Swift/false, the entity consists only of external connectors to which you can attach other devices.
- `numSourceEndpoints`: The entity’s number of source endpoints.
- `numDestinationEndpoints`: The entity’s number of destination endpoints.
- `newEntity`: On successful return, points to the newly created entity.

## Return Value

Return Value An OSStatus result code.

## Discussion

Discussion Beginning with macOS 11 and iOS 14, non-drivers may call this function to add entities to external devices.

## See Also

### Managing Entities

- [MIDIDeviceRemoveEntity(_:_:)](coremidi/midideviceremoveentity(_:_:).md)
- [MIDIEntityAddOrRemoveEndpoints(_:_:_:)](coremidi/midientityaddorremoveendpoints(_:_:_:).md)
