zds-pickers 4.1.1 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +9 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +3236 -3135
- package/dist/index.es.js.map +1 -1
- package/dist/other/SoundFontProvider.js +6 -5
- package/dist/types/other/SoundFontProvider.d.ts +1 -1
- package/lib/soundfonts/acoustic_grand_piano-mp3.js +107 -0
- package/package.json +9 -2
- package/.editorconfig +0 -19
- package/.github/workflows/codeql-analysis.yml +0 -67
- package/.nvmrc +0 -1
- package/.prettierignore +0 -0
- package/.prettierrc +0 -13
- package/.storybook/main.ts +0 -42
- package/.storybook/manager.ts +0 -12
- package/.storybook/preview.tsx +0 -26
- package/.vscode/extensions.json +0 -32
- package/.vscode/javascript.code-snippets +0 -229
- package/.vscode/settings.json +0 -358
- package/biome.jsonc +0 -158
- package/lib/@types/nebiru-react-rotary-knob.d.ts +0 -20
- package/lib/@types/react-svgmt.d.ts +0 -74
- package/lib/@types/zds-mappings.d.ts +0 -55
- package/lib/@types/zds-react-piano.d.ts +0 -17
- package/lib/hooks/useComponentSize.ts +0 -52
- package/lib/hooks/useStateWithDynamicDefault.ts +0 -13
- package/lib/index.ts +0 -52
- package/lib/midi/ccValues.ts +0 -139
- package/lib/midi/export.ts +0 -88
- package/lib/other/DefaultTooltip.ts +0 -14
- package/lib/other/OctavePlayer.tsx +0 -139
- package/lib/other/SoundFontProvider.tsx +0 -214
- package/lib/other/SvgText.tsx +0 -221
- package/lib/pickers/CCPicker.tsx +0 -28
- package/lib/pickers/ChannelMappingPicker.tsx +0 -150
- package/lib/pickers/ChannelPicker.tsx +0 -84
- package/lib/pickers/KeyPicker.tsx +0 -55
- package/lib/pickers/Knob.tsx +0 -93
- package/lib/pickers/KnobPicker.tsx +0 -93
- package/lib/pickers/LatchPicker.tsx +0 -33
- package/lib/pickers/MappingPicker.tsx +0 -68
- package/lib/pickers/NotePicker.tsx +0 -95
- package/lib/pickers/PianoPicker.tsx +0 -81
- package/lib/pickers/PolarityPicker.tsx +0 -39
- package/lib/pickers/ResponseCurve.tsx +0 -251
- package/lib/pickers/ResponseCurvePicker.tsx +0 -75
- package/lib/pickers/Select.tsx +0 -268
- package/lib/pickers/StatusPicker.tsx +0 -30
- package/lib/pickers/ValuePicker.tsx +0 -67
- package/lib/pickers/knobSkin10.tsx +0 -112
- package/lib/rotaryKnob/InternalInput.tsx +0 -43
- package/lib/rotaryKnob/Types.ts +0 -6
- package/lib/rotaryKnob/helpers/DrawCircle.tsx +0 -41
- package/lib/rotaryKnob/helpers/DrawLine.tsx +0 -32
- package/lib/rotaryKnob/helpers/HelpersOverlay.tsx +0 -43
- package/lib/rotaryKnob/helpers/KnobVisualHelpers.tsx +0 -138
- package/lib/rotaryKnob/index.tsx +0 -417
- package/lib/rotaryKnob/knobdefaultskin.ts +0 -69
- package/lib/rotaryKnob/utils.ts +0 -112
- package/lib/utils.ts +0 -41
- package/stories/assets/sampleStyles.css +0 -365
- package/stories/assets/utils.js +0 -7
- package/stories/picker.stories.tsx +0 -432
- package/tsconfig.json +0 -35
- package/vite.config.ts +0 -41
- /package/{lib/temp → dist/soundfonts}/acoustic_grand_piano-mp3.js +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { useCallback, useLayoutEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const getSize = (el: HTMLDivElement | null) =>
|
|
4
|
-
el
|
|
5
|
-
? {
|
|
6
|
-
width: el.offsetWidth,
|
|
7
|
-
height: el.offsetHeight,
|
|
8
|
-
}
|
|
9
|
-
: {
|
|
10
|
-
width: 0,
|
|
11
|
-
height: 0,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const useComponentSize = (ref: React.RefObject<HTMLDivElement>) => {
|
|
15
|
-
const [componentSize, setComponentSize] = useState(
|
|
16
|
-
getSize(ref ? ref.current : null),
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
const handleResize = useCallback(() => {
|
|
20
|
-
if (ref.current) {
|
|
21
|
-
setComponentSize(getSize(ref.current))
|
|
22
|
-
}
|
|
23
|
-
}, [ref])
|
|
24
|
-
|
|
25
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
26
|
-
useLayoutEffect(() => {
|
|
27
|
-
if (!ref.current) return
|
|
28
|
-
|
|
29
|
-
handleResize()
|
|
30
|
-
|
|
31
|
-
if (typeof ResizeObserver === 'function') {
|
|
32
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
33
|
-
handleResize()
|
|
34
|
-
})
|
|
35
|
-
resizeObserver.observe(ref.current)
|
|
36
|
-
|
|
37
|
-
return () => {
|
|
38
|
-
resizeObserver.disconnect()
|
|
39
|
-
// resizeObserver = null
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
window.addEventListener('resize', handleResize)
|
|
43
|
-
|
|
44
|
-
return () => {
|
|
45
|
-
window.removeEventListener('resize', handleResize)
|
|
46
|
-
}
|
|
47
|
-
}, [ref.current])
|
|
48
|
-
|
|
49
|
-
return componentSize
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default useComponentSize
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const useStateWithDynamicDefault = <T>(defaultVal: T) => {
|
|
4
|
-
const [state, setState] = useState<T>(defaultVal)
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
setState(defaultVal)
|
|
8
|
-
}, [defaultVal])
|
|
9
|
-
|
|
10
|
-
return [state, setState] as const
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default useStateWithDynamicDefault
|
package/lib/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export * from './utils'
|
|
2
|
-
|
|
3
|
-
export * from './midi/ccValues'
|
|
4
|
-
export * from './midi/export'
|
|
5
|
-
|
|
6
|
-
export * from './other/DefaultTooltip'
|
|
7
|
-
export * from './other/OctavePlayer'
|
|
8
|
-
export * from './other/SvgText'
|
|
9
|
-
|
|
10
|
-
export * from './pickers/CCPicker'
|
|
11
|
-
export * from './pickers/ChannelMappingPicker'
|
|
12
|
-
export * from './pickers/ChannelPicker'
|
|
13
|
-
export * from './pickers/KeyPicker'
|
|
14
|
-
export * from './pickers/Knob'
|
|
15
|
-
export * from './pickers/KnobPicker'
|
|
16
|
-
export * from './pickers/LatchPicker'
|
|
17
|
-
export * from './pickers/MappingPicker'
|
|
18
|
-
export * from './pickers/NotePicker'
|
|
19
|
-
export * from './pickers/PianoPicker'
|
|
20
|
-
export * from './pickers/PolarityPicker'
|
|
21
|
-
export * from './pickers/ResponseCurve'
|
|
22
|
-
export * from './pickers/ResponseCurvePicker'
|
|
23
|
-
export * from './pickers/Select'
|
|
24
|
-
export * from './pickers/StatusPicker'
|
|
25
|
-
export * from './pickers/ValuePicker'
|
|
26
|
-
|
|
27
|
-
// Types
|
|
28
|
-
export type * from './midi/export'
|
|
29
|
-
|
|
30
|
-
export type * from './other/DefaultTooltip'
|
|
31
|
-
export type * from './other/OctavePlayer'
|
|
32
|
-
export type * from './other/SoundFontProvider'
|
|
33
|
-
export type * from './other/SvgText'
|
|
34
|
-
|
|
35
|
-
export type * from './pickers/CCPicker'
|
|
36
|
-
export type * from './pickers/ChannelMappingPicker'
|
|
37
|
-
export type * from './pickers/ChannelPicker'
|
|
38
|
-
export type * from './pickers/KeyPicker'
|
|
39
|
-
export type * from './pickers/Knob'
|
|
40
|
-
export type * from './pickers/KnobPicker'
|
|
41
|
-
export type * from './pickers/LatchPicker'
|
|
42
|
-
export type * from './pickers/MappingPicker'
|
|
43
|
-
export type * from './pickers/NotePicker'
|
|
44
|
-
export type * from './pickers/PianoPicker'
|
|
45
|
-
export type * from './pickers/PolarityPicker'
|
|
46
|
-
export type * from './pickers/ResponseCurve'
|
|
47
|
-
export type * from './pickers/ResponseCurvePicker'
|
|
48
|
-
export type * from './pickers/Select'
|
|
49
|
-
export type * from './pickers/StatusPicker'
|
|
50
|
-
export type * from './pickers/ValuePicker'
|
|
51
|
-
|
|
52
|
-
export type * from './rotaryKnob/InternalInput'
|
package/lib/midi/ccValues.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { Option } from '../pickers/Select'
|
|
2
|
-
|
|
3
|
-
const changeControllerOptions = [
|
|
4
|
-
'Bank Select',
|
|
5
|
-
'Modulation Wheel',
|
|
6
|
-
'Breath Controller',
|
|
7
|
-
'',
|
|
8
|
-
'Foot Control',
|
|
9
|
-
'Portamento Time',
|
|
10
|
-
'Data Entry Slider',
|
|
11
|
-
'Volume',
|
|
12
|
-
'Balance',
|
|
13
|
-
'',
|
|
14
|
-
'Pan',
|
|
15
|
-
'Expression',
|
|
16
|
-
'Effect Control 1',
|
|
17
|
-
'Effect Control 2',
|
|
18
|
-
'',
|
|
19
|
-
'',
|
|
20
|
-
'',
|
|
21
|
-
'',
|
|
22
|
-
'',
|
|
23
|
-
'',
|
|
24
|
-
'',
|
|
25
|
-
'',
|
|
26
|
-
'',
|
|
27
|
-
'',
|
|
28
|
-
'',
|
|
29
|
-
'',
|
|
30
|
-
'',
|
|
31
|
-
'',
|
|
32
|
-
'',
|
|
33
|
-
'',
|
|
34
|
-
'',
|
|
35
|
-
'',
|
|
36
|
-
'Controller 0',
|
|
37
|
-
'Controller 1',
|
|
38
|
-
'Controller 2',
|
|
39
|
-
'Controller 3',
|
|
40
|
-
'Controller 4',
|
|
41
|
-
'Controller 5',
|
|
42
|
-
'Controller 6',
|
|
43
|
-
'Controller 7',
|
|
44
|
-
'Controller 8',
|
|
45
|
-
'Controller 9',
|
|
46
|
-
'Controller 10',
|
|
47
|
-
'Controller 11',
|
|
48
|
-
'Controller 12',
|
|
49
|
-
'Controller 13',
|
|
50
|
-
'Controller 14',
|
|
51
|
-
'Controller 15',
|
|
52
|
-
'Controller 16',
|
|
53
|
-
'Controller 17',
|
|
54
|
-
'Controller 18',
|
|
55
|
-
'Controller 19',
|
|
56
|
-
'Controller 20',
|
|
57
|
-
'Controller 21',
|
|
58
|
-
'Controller 22',
|
|
59
|
-
'Controller 23',
|
|
60
|
-
'Controller 24',
|
|
61
|
-
'Controller 25',
|
|
62
|
-
'Controller 26',
|
|
63
|
-
'Controller 27',
|
|
64
|
-
'Controller 28',
|
|
65
|
-
'Controller 29',
|
|
66
|
-
'Controller 30',
|
|
67
|
-
'Controller 31',
|
|
68
|
-
'Sustain',
|
|
69
|
-
'Portamento',
|
|
70
|
-
'Sostenuto',
|
|
71
|
-
'Soft Pedal',
|
|
72
|
-
'Legato Pedal',
|
|
73
|
-
'Sustain 2',
|
|
74
|
-
'Sound Variation',
|
|
75
|
-
'Resonance/Timbre',
|
|
76
|
-
'Sound Release Time',
|
|
77
|
-
'Sound Attack Time',
|
|
78
|
-
'Frequency Cutoff',
|
|
79
|
-
'Sound Control 6',
|
|
80
|
-
'Sound Control 7',
|
|
81
|
-
'Sound Control 8',
|
|
82
|
-
'Sound Control 9',
|
|
83
|
-
'Sound Control 10',
|
|
84
|
-
'Decay or General 1',
|
|
85
|
-
'Hi-Pass or General 2',
|
|
86
|
-
'General 3',
|
|
87
|
-
'General 4',
|
|
88
|
-
'Portamento Amount',
|
|
89
|
-
'',
|
|
90
|
-
'',
|
|
91
|
-
'',
|
|
92
|
-
'',
|
|
93
|
-
'',
|
|
94
|
-
'',
|
|
95
|
-
'Reverb Level',
|
|
96
|
-
'Tremolo Depth',
|
|
97
|
-
'Chorus Level',
|
|
98
|
-
'Detune',
|
|
99
|
-
'Phaser Depth',
|
|
100
|
-
'Data Entry +1',
|
|
101
|
-
'Data Entry -1',
|
|
102
|
-
'Non-registered LSB',
|
|
103
|
-
'Non-registered MSB',
|
|
104
|
-
'Registered msb',
|
|
105
|
-
'Registered lsb',
|
|
106
|
-
'',
|
|
107
|
-
'',
|
|
108
|
-
'',
|
|
109
|
-
'',
|
|
110
|
-
'',
|
|
111
|
-
'',
|
|
112
|
-
'',
|
|
113
|
-
'',
|
|
114
|
-
'Shift 1',
|
|
115
|
-
'Shift 2',
|
|
116
|
-
'Shift 3',
|
|
117
|
-
'Shift 4',
|
|
118
|
-
'Shift 5',
|
|
119
|
-
'Shift 6',
|
|
120
|
-
'',
|
|
121
|
-
'',
|
|
122
|
-
'',
|
|
123
|
-
'',
|
|
124
|
-
'All Sound Off',
|
|
125
|
-
'All Controllers Off',
|
|
126
|
-
'Local Mode',
|
|
127
|
-
'All Notes Off',
|
|
128
|
-
'Omni Mode Off',
|
|
129
|
-
'Omni Mode On',
|
|
130
|
-
'Mono Mode On',
|
|
131
|
-
'Poly Mode',
|
|
132
|
-
].map(
|
|
133
|
-
(label, value): Option<number> => ({
|
|
134
|
-
label: String(label).length ? `${value} - ${label}` : String(value),
|
|
135
|
-
value,
|
|
136
|
-
}),
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
export { changeControllerOptions }
|
package/lib/midi/export.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { Option, noSelection } from 'lib/pickers/Select'
|
|
2
|
-
|
|
3
|
-
const Statuses = {
|
|
4
|
-
noteOff: 8, // 1000
|
|
5
|
-
noteOn: 9, // 1001
|
|
6
|
-
aftertouch: 10, // 1010
|
|
7
|
-
controlChange: 11, // 1011
|
|
8
|
-
programChange: 12, // 1100
|
|
9
|
-
channelPressure: 13, // 1101
|
|
10
|
-
pitchWheel: 14, // 1110
|
|
11
|
-
} as const
|
|
12
|
-
|
|
13
|
-
// Define type as union of literal values
|
|
14
|
-
type Status = 8 | 9 | 10 | 11 | 12 | 13 | 14
|
|
15
|
-
|
|
16
|
-
const MASK_CHANNEL = 15 // 00001111
|
|
17
|
-
const MASK_STATUS = 240 // 01110000
|
|
18
|
-
|
|
19
|
-
const statusOptions: Option<Status>[] = [
|
|
20
|
-
{ value: Statuses.noteOn, label: 'Note On' },
|
|
21
|
-
{ value: Statuses.noteOff, label: 'Note Stack' },
|
|
22
|
-
{ value: Statuses.controlChange, label: 'Control Change' },
|
|
23
|
-
{ value: Statuses.programChange, label: 'Program Change' },
|
|
24
|
-
{ value: Statuses.aftertouch, label: 'Aftertouch' },
|
|
25
|
-
{ value: Statuses.channelPressure, label: 'Channel Pressure' },
|
|
26
|
-
{ value: Statuses.pitchWheel, label: 'Pitch Wheel' },
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
const getStatusLabel = (val: Status) =>
|
|
30
|
-
statusOptions.filter(({ value }) => value === val)[0]?.label || '???'
|
|
31
|
-
|
|
32
|
-
const combineStatusWithChannel = (channel: number, status: Status) =>
|
|
33
|
-
channel | (status << 4)
|
|
34
|
-
|
|
35
|
-
const extractStatusAndChannel = (
|
|
36
|
-
status: number,
|
|
37
|
-
): {
|
|
38
|
-
status: Status
|
|
39
|
-
channel: number
|
|
40
|
-
} => ({
|
|
41
|
-
status: (((status & MASK_STATUS) >> 4) | 8) as Status,
|
|
42
|
-
channel: status & MASK_CHANNEL,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const RESPONSE_CURVE_0 = 0
|
|
46
|
-
const RESPONSE_CURVE_1 = 1
|
|
47
|
-
const RESPONSE_CURVE_2 = 2
|
|
48
|
-
const RESPONSE_CURVE_3 = 3
|
|
49
|
-
const RESPONSE_CURVE_4 = 4
|
|
50
|
-
const RESPONSE_CURVE_5 = 5
|
|
51
|
-
const RESPONSE_CURVE_6 = 6
|
|
52
|
-
const RESPONSE_CURVE_7 = 7
|
|
53
|
-
|
|
54
|
-
const ResponseCurveLabels = {
|
|
55
|
-
[RESPONSE_CURVE_0]: 'Linear, no change',
|
|
56
|
-
[RESPONSE_CURVE_1]: 'A little less sensitive',
|
|
57
|
-
[RESPONSE_CURVE_2]: 'Even less sensitive',
|
|
58
|
-
[RESPONSE_CURVE_3]: 'Least sensitive',
|
|
59
|
-
[RESPONSE_CURVE_4]: 'A little sensitive',
|
|
60
|
-
[RESPONSE_CURVE_5]: 'Moderately sensitive',
|
|
61
|
-
[RESPONSE_CURVE_6]: 'Most sensitive',
|
|
62
|
-
[RESPONSE_CURVE_7]: 'Always maxed out',
|
|
63
|
-
} as const
|
|
64
|
-
|
|
65
|
-
// type Curve = (typeof Items)[keyof typeof Items]
|
|
66
|
-
|
|
67
|
-
type Curve = keyof typeof ResponseCurveLabels | typeof noSelection
|
|
68
|
-
|
|
69
|
-
const responseCurves: Option<Curve>[] = Object.keys(ResponseCurveLabels)
|
|
70
|
-
.map(Number)
|
|
71
|
-
.map(key => ({
|
|
72
|
-
value: key as Curve,
|
|
73
|
-
label: ResponseCurveLabels[key as keyof typeof ResponseCurveLabels],
|
|
74
|
-
}))
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
combineStatusWithChannel,
|
|
78
|
-
extractStatusAndChannel,
|
|
79
|
-
getStatusLabel,
|
|
80
|
-
MASK_CHANNEL,
|
|
81
|
-
MASK_STATUS,
|
|
82
|
-
responseCurves,
|
|
83
|
-
ResponseCurveLabels,
|
|
84
|
-
Statuses,
|
|
85
|
-
statusOptions,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type { Curve, Status }
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Fragment, createElement } from 'react'
|
|
2
|
-
|
|
3
|
-
type TooltipProps = {
|
|
4
|
-
children?: React.ReactNode
|
|
5
|
-
placement?: 'left' | 'right' | 'top' | 'bottom'
|
|
6
|
-
title: React.ReactNode
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const DefaultTooltip = ({ children }: React.PropsWithoutRef<TooltipProps>) =>
|
|
10
|
-
createElement(Fragment, null, children)
|
|
11
|
-
|
|
12
|
-
export { DefaultTooltip }
|
|
13
|
-
|
|
14
|
-
export type { TooltipProps }
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { PianoProps } from 'lib/pickers/PianoPicker'
|
|
2
|
-
import type Soundfont from 'soundfont-player'
|
|
3
|
-
import { /* Midi, */ Note } from 'tonal'
|
|
4
|
-
import { Piano as ReactPiano } from 'zds-react-piano'
|
|
5
|
-
import type { TooltipProps } from './DefaultTooltip'
|
|
6
|
-
import { SoundfontProvider } from './SoundFontProvider'
|
|
7
|
-
|
|
8
|
-
type PianoMidiNote = {
|
|
9
|
-
accidental: boolean
|
|
10
|
-
left: number
|
|
11
|
-
midiNumber: number
|
|
12
|
-
width: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const baseNotes = [
|
|
16
|
-
'C',
|
|
17
|
-
'C#',
|
|
18
|
-
'D',
|
|
19
|
-
'D#',
|
|
20
|
-
'E',
|
|
21
|
-
'F',
|
|
22
|
-
'F#',
|
|
23
|
-
'G',
|
|
24
|
-
'G#',
|
|
25
|
-
'A',
|
|
26
|
-
'A#',
|
|
27
|
-
'B',
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
// const { midiToFreq, midiToNoteName } = Midi
|
|
31
|
-
|
|
32
|
-
// console.log(Note.names(), Note.midi('C4'))
|
|
33
|
-
|
|
34
|
-
// const firstNote = 21
|
|
35
|
-
// const lastNote = 108
|
|
36
|
-
const numNotes = 12
|
|
37
|
-
|
|
38
|
-
const whiteNotes = numNotes * 0.7 // approx
|
|
39
|
-
|
|
40
|
-
const audioContext = new window.AudioContext()
|
|
41
|
-
|
|
42
|
-
type OctavePlayerProps = PianoProps & {
|
|
43
|
-
disabled?: boolean
|
|
44
|
-
height: number
|
|
45
|
-
octave: number
|
|
46
|
-
width: number
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const BaseOctavePlayer = ({
|
|
50
|
-
octave,
|
|
51
|
-
height,
|
|
52
|
-
width,
|
|
53
|
-
...rest
|
|
54
|
-
}: OctavePlayerProps) => {
|
|
55
|
-
const keyWidth = width / whiteNotes + 2
|
|
56
|
-
const keyWidthToHeight = keyWidth / height
|
|
57
|
-
|
|
58
|
-
const firstNote = Note.midi(baseNotes[0] + String(octave)) || 0
|
|
59
|
-
const lastNote =
|
|
60
|
-
Note.midi(baseNotes[baseNotes.length - 1] + String(octave)) || 0
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<div>
|
|
64
|
-
<ReactPiano
|
|
65
|
-
keyWidthToHeight={keyWidthToHeight}
|
|
66
|
-
noteRange={{ first: firstNote, last: lastNote }}
|
|
67
|
-
width={width}
|
|
68
|
-
{...rest}
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
type WithProviderProps = PianoProps & {
|
|
75
|
-
format?: 'mp3' | 'ogg'
|
|
76
|
-
height: number
|
|
77
|
-
hostname?: string
|
|
78
|
-
instrumentName?: Soundfont.InstrumentName
|
|
79
|
-
octave?: number
|
|
80
|
-
onChange?: (note: number) => void
|
|
81
|
-
onClick?: (note: number) => void
|
|
82
|
-
onDoubleClick?: (note: number) => void
|
|
83
|
-
onKeyMouseEnter?: (note: PianoMidiNote) => void
|
|
84
|
-
onKeyMouseLeave?: (note: number) => void
|
|
85
|
-
selectedNotes?: number[]
|
|
86
|
-
soundfont?: 'MusyngKite' | 'FluidR3_GM'
|
|
87
|
-
Tooltip?: TooltipProps
|
|
88
|
-
width: number
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const WithProvider = ({
|
|
92
|
-
format,
|
|
93
|
-
height,
|
|
94
|
-
hostname,
|
|
95
|
-
instrumentName,
|
|
96
|
-
octave = 4,
|
|
97
|
-
onChange,
|
|
98
|
-
onClick,
|
|
99
|
-
onDoubleClick,
|
|
100
|
-
onKeyMouseEnter,
|
|
101
|
-
onKeyMouseLeave,
|
|
102
|
-
selectedNotes,
|
|
103
|
-
soundfont,
|
|
104
|
-
Tooltip,
|
|
105
|
-
width,
|
|
106
|
-
}: WithProviderProps) => (
|
|
107
|
-
<SoundfontProvider
|
|
108
|
-
{...{
|
|
109
|
-
audioContext,
|
|
110
|
-
format,
|
|
111
|
-
hostname,
|
|
112
|
-
instrumentName,
|
|
113
|
-
onChange,
|
|
114
|
-
soundfont,
|
|
115
|
-
}}
|
|
116
|
-
render={({ isLoading, playNote, stopNote }) => (
|
|
117
|
-
<BaseOctavePlayer
|
|
118
|
-
disabled={isLoading}
|
|
119
|
-
{...{
|
|
120
|
-
height,
|
|
121
|
-
octave,
|
|
122
|
-
onClick,
|
|
123
|
-
onDoubleClick,
|
|
124
|
-
onKeyMouseEnter,
|
|
125
|
-
onKeyMouseLeave,
|
|
126
|
-
playNote,
|
|
127
|
-
selectedNotes,
|
|
128
|
-
stopNote,
|
|
129
|
-
Tooltip,
|
|
130
|
-
width,
|
|
131
|
-
}}
|
|
132
|
-
/>
|
|
133
|
-
)}
|
|
134
|
-
/>
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
export { WithProvider as OctavePlayer }
|
|
138
|
-
|
|
139
|
-
export type { OctavePlayerProps, PianoMidiNote, WithProviderProps }
|