---
title: "init(channel:key:velocity:duration:)"
framework: avfaudio
role: symbol
role_heading: Initializer
path: "avfaudio/avmidinoteevent/init(channel:key:velocity:duration:)"
---

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

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

## Declaration

```swift
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.
