Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | import React from "react"; import { PIANO_ROLL_CELL_SIZE, TOTAL_NOTES } from "consts"; import { StyledPianoRollNote, StyledPatternChannelNotes, StyledPianoRollNoteTouchBlocker, } from "./style"; import { useAppSelector } from "store/hooks"; interface PatternChannelNotesProps { patternId: number; channelId: number; isActive: boolean; selectedRowIds?: ReadonlySet<number>; isDragging: boolean; } const ARPEGGIO_CODE = 0; const noteBottom = (note: number) => (note % TOTAL_NOTES) * PIANO_ROLL_CELL_SIZE; export const PatternChannelNotes = React.memo( ({ patternId, channelId, isActive, selectedRowIds, isDragging, }: PatternChannelNotesProps) => { const channelCells = useAppSelector( (state) => state.trackerDocument.present.song?.patterns[patternId], ); Iif (!channelCells) { return null; } let instrument: number | null = null; return ( <StyledPatternChannelNotes $active={isActive}> {channelCells.map((cell, rowIndex) => { Iif (!cell || cell.note === null) { return null; } const isSelected = isActive && (selectedRowIds?.has(rowIndex) ?? false); Iif (cell.instrument !== null) { instrument = cell.instrument; } const noteInstrument = instrument !== null && isActive ? instrument : undefined; const usingPreviousInstrument = cell.instrument === null && instrument !== null; const left = rowIndex * PIANO_ROLL_CELL_SIZE; const effect = cell.effectParam ?? 0; return ( <React.Fragment key={`note_${rowIndex}_${channelId}`}> <StyledPianoRollNote data-type="note" data-note={cell.note} data-row={rowIndex} $instrument={noteInstrument} $usingPreviousInstrument={usingPreviousInstrument} $isSelected={isSelected} $isDragging={isDragging} style={{ left, bottom: noteBottom(cell.note), }} > {isActive ? ( <StyledPianoRollNoteTouchBlocker $isSelected={isSelected} /> ) : null} </StyledPianoRollNote> {cell.effectCode === ARPEGGIO_CODE ? ( <> <StyledPianoRollNote data-param={effect >> 4} $instrument={noteInstrument} $usingPreviousInstrument={usingPreviousInstrument} $isVirtual style={{ left, bottom: noteBottom(cell.note + (effect >> 4)), }} /> <StyledPianoRollNote data-param={effect & 0xf} $instrument={noteInstrument} $usingPreviousInstrument={usingPreviousInstrument} $isVirtual style={{ left, bottom: noteBottom(cell.note + (effect & 0xf)), }} /> </> ) : null} </React.Fragment> ); })} </StyledPatternChannelNotes> ); }, ); |