<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVMIDINoteEvent/init(channel:key:velocity:duration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVMIDINoteEvent(im)initWithChannel:key:velocity:duration:"
  },
  "title" : "init(channel:key:velocity:duration:)"
}
-->

# init(channel:key:velocity:duration:)

Creates an event with a MIDI channel, key number, velocity, and duration.

```
init(channel: UInt32, key keyNum: UInt32, velocity: UInt32, duration: AVMusicTimeStamp)
```

## Parameters

`channel`

The MIDI channel, between `0` and `15`.

`keyNum`

The MIDI key number, between `0` and `127`.

`velocity`

The MIDI velocity, between `0` and `127`.

`duration`

The duration for this note, in beats.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)