-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrack.jsx
More file actions
45 lines (42 loc) · 1.05 KB
/
Track.jsx
File metadata and controls
45 lines (42 loc) · 1.05 KB
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
import { memo } from 'react'
import Pad from './Pad'
const Track = memo(function Track({
instrument,
steps,
pattern,
currentStep,
onToggle,
showLabel = true,
}) {
// Group pads into groups of 4
const padGroups = []
for (let g = 0; g < steps; g += 4) {
padGroups.push(
Array.from({ length: 4 }, (_, i) => g + i)
)
}
return (
<div className="track-row">
{showLabel && <span className="track-label">{instrument.name}</span>}
<div className="notes-container">
{padGroups.map((group, groupIndex) => (
<div
key={groupIndex}
className={`pad-group ${groupIndex === 0 || groupIndex === 2 ? 'bordered' : ''}`}
>
{group.map(i => (
<Pad
key={i}
active={pattern[i]}
playing={currentStep === i}
isBeatStart={i % 4 === 0}
onClick={() => onToggle(instrument.id, i)}
/>
))}
</div>
))}
</div>
</div>
)
})
export default Track