MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / note

Method note

src/main/java/trace/sound/SaveMidi.kt:18–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 track = sequence.createTrack() // Begin with a new track
17 }
18
19 @Documentation("`note(time, pitch, velocity, duration)` adds a note to this file. Times are in seconds, pitch is 1-127, velocity is 0 to 1.")
20 fun note(time: Double, pitch: Int, velocity: Double, duration: Double) {
21 val on = ShortMessage()
22 on.setMessage(ShortMessage.NOTE_ON, 0, Math.max(0, Math.min(127, pitch)), Math.max(0, Math.min(127, (127 * velocity).toInt())))
23 val off = ShortMessage()
24 off.setMessage(ShortMessage.NOTE_OFF, 0, Math.max(0, Math.min(127, pitch)), 0)
25 track.add(MidiEvent(on, secondsToTicks(time)))
26 track.add(MidiEvent(off, secondsToTicks(time + duration)))
27 }
28
29 @Documentation("`note(time, pitch, velocity, duration, channel)` adds a note to this file. Times are in seconds, pitch is 1-127, velocity is 0 to 1. channel from 0-15")

Callers

nothing calls this directly

Calls 3

maxMethod · 0.45
minMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected