Overview
TheMidiClip class extends the base Clip class to provide MIDI-specific functionality. MIDI clips contain MIDI note data, have an associated piano roll editor, and can be created from MIDI files or programmatically.
Constructors
MidiClip(MidiTrack, string, long)
Creates a new MIDI clip from a MIDI file.The parent MIDI track that will contain this clip.
Path to the MIDI file (.mid) to load.
Starting time in ticks for the clip in the arrangement.
MidiClip(MidiTrack, MidiClipData, long)
Creates a new MIDI clip from existing MIDI clip data.The parent MIDI track that will contain this clip.
The MIDI data for the clip.
Starting time in ticks for the clip in the arrangement.
MidiClip(MidiTrack, long)
Creates a new empty MIDI clip with default length.The parent MIDI track that will contain this clip.
Starting time in ticks for the clip in the arrangement.
MidiClip(MidiTrack, TimeSelection)
Creates a new MIDI clip with duration and position defined by a time selection.The parent MIDI track that will contain this clip.
Time selection defining the clip’s start time and duration.
Properties
MidiClipData
The MIDI data container with notes, tempo map, and MIDI file information.
PianoRollEditor
The piano roll editor instance associated with this clip.
Inherited Properties
MidiClip inherits the following properties from theClip base class:
Unique identifier for the clip (auto-generated GUID).
Display name of the clip.
Whether the clip is enabled (not muted).
The parent track containing this clip.
Width of the clip in pixels.
RGBA color of the clip.
Starting time in ticks in the arrangement.
Ending time in ticks in the arrangement.
Duration of the clip in ticks.
Starting time in musical notation (Bars.Beats.Ticks).
Ending time in musical notation (Bars.Beats.Ticks).
Duration in musical notation (Bars.Beats.Ticks).
Trimmed portion in ticks from the start of the clip.
Trimmed portion in ticks from the end of the clip.
Whether the mouse is hovering over the clip.
Whether the mouse is hovering over the clip’s menu bar.
Whether the clip has been played during current playback.
Flag indicating the clip should be deleted.
Flag indicating the clip should be duplicated.
Methods
UpdateClipData()
Updates the clip’s MIDI data with new data.The new MIDI clip data to replace the existing data.
Inherited Methods
MidiClip inherits these methods from theClip base class:
SetStartTick()
Sets the starting time of the clip in ticks.The starting time in ticks.
GetStartTimeInMusicalTime()
Returns the clip’s start time in musical notation (Bars.Beats.Ticks).GetEndTimeInMusicalTime()
Returns the clip’s end time in musical notation (Bars.Beats.Ticks).GetDurationInMusicalTime()
Returns the clip’s duration in musical notation (Bars.Beats.Ticks).GetDurationInSeconds()
Returns the clip’s duration in seconds.Play()
Plays the MIDI clip through the track’s engine.The MIDI file to play.
Starting offset in seconds.
Render()
Renders the clip in the arrangement view.Protected Methods
GetClipDuration()
Calculates and returns the duration of the clip in ticks based on the MIDI file’s duration.GetClipWidth()
Calculates and returns the width of the clip in pixels based on the current zoom level.RenderClipContent()
Renders the visual content of the clip (MIDI notes visualization).OnClipDoubleClickLeft()
Handles double-click events on the clip. Opens the piano roll editor view.Usage Example
Notes
- Double-clicking a MIDI clip opens it in the piano roll editor
- The clip’s name is automatically set from the MIDI file name when loading from a file
- The clip’s color is inherited from the parent track by default
- Clips can be dragged between tracks and duplicated with Ctrl+D
- MIDI clip duration is calculated from the MIDI file’s total duration in seconds
- The piano roll editor allows detailed note editing and is accessible via
PianoRollEditorproperty