Skip to content

Instantly share code, notes, and snippets.

@fluxtah
Last active February 3, 2020 19:56
Show Gist options
  • Save fluxtah/35609acfff9c3dd6a0d029d3e6fe061b to your computer and use it in GitHub Desktop.
Save fluxtah/35609acfff9c3dd6a0d029d3e6fe061b to your computer and use it in GitHub Desktop.
@Composable
fun PianoRollOctave(startFromF: Boolean = false, showNoteNames: Boolean = false, octave: Int? = 0) {
Stack {
Row {
repeat(7) {
PianoKey()
}
}
Row {
if (startFromF) {
AccidentalPianoKey(10.dp)
AccidentalPianoKey(5.dp)
AccidentalPianoKey(4.dp)
AccidentalPianoKey(21.dp)
AccidentalPianoKey(4.dp)
} else {
AccidentalPianoKey(10.dp)
AccidentalPianoKey(5.dp)
AccidentalPianoKey(21.dp)
AccidentalPianoKey(4.dp)
AccidentalPianoKey(4.dp)
}
}
if (showNoteNames) {
Row {
repeat(7) { noteIndex ->
Container(
LayoutPadding(right = 1.dp) + LayoutSize(16.dp, 62.dp),
alignment = Alignment.BottomCenter
) {
val noteName = formatNoteName(startFromF, noteIndex, octave)
Text(text = noteName, style = TextStyle(fontSize = 8.sp))
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment