DiatonicKeyboardWithControllers

fun DiatonicKeyboardWithControllers(noteOnStates: List<Long> = List(128) { 0L }, modifier: Modifier = Modifier, onNoteOn: (note: Int, reserved: Long) -> Unit = { _,_ -> }, onNoteOff: (note: Int, reserved: Long) -> Unit = { _,_ -> }, onExpression: (origin: DiatonicKeyboardNoteExpressionOrigin, note: Int, data: Float) -> Unit = {_,_,_ -> }, showNoteExpressionToggle: Boolean = true, showExpressionSensitivitySlider: Boolean = true, showOctaveSlider: Boolean = true, initialMoveAction: DiatonicKeyboardMoveAction = DiatonicKeyboardMoveAction.NoteChange, initialOctaveZeroBased: Int = 4, numWhiteKeys: Int = 14, initialExpressionDragSensitivity: Int = 80, whiteKeyWidth: Dp = 30.dp, blackKeyHeight: Dp = 35.dp, totalWidth: Dp? = whiteKeyWidth * numWhiteKeys, totalHeight: Dp = 60.dp, whiteNoteOnColor: Color = Color.Cyan, blackNoteOnColor: Color = whiteNoteOnColor, whiteKeyColor: Color = Color.White, blackKeyColor: Color = Color.Black)

It is a compound set of DiatonicKeyboard with the following controllers:

  • it can toggle NoteExpression mode

  • it can change the note expression sensitivity using slider. It ranges from32 to 320 (2 inches).

  • it can change the base octave.

The list of parameters are almost identical to DiatonicKeyboard, except:

  • some parameters are named "initial",

  • there are showXXX parameters that indicate whether it should render each controllers.

For more details, see DiatonicKeyboard documentation.

Parameters

noteOnStates

a List of Long that holds note states. It must contain 128 elements. Currently it only expects that note on state holds non-zero value.

modifier

a Modifier that applies to its top level Column.

onNoteOn

an event handler that is called when a key for a note is pressed

onNoteOff

an event handler that is called when a key for a note is released

onExpression

an event handler that is called when note expression events occur, by dragging (if indicated so by moveAction). The value range for data sent to the handler depends on the target origin. For HorizontalDragging and VerticalDragging they are -1.0f..1.0f. For Pressure it is up to device.

showNoteExpressionToggle

indicates whether the mode (note change vs. note expression) toggle switch is rendered. true by default.

showExpressionSensitivitySlider

indicates whether the expression sensitivity slider is rendered. true by default.

showOctaveSlider

indicates whether the octave slider is rendered. true by default.

initialMoveAction

indicates the initial value of moveAction that how dragging works. See the documentation on DiatonicKeyboardMoveAction enumeration type. NoteChange by default.

initialOctaveZeroBased

the initial value of octave (in zero-based counting i.e. 0 to 9 or 10 (up to numWhiteKeys). 4 by default.

numWhiteKeys

the number of white keys to be rendered. 14 by default (which means 2 octaves)

initialExpressionDragSensitivity

the initial value of the sensitivity parameter over note expression dragging. The value is treated as a Dp value that corresponds to the width for "half" of the motion size towards max or min value. 80 (Dp) by default.

whiteKeyWidth

The display size for one white key width. 30.dp by default.

blackKeyHeight

The display size for black key height. 35.dp by default.

totalWidth

The display size for the whole keyboard control. It is automatically calculated as whiteKeyWidth * numWhiteKeys but you can change it. Alternatively, you can explicitly specify null then it will take use Modifier.fillMaxSize() (but note that the number of the rendered key is governed by numWhiteKeys anyways).

totalHeight

The display size for the whole keyboard control. It also means white key height. 60.dp by default.

whiteNoteOnColor

A Color value for the note on indication on the white keys. Color.Cyan by default.

blackNoteOnColor

A Color value for the note on indication on the black keys. whiteNoteOnColor by default.

whiteKeyColor

A Color value for the white keys (when not at note-on state). Color.White by default.

blackKeyColor

A Color value for the black keys (when not at note-on state). Color.Black by default.