@tialro2/rnbokit 1.0.15 → 1.0.18
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/README.md +242 -242
- package/dist/RNBO.css +113 -113
- package/dist/RNBO.svelte +230 -230
- package/dist/RNBOcomponents/AudioDropIn.svelte +125 -125
- package/dist/RNBOcomponents/ExtMidiIn.svelte +85 -85
- package/dist/RNBOcomponents/ExtMidiOut.svelte +85 -85
- package/dist/RNBOcomponents/MicIn.svelte +80 -80
- package/dist/RNBOcomponents/RNBOInlet.svelte +66 -66
- package/dist/RNBOcomponents/RNBOInport.svelte +21 -21
- package/dist/RNBOcomponents/RNBOMidiIn.svelte +63 -63
- package/dist/RNBOcomponents/RNBOMidiOut.svelte +22 -22
- package/dist/RNBOcomponents/RNBOOutport.svelte +36 -36
- package/dist/RNBOcomponents/RNBOParam.svelte +37 -37
- package/dist/RNBOcomponents/XYMidiIn.svelte +93 -93
- package/dist/UIcomponents/Controls.svelte +12 -12
- package/dist/UIcomponents/FileDropZone.svelte +118 -118
- package/dist/UIcomponents/ProgressBar.svelte +35 -35
- package/dist/UIcomponents/RadioGroup.svelte +27 -27
- package/dist/UIcomponents/RadioItem.svelte +96 -96
- package/dist/index.js +20 -20
- package/package.json +10 -10
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
//TODO: create a nice way to visualise the average volume!
|
|
3
|
-
import { onDestroy } from 'svelte';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** @type {MediaStream|null} */
|
|
7
|
-
let stream = $state();
|
|
8
|
-
|
|
1
|
+
<script>
|
|
2
|
+
//TODO: create a nice way to visualise the average volume!
|
|
3
|
+
import { onDestroy } from 'svelte';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/** @type {MediaStream|null} */
|
|
7
|
+
let stream = $state();
|
|
8
|
+
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Object} Props
|
|
11
11
|
* @property {AudioContext} context
|
|
@@ -14,75 +14,75 @@
|
|
|
14
14
|
|
|
15
15
|
/** @type {Props & { [key: string]: any }} */
|
|
16
16
|
let { context, audio = $bindable(), ...rest } = $props();
|
|
17
|
-
|
|
18
|
-
let volumeCallback = null;
|
|
19
|
-
/** @type {number|null} */
|
|
20
|
-
let averageVolume = $state(0);
|
|
21
|
-
|
|
22
|
-
/** @param {MediaStream} stream */
|
|
23
|
-
const handleSuccess = (stream) => {
|
|
24
|
-
const source = context.createMediaStreamSource(stream);
|
|
25
|
-
let analyser = context.createAnalyser();
|
|
26
|
-
analyser.fftSize = 512;
|
|
27
|
-
analyser.minDecibels = -127;
|
|
28
|
-
analyser.maxDecibels = 0;
|
|
29
|
-
analyser.smoothingTimeConstant = 0.4;
|
|
30
|
-
source.connect(analyser);
|
|
31
|
-
const volumes = new Uint8Array(analyser.frequencyBinCount);
|
|
32
|
-
//probe every 100ms for the average volume
|
|
33
|
-
volumeCallback = setInterval(() => {
|
|
34
|
-
analyser.getByteFrequencyData(volumes);
|
|
35
|
-
let volumeSum = 0;
|
|
36
|
-
for (const volume of volumes) volumeSum += volume;
|
|
37
|
-
averageVolume = volumeSum / volumes.length;
|
|
38
|
-
// console.log(`brightness-[${averageVolume / 100}]`);
|
|
39
|
-
}, 100);
|
|
40
|
-
source.connect(analyser);
|
|
41
|
-
audio = analyser;
|
|
42
|
-
// analyser.connect(device.node, inlet.index - 1);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
async function connectMic() {
|
|
46
|
-
if (!stream) {
|
|
47
|
-
stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: false });
|
|
48
|
-
handleSuccess(stream);
|
|
49
|
-
} else {
|
|
50
|
-
disconnectMic();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function disconnectMic() {
|
|
54
|
-
if (!stream) return;
|
|
55
|
-
clearInterval(volumeCallback);
|
|
56
|
-
volumeCallback = null;
|
|
57
|
-
averageVolume = 0;
|
|
58
|
-
stream.getTracks().forEach((track) => track.stop());
|
|
59
|
-
stream = null;
|
|
60
|
-
}
|
|
61
|
-
onDestroy(disconnectMic);
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
<div class="RNBOsubcomponent RNBOalign" {...rest}>
|
|
65
|
-
<button onclick={connectMic} type="button" class="RNBObutton">
|
|
66
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512" class:RNBOfill={stream}>
|
|
67
|
-
<path
|
|
68
|
-
d="M176 352c53.02 0 96-42.98 96-96V96c0-53.02-42.98-96-96-96S80 42.98 80 96v160c0 53.02 42.98 96 96 96zm160-160h-16c-8.84 0-16 7.16-16 16v48c0 74.8-64.49 134.82-140.79 127.38C96.71 376.89 48 317.11 48 250.3V208c0-8.84-7.16-16-16-16H16c-8.84 0-16 7.16-16 16v40.16c0 89.64 63.97 169.55 152 181.69V464H96c-8.84 0-16 7.16-16 16v16c0 8.84 7.16 16 16 16h160c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16h-56v-33.77C285.71 418.47 352 344.9 352 256v-48c0-8.84-7.16-16-16-16z"
|
|
69
|
-
/>
|
|
70
|
-
</svg>
|
|
71
|
-
</button>
|
|
72
|
-
<p>{averageVolume}</p>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<style>
|
|
76
|
-
.RNBOfill {
|
|
77
|
-
fill: rgb(var(--local-accent-color));
|
|
78
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
79
|
-
transition-timing-function: var(--local-animation-function);
|
|
80
|
-
}
|
|
81
|
-
.RNBObutton {
|
|
82
|
-
width: 3rem;
|
|
83
|
-
border-style: none;
|
|
84
|
-
background-color: transparent;
|
|
85
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
86
|
-
transition-timing-function: var(--local-animation-function);
|
|
87
|
-
}
|
|
88
|
-
</style>
|
|
17
|
+
|
|
18
|
+
let volumeCallback = null;
|
|
19
|
+
/** @type {number|null} */
|
|
20
|
+
let averageVolume = $state(0);
|
|
21
|
+
|
|
22
|
+
/** @param {MediaStream} stream */
|
|
23
|
+
const handleSuccess = (stream) => {
|
|
24
|
+
const source = context.createMediaStreamSource(stream);
|
|
25
|
+
let analyser = context.createAnalyser();
|
|
26
|
+
analyser.fftSize = 512;
|
|
27
|
+
analyser.minDecibels = -127;
|
|
28
|
+
analyser.maxDecibels = 0;
|
|
29
|
+
analyser.smoothingTimeConstant = 0.4;
|
|
30
|
+
source.connect(analyser);
|
|
31
|
+
const volumes = new Uint8Array(analyser.frequencyBinCount);
|
|
32
|
+
//probe every 100ms for the average volume
|
|
33
|
+
volumeCallback = setInterval(() => {
|
|
34
|
+
analyser.getByteFrequencyData(volumes);
|
|
35
|
+
let volumeSum = 0;
|
|
36
|
+
for (const volume of volumes) volumeSum += volume;
|
|
37
|
+
averageVolume = volumeSum / volumes.length;
|
|
38
|
+
// console.log(`brightness-[${averageVolume / 100}]`);
|
|
39
|
+
}, 100);
|
|
40
|
+
source.connect(analyser);
|
|
41
|
+
audio = analyser;
|
|
42
|
+
// analyser.connect(device.node, inlet.index - 1);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
async function connectMic() {
|
|
46
|
+
if (!stream) {
|
|
47
|
+
stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: false });
|
|
48
|
+
handleSuccess(stream);
|
|
49
|
+
} else {
|
|
50
|
+
disconnectMic();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function disconnectMic() {
|
|
54
|
+
if (!stream) return;
|
|
55
|
+
clearInterval(volumeCallback);
|
|
56
|
+
volumeCallback = null;
|
|
57
|
+
averageVolume = 0;
|
|
58
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
59
|
+
stream = null;
|
|
60
|
+
}
|
|
61
|
+
onDestroy(disconnectMic);
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div class="RNBOsubcomponent RNBOalign" {...rest}>
|
|
65
|
+
<button onclick={connectMic} type="button" class="RNBObutton">
|
|
66
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512" class:RNBOfill={stream}>
|
|
67
|
+
<path
|
|
68
|
+
d="M176 352c53.02 0 96-42.98 96-96V96c0-53.02-42.98-96-96-96S80 42.98 80 96v160c0 53.02 42.98 96 96 96zm160-160h-16c-8.84 0-16 7.16-16 16v48c0 74.8-64.49 134.82-140.79 127.38C96.71 376.89 48 317.11 48 250.3V208c0-8.84-7.16-16-16-16H16c-8.84 0-16 7.16-16 16v40.16c0 89.64 63.97 169.55 152 181.69V464H96c-8.84 0-16 7.16-16 16v16c0 8.84 7.16 16 16 16h160c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16h-56v-33.77C285.71 418.47 352 344.9 352 256v-48c0-8.84-7.16-16-16-16z"
|
|
69
|
+
/>
|
|
70
|
+
</svg>
|
|
71
|
+
</button>
|
|
72
|
+
<p>{averageVolume}</p>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<style>
|
|
76
|
+
.RNBOfill {
|
|
77
|
+
fill: rgb(var(--local-accent-color));
|
|
78
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
79
|
+
transition-timing-function: var(--local-animation-function);
|
|
80
|
+
}
|
|
81
|
+
.RNBObutton {
|
|
82
|
+
width: 3rem;
|
|
83
|
+
border-style: none;
|
|
84
|
+
background-color: transparent;
|
|
85
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
86
|
+
transition-timing-function: var(--local-animation-function);
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import RadioGroup from '../UIcomponents/RadioGroup.svelte';
|
|
3
|
-
import RadioItem from '../UIcomponents/RadioItem.svelte';
|
|
4
|
-
import AudioDropIn from './AudioDropIn.svelte';
|
|
5
|
-
import MicIn from './MicIn.svelte';
|
|
6
|
-
|
|
7
|
-
let context = device.context;
|
|
8
|
-
|
|
9
|
-
/** @typedef {object} inlet
|
|
10
|
-
* @property {number} index - the port index
|
|
11
|
-
* @property {string} tag - the tag
|
|
12
|
-
* @property {'signal'} type - the type
|
|
13
|
-
* @property {string} meta - the meta
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** @type {AudioNode} */
|
|
17
|
-
let audio = $state();
|
|
18
|
-
|
|
19
|
-
/** @type {{default: 'default', mic: 'mic', dropIn: 'dropIn'}} */
|
|
20
|
-
let modes = { default: 'default', mic: 'mic', dropIn: 'dropIn' };
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {Object} Props
|
|
24
|
-
* @property {import ('@rnbo/js').Device} device
|
|
25
|
-
* @property {inlet} [inlet]
|
|
26
|
-
* @property {'default'|'mic'|'dropIn'} [mode]
|
|
27
|
-
* @property {import('svelte').Snippet<[any]>} [children]
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** @type {Props & { [key: string]: any }} */
|
|
31
|
-
let {
|
|
32
|
-
device,
|
|
33
|
-
inlet = { index: 1, tag: 'in1', type: 'signal', meta: 'something' },
|
|
34
|
-
mode = $bindable(modes.default),
|
|
35
|
-
children,
|
|
36
|
-
...rest
|
|
37
|
-
} = $props();
|
|
38
|
-
//set a defaultMode so the radio group only shows if no mode has been specified
|
|
39
|
-
/** @type {'default'|'mic'|'dropIn'} */
|
|
40
|
-
let defaultMode = mode;
|
|
41
|
-
//make sure the default mode is mic in the radio group
|
|
42
|
-
if (mode == modes.default) mode = modes.mic;
|
|
43
|
-
|
|
44
|
-
$effect(() => {
|
|
45
|
-
if (audio) {
|
|
46
|
-
audio.connect(device.node, inlet.index - 1);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
52
|
-
{#if children}{@render children({ context, audio })}{:else}
|
|
53
|
-
<div class="RNBOtag">{inlet.tag}</div>
|
|
54
|
-
{#if defaultMode === modes.default}
|
|
55
|
-
<RadioGroup>
|
|
56
|
-
<RadioItem bind:group={mode} name="Mic" value={modes.mic}>Mic</RadioItem>
|
|
57
|
-
<RadioItem bind:group={mode} name="DropIn" value={modes.dropIn}>Drop-in</RadioItem>
|
|
58
|
-
</RadioGroup>
|
|
59
|
-
{/if}
|
|
60
|
-
{#if mode === modes.dropIn}
|
|
61
|
-
<AudioDropIn class="RNBOsubcomponent" bind:audio {context} />
|
|
62
|
-
{:else}
|
|
63
|
-
<MicIn bind:audio {context} />
|
|
64
|
-
{/if}
|
|
65
|
-
{/if}
|
|
66
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
import RadioGroup from '../UIcomponents/RadioGroup.svelte';
|
|
3
|
+
import RadioItem from '../UIcomponents/RadioItem.svelte';
|
|
4
|
+
import AudioDropIn from './AudioDropIn.svelte';
|
|
5
|
+
import MicIn from './MicIn.svelte';
|
|
6
|
+
|
|
7
|
+
let context = device.context;
|
|
8
|
+
|
|
9
|
+
/** @typedef {object} inlet
|
|
10
|
+
* @property {number} index - the port index
|
|
11
|
+
* @property {string} tag - the tag
|
|
12
|
+
* @property {'signal'} type - the type
|
|
13
|
+
* @property {string} meta - the meta
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** @type {AudioNode} */
|
|
17
|
+
let audio = $state();
|
|
18
|
+
|
|
19
|
+
/** @type {{default: 'default', mic: 'mic', dropIn: 'dropIn'}} */
|
|
20
|
+
let modes = { default: 'default', mic: 'mic', dropIn: 'dropIn' };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} Props
|
|
24
|
+
* @property {import ('@rnbo/js').Device} device
|
|
25
|
+
* @property {inlet} [inlet]
|
|
26
|
+
* @property {'default'|'mic'|'dropIn'} [mode]
|
|
27
|
+
* @property {import('svelte').Snippet<[any]>} [children]
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** @type {Props & { [key: string]: any }} */
|
|
31
|
+
let {
|
|
32
|
+
device,
|
|
33
|
+
inlet = { index: 1, tag: 'in1', type: 'signal', meta: 'something' },
|
|
34
|
+
mode = $bindable(modes.default),
|
|
35
|
+
children,
|
|
36
|
+
...rest
|
|
37
|
+
} = $props();
|
|
38
|
+
//set a defaultMode so the radio group only shows if no mode has been specified
|
|
39
|
+
/** @type {'default'|'mic'|'dropIn'} */
|
|
40
|
+
let defaultMode = mode;
|
|
41
|
+
//make sure the default mode is mic in the radio group
|
|
42
|
+
if (mode == modes.default) mode = modes.mic;
|
|
43
|
+
|
|
44
|
+
$effect(() => {
|
|
45
|
+
if (audio) {
|
|
46
|
+
audio.connect(device.node, inlet.index - 1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
52
|
+
{#if children}{@render children({ context, audio })}{:else}
|
|
53
|
+
<div class="RNBOtag">{inlet.tag}</div>
|
|
54
|
+
{#if defaultMode === modes.default}
|
|
55
|
+
<RadioGroup>
|
|
56
|
+
<RadioItem bind:group={mode} name="Mic" value={modes.mic}>Mic</RadioItem>
|
|
57
|
+
<RadioItem bind:group={mode} name="DropIn" value={modes.dropIn}>Drop-in</RadioItem>
|
|
58
|
+
</RadioGroup>
|
|
59
|
+
{/if}
|
|
60
|
+
{#if mode === modes.dropIn}
|
|
61
|
+
<AudioDropIn class="RNBOsubcomponent" bind:audio {context} />
|
|
62
|
+
{:else}
|
|
63
|
+
<MicIn bind:audio {context} />
|
|
64
|
+
{/if}
|
|
65
|
+
{/if}
|
|
66
|
+
</div>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Controls from '../UIcomponents/Controls.svelte';
|
|
3
|
-
import rnbo from '@rnbo/js';
|
|
4
|
-
const { TimeNow, MessageEvent } = rnbo;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} Props
|
|
8
|
-
* @property {string} tag
|
|
9
|
-
* @property {import ('@rnbo/js').Device} device
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/** @type {Props} */
|
|
13
|
-
let { tag, device } = $props();
|
|
14
|
-
|
|
15
|
-
const sendMessage = () => {
|
|
16
|
-
const messageEvent = new MessageEvent(TimeNow, tag);
|
|
17
|
-
device.scheduleEvent(messageEvent);
|
|
18
|
-
};
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<Controls {tag} {sendMessage} />
|
|
1
|
+
<script>
|
|
2
|
+
import Controls from '../UIcomponents/Controls.svelte';
|
|
3
|
+
import rnbo from '@rnbo/js';
|
|
4
|
+
const { TimeNow, MessageEvent } = rnbo;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} Props
|
|
8
|
+
* @property {string} tag
|
|
9
|
+
* @property {import ('@rnbo/js').Device} device
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** @type {Props} */
|
|
13
|
+
let { tag, device } = $props();
|
|
14
|
+
|
|
15
|
+
const sendMessage = () => {
|
|
16
|
+
const messageEvent = new MessageEvent(TimeNow, tag);
|
|
17
|
+
device.scheduleEvent(messageEvent);
|
|
18
|
+
};
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Controls {tag} {sendMessage} />
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import rnbo from '@rnbo/js';
|
|
3
|
-
const { MIDIEvent, TimeNow } = rnbo;
|
|
4
|
-
import XyMidiIn from './XYMidiIn.svelte';
|
|
5
|
-
import ExtMidiIn from './ExtMidiIn.svelte';
|
|
6
|
-
import RadioGroup from '../UIcomponents/RadioGroup.svelte';
|
|
7
|
-
import RadioItem from '../UIcomponents/RadioItem.svelte';
|
|
8
|
-
|
|
9
|
-
/** @type {{default: 'default', xy: 'xy', external: 'external'}} */
|
|
10
|
-
let modes = { default: 'default', xy: 'xy', external: 'external' };
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {Object} Props
|
|
14
|
-
* @property {number} [port] - type {number} - the MIDI port index
|
|
15
|
-
* @property {import ('@rnbo/js').Device} device
|
|
16
|
-
* @property {import('@rnbo/js').MIDIData|undefined} [midiMessage]
|
|
17
|
-
* @property {number|undefined} [midiChannel]
|
|
18
|
-
* @property {'default'|'xy'|'external'} [mode]
|
|
19
|
-
* @property {import('svelte').Snippet<[any]>} [children]
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/** @type {Props & { [key: string]: any }} */
|
|
23
|
-
let {
|
|
24
|
-
port = 0,
|
|
25
|
-
device,
|
|
26
|
-
midiMessage = $bindable(undefined),
|
|
27
|
-
midiChannel = 0,
|
|
28
|
-
mode = $bindable(modes.default),
|
|
29
|
-
children,
|
|
30
|
-
...rest
|
|
31
|
-
} = $props();
|
|
32
|
-
|
|
33
|
-
//set a defaultMode so the radio group only shows if no mode has been specified
|
|
34
|
-
/** @type {'default'|'xy'|'external'} */
|
|
35
|
-
let defaultMode = mode;
|
|
36
|
-
//make sure the default mode is mic in the radio group
|
|
37
|
-
if (mode == modes.default) mode = modes.xy;
|
|
38
|
-
|
|
39
|
-
$effect(() => {
|
|
40
|
-
if (midiMessage && midiMessage.length > 0) {
|
|
41
|
-
console.log('from MidiIn', midiMessage);
|
|
42
|
-
device.scheduleEvent(new MIDIEvent(TimeNow, port, midiMessage));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
48
|
-
{#if children}{@render children({ midiChannel })}{:else}
|
|
49
|
-
<div class="RNBOtag">in {port}</div>
|
|
50
|
-
{#if defaultMode === modes.default}
|
|
51
|
-
<RadioGroup>
|
|
52
|
-
<RadioItem bind:group={mode} name="xy" value={modes.xy}>XY-pad</RadioItem>
|
|
53
|
-
<RadioItem bind:group={mode} name="external" value={modes.external}>ext. MIDI</RadioItem>
|
|
54
|
-
</RadioGroup>
|
|
55
|
-
{/if}
|
|
56
|
-
|
|
57
|
-
{#if mode === modes.external}
|
|
58
|
-
<ExtMidiIn bind:midiMessage {midiChannel} />
|
|
59
|
-
{:else}
|
|
60
|
-
<XyMidiIn bind:midiMessage {midiChannel} />
|
|
61
|
-
{/if}
|
|
62
|
-
{/if}
|
|
63
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
import rnbo from '@rnbo/js';
|
|
3
|
+
const { MIDIEvent, TimeNow } = rnbo;
|
|
4
|
+
import XyMidiIn from './XYMidiIn.svelte';
|
|
5
|
+
import ExtMidiIn from './ExtMidiIn.svelte';
|
|
6
|
+
import RadioGroup from '../UIcomponents/RadioGroup.svelte';
|
|
7
|
+
import RadioItem from '../UIcomponents/RadioItem.svelte';
|
|
8
|
+
|
|
9
|
+
/** @type {{default: 'default', xy: 'xy', external: 'external'}} */
|
|
10
|
+
let modes = { default: 'default', xy: 'xy', external: 'external' };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} Props
|
|
14
|
+
* @property {number} [port] - type {number} - the MIDI port index
|
|
15
|
+
* @property {import ('@rnbo/js').Device} device
|
|
16
|
+
* @property {import('@rnbo/js').MIDIData|undefined} [midiMessage]
|
|
17
|
+
* @property {number|undefined} [midiChannel]
|
|
18
|
+
* @property {'default'|'xy'|'external'} [mode]
|
|
19
|
+
* @property {import('svelte').Snippet<[any]>} [children]
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** @type {Props & { [key: string]: any }} */
|
|
23
|
+
let {
|
|
24
|
+
port = 0,
|
|
25
|
+
device,
|
|
26
|
+
midiMessage = $bindable(undefined),
|
|
27
|
+
midiChannel = 0,
|
|
28
|
+
mode = $bindable(modes.default),
|
|
29
|
+
children,
|
|
30
|
+
...rest
|
|
31
|
+
} = $props();
|
|
32
|
+
|
|
33
|
+
//set a defaultMode so the radio group only shows if no mode has been specified
|
|
34
|
+
/** @type {'default'|'xy'|'external'} */
|
|
35
|
+
let defaultMode = mode;
|
|
36
|
+
//make sure the default mode is mic in the radio group
|
|
37
|
+
if (mode == modes.default) mode = modes.xy;
|
|
38
|
+
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (midiMessage && midiMessage.length > 0) {
|
|
41
|
+
console.log('from MidiIn', midiMessage);
|
|
42
|
+
device.scheduleEvent(new MIDIEvent(TimeNow, port, midiMessage));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
48
|
+
{#if children}{@render children({ midiChannel })}{:else}
|
|
49
|
+
<div class="RNBOtag">in {port}</div>
|
|
50
|
+
{#if defaultMode === modes.default}
|
|
51
|
+
<RadioGroup>
|
|
52
|
+
<RadioItem bind:group={mode} name="xy" value={modes.xy}>XY-pad</RadioItem>
|
|
53
|
+
<RadioItem bind:group={mode} name="external" value={modes.external}>ext. MIDI</RadioItem>
|
|
54
|
+
</RadioGroup>
|
|
55
|
+
{/if}
|
|
56
|
+
|
|
57
|
+
{#if mode === modes.external}
|
|
58
|
+
<ExtMidiIn bind:midiMessage {midiChannel} />
|
|
59
|
+
{:else}
|
|
60
|
+
<XyMidiIn bind:midiMessage {midiChannel} />
|
|
61
|
+
{/if}
|
|
62
|
+
{/if}
|
|
63
|
+
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { MIDIEvent, TimeNow } from '@rnbo/js';
|
|
3
|
-
// import ExtMidiOut from './ExtMidiOut.svelte';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script>
|
|
2
|
+
import { MIDIEvent, TimeNow } from '@rnbo/js';
|
|
3
|
+
// import ExtMidiOut from './ExtMidiOut.svelte';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {Object} Props
|
|
9
9
|
* @property {number} [port] - type {number} - the MIDI port index
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
children,
|
|
21
21
|
...rest
|
|
22
22
|
} = $props();
|
|
23
|
-
// /** @type {number|undefined} */
|
|
24
|
-
// export let midiChannel = 0;
|
|
25
|
-
|
|
26
|
-
//TODO: replace block below with a midiMessage receive from a Max Midi out, send to extMidiOut
|
|
27
|
-
device.midiEvent.subscribe((ev) => {
|
|
28
|
-
console.log(ev);
|
|
29
|
-
});
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
33
|
-
{#if children}{@render children({ port, })}{:else}
|
|
34
|
-
<div class="RNBOtag">in {port}</div>
|
|
35
|
-
|
|
36
|
-
<!-- <ExtMidiOut bind:midiMessage /> -->
|
|
37
|
-
{/if}
|
|
38
|
-
</div>
|
|
23
|
+
// /** @type {number|undefined} */
|
|
24
|
+
// export let midiChannel = 0;
|
|
25
|
+
|
|
26
|
+
//TODO: replace block below with a midiMessage receive from a Max Midi out, send to extMidiOut
|
|
27
|
+
device.midiEvent.subscribe((ev) => {
|
|
28
|
+
console.log(ev);
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
33
|
+
{#if children}{@render children({ port, })}{:else}
|
|
34
|
+
<div class="RNBOtag">in {port}</div>
|
|
35
|
+
|
|
36
|
+
<!-- <ExtMidiOut bind:midiMessage /> -->
|
|
37
|
+
{/if}
|
|
38
|
+
</div>
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import ProgressBar from '../UIcomponents/ProgressBar.svelte';
|
|
3
|
-
|
|
4
|
-
/** @type {import ('@rnbo/js').MessagePayload } */
|
|
5
|
-
let value = $state(0);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} Props
|
|
9
|
-
* @property {import ('@rnbo/js').MessageInfo} outport
|
|
10
|
-
* @property {import ('@rnbo/js').Device} device
|
|
11
|
-
* @property {number} [min]
|
|
12
|
-
* @property {number} [max]
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** @type {Props & { [key: string]: any }} */
|
|
16
|
-
let { outport, device, min = 0, max = 1, ...rest } = $props();
|
|
17
|
-
|
|
18
|
-
$effect(() => {
|
|
19
|
-
device.messageEvent.subscribe((ev) => {
|
|
20
|
-
if (ev.tag == outport.tag) {
|
|
21
|
-
value = ev.payload;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
28
|
-
<div class="RNBOalign">
|
|
29
|
-
<div class="RNBOtag">{outport.tag}</div>
|
|
30
|
-
<!-- some hack to make the value max 2 decimal floats: -->
|
|
31
|
-
<div class="RNBOval">{+parseFloat(value).toFixed(2)}</div>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
<p class="RNBOtext">{outport.meta.slice(1, -1)}</p>
|
|
35
|
-
<ProgressBar value={Array.isArray(value) ? value[0] : value} {max} {min} />
|
|
36
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
import ProgressBar from '../UIcomponents/ProgressBar.svelte';
|
|
3
|
+
|
|
4
|
+
/** @type {import ('@rnbo/js').MessagePayload } */
|
|
5
|
+
let value = $state(0);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} Props
|
|
9
|
+
* @property {import ('@rnbo/js').MessageInfo} outport
|
|
10
|
+
* @property {import ('@rnbo/js').Device} device
|
|
11
|
+
* @property {number} [min]
|
|
12
|
+
* @property {number} [max]
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @type {Props & { [key: string]: any }} */
|
|
16
|
+
let { outport, device, min = 0, max = 1, ...rest } = $props();
|
|
17
|
+
|
|
18
|
+
$effect(() => {
|
|
19
|
+
device.messageEvent.subscribe((ev) => {
|
|
20
|
+
if (ev.tag == outport.tag) {
|
|
21
|
+
value = ev.payload;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
28
|
+
<div class="RNBOalign">
|
|
29
|
+
<div class="RNBOtag">{outport.tag}</div>
|
|
30
|
+
<!-- some hack to make the value max 2 decimal floats: -->
|
|
31
|
+
<div class="RNBOval">{+parseFloat(value).toFixed(2)}</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<p class="RNBOtext">{outport.meta.slice(1, -1)}</p>
|
|
35
|
+
<ProgressBar value={Array.isArray(value) ? value[0] : value} {max} {min} />
|
|
36
|
+
</div>
|