zds-pickers 4.0.14 → 4.0.15
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 +11 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +213 -213
- package/dist/index.es.js.map +1 -1
- package/dist/other/SoundFontProvider.js +4 -2
- package/dist/rotaryKnob/helpers/KnobVisualHelpers.js +1 -1
- package/dist/types/other/OctavePlayer.d.ts +9 -3
- package/dist/types/other/SoundFontProvider.d.ts +1 -1
- package/lib/other/OctavePlayer.tsx +10 -3
- package/lib/other/SoundFontProvider.tsx +5 -3
- package/lib/rotaryKnob/helpers/KnobVisualHelpers.tsx +3 -2
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ const SoundfontProvider = (props) => {
|
|
|
22
22
|
setInstrument(newInstrument);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
else if (
|
|
25
|
+
else if (instrumentName) {
|
|
26
26
|
// the host app has already injected the soundfont into global space
|
|
27
27
|
Soundfont.instrument(audioContext, instrumentName).then(newInstrument => {
|
|
28
28
|
setInstrument(newInstrument);
|
|
@@ -34,7 +34,9 @@ const SoundfontProvider = (props) => {
|
|
|
34
34
|
}
|
|
35
35
|
}, [audioContext, format, hostname, instrumentName, soundfont]);
|
|
36
36
|
useEffect(() => {
|
|
37
|
-
|
|
37
|
+
if (instrumentName) {
|
|
38
|
+
loadInstrument(instrumentName);
|
|
39
|
+
}
|
|
38
40
|
}, [instrumentName, loadInstrument]);
|
|
39
41
|
useEffect(() => {
|
|
40
42
|
if (isDefined(instrumentName)) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { toRadians } from '../utils';
|
|
3
4
|
import { DrawCircle } from './DrawCircle';
|
|
4
5
|
import { DrawLine } from './DrawLine';
|
|
5
6
|
import { HelpersOverlay } from './HelpersOverlay';
|
|
6
|
-
import { toRadians } from '../utils';
|
|
7
7
|
class KnobVisualHelpers extends React.Component {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type Soundfont from 'soundfont-player';
|
|
2
2
|
import type { TooltipProps } from './DefaultTooltip';
|
|
3
|
+
type PianoMidiNote = {
|
|
4
|
+
accidental: boolean;
|
|
5
|
+
left: number;
|
|
6
|
+
midiNumber: number;
|
|
7
|
+
width: number;
|
|
8
|
+
};
|
|
3
9
|
type OctavePlayerProps = {
|
|
4
10
|
disabled?: boolean;
|
|
5
11
|
height: number;
|
|
@@ -10,12 +16,12 @@ type WithProviderProps = {
|
|
|
10
16
|
format?: 'mp3' | 'ogg';
|
|
11
17
|
height: number;
|
|
12
18
|
hostname?: string;
|
|
13
|
-
instrumentName
|
|
19
|
+
instrumentName?: Soundfont.InstrumentName;
|
|
14
20
|
octave?: number;
|
|
15
21
|
onChange?: (note: number) => void;
|
|
16
22
|
onClick?: (note: number) => void;
|
|
17
23
|
onDoubleClick?: (note: number) => void;
|
|
18
|
-
onKeyMouseEnter?: (note:
|
|
24
|
+
onKeyMouseEnter?: (note: PianoMidiNote) => void;
|
|
19
25
|
onKeyMouseLeave?: (note: number) => void;
|
|
20
26
|
soundfont?: 'MusyngKite' | 'FluidR3_GM';
|
|
21
27
|
Tooltip?: TooltipProps;
|
|
@@ -23,4 +29,4 @@ type WithProviderProps = {
|
|
|
23
29
|
};
|
|
24
30
|
declare const WithProvider: ({ format, height, hostname, instrumentName, octave, onChange, onClick, onDoubleClick, onKeyMouseEnter, onKeyMouseLeave, soundfont, Tooltip, width, }: WithProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
31
|
export { WithProvider as OctavePlayer };
|
|
26
|
-
export type { OctavePlayerProps, WithProviderProps };
|
|
32
|
+
export type { OctavePlayerProps, PianoMidiNote, WithProviderProps };
|
|
@@ -3,7 +3,7 @@ type SoundfontProviderProps = {
|
|
|
3
3
|
audioContext: AudioContext;
|
|
4
4
|
format?: 'mp3' | 'ogg';
|
|
5
5
|
hostname?: string;
|
|
6
|
-
instrumentName
|
|
6
|
+
instrumentName?: Soundfont.InstrumentName;
|
|
7
7
|
onChange?: (midiNumber: number) => void;
|
|
8
8
|
render: (props: {
|
|
9
9
|
isLoading: boolean;
|
|
@@ -4,6 +4,13 @@ import { Piano as ReactPiano } from 'zds-react-piano'
|
|
|
4
4
|
import type { TooltipProps } from './DefaultTooltip'
|
|
5
5
|
import { SoundfontProvider } from './SoundFontProvider'
|
|
6
6
|
|
|
7
|
+
type PianoMidiNote = {
|
|
8
|
+
accidental: boolean
|
|
9
|
+
left: number
|
|
10
|
+
midiNumber: number
|
|
11
|
+
width: number
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
const baseNotes = [
|
|
8
15
|
'C',
|
|
9
16
|
'C#',
|
|
@@ -67,12 +74,12 @@ type WithProviderProps = {
|
|
|
67
74
|
format?: 'mp3' | 'ogg'
|
|
68
75
|
height: number
|
|
69
76
|
hostname?: string
|
|
70
|
-
instrumentName
|
|
77
|
+
instrumentName?: Soundfont.InstrumentName
|
|
71
78
|
octave?: number
|
|
72
79
|
onChange?: (note: number) => void
|
|
73
80
|
onClick?: (note: number) => void
|
|
74
81
|
onDoubleClick?: (note: number) => void
|
|
75
|
-
onKeyMouseEnter?: (note:
|
|
82
|
+
onKeyMouseEnter?: (note: PianoMidiNote) => void
|
|
76
83
|
onKeyMouseLeave?: (note: number) => void
|
|
77
84
|
soundfont?: 'MusyngKite' | 'FluidR3_GM'
|
|
78
85
|
Tooltip?: TooltipProps
|
|
@@ -138,4 +145,4 @@ const WithProvider = ({
|
|
|
138
145
|
|
|
139
146
|
export { WithProvider as OctavePlayer }
|
|
140
147
|
|
|
141
|
-
export type { OctavePlayerProps, WithProviderProps }
|
|
148
|
+
export type { OctavePlayerProps, PianoMidiNote, WithProviderProps }
|
|
@@ -11,7 +11,7 @@ type SoundfontProviderProps = {
|
|
|
11
11
|
audioContext: AudioContext
|
|
12
12
|
format?: 'mp3' | 'ogg'
|
|
13
13
|
hostname?: string
|
|
14
|
-
instrumentName
|
|
14
|
+
instrumentName?: Soundfont.InstrumentName
|
|
15
15
|
onChange?: (midiNumber: number) => void
|
|
16
16
|
render: (props: {
|
|
17
17
|
isLoading: boolean
|
|
@@ -54,7 +54,7 @@ const SoundfontProvider = (props: SoundfontProviderProps) => {
|
|
|
54
54
|
}).then(newInstrument => {
|
|
55
55
|
setInstrument(newInstrument)
|
|
56
56
|
})
|
|
57
|
-
} else if (
|
|
57
|
+
} else if (instrumentName) {
|
|
58
58
|
// the host app has already injected the soundfont into global space
|
|
59
59
|
Soundfont.instrument(audioContext, instrumentName).then(
|
|
60
60
|
newInstrument => {
|
|
@@ -70,7 +70,9 @@ const SoundfontProvider = (props: SoundfontProviderProps) => {
|
|
|
70
70
|
)
|
|
71
71
|
|
|
72
72
|
useEffect(() => {
|
|
73
|
-
|
|
73
|
+
if (instrumentName) {
|
|
74
|
+
loadInstrument(instrumentName)
|
|
75
|
+
}
|
|
74
76
|
}, [instrumentName, loadInstrument])
|
|
75
77
|
|
|
76
78
|
useEffect(() => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { Point } from '../Types'
|
|
3
|
+
import { toRadians } from '../utils'
|
|
3
4
|
import { DrawCircle } from './DrawCircle'
|
|
4
5
|
import { DrawLine } from './DrawLine'
|
|
5
6
|
import { HelpersOverlay } from './HelpersOverlay'
|
|
6
|
-
import { toRadians } from '../utils'
|
|
7
7
|
|
|
8
8
|
/** Precision visual helpers */
|
|
9
9
|
|
|
@@ -50,7 +50,8 @@ class KnobVisualHelpers extends React.Component<
|
|
|
50
50
|
//Note: Not sure why we need to subtract 90 here
|
|
51
51
|
const valueMarkerX =
|
|
52
52
|
props.radius * Math.cos(toRadians(props.valueAngle - 90))
|
|
53
|
-
const valueMarkerY =
|
|
53
|
+
const valueMarkerY =
|
|
54
|
+
props.radius * Math.sin(toRadians(props.valueAngle - 90))
|
|
54
55
|
|
|
55
56
|
return {
|
|
56
57
|
...state,
|