mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 21:18:49 +00:00
merged with vanilla updates
This commit is contained in:
parent
3152bc123a
commit
69554c0762
@ -8,6 +8,7 @@ import { code2hash, getDrawContext, logger, silence } from '@strudel.cycles/core
|
|||||||
import cx from '@src/cx.mjs';
|
import cx from '@src/cx.mjs';
|
||||||
import { transpiler } from '@strudel.cycles/transpiler';
|
import { transpiler } from '@strudel.cycles/transpiler';
|
||||||
import { getAudioContext, initAudioOnFirstClick, webaudioOutput } from '@strudel.cycles/webaudio';
|
import { getAudioContext, initAudioOnFirstClick, webaudioOutput } from '@strudel.cycles/webaudio';
|
||||||
|
import { defaultAudioDeviceName, getAudioDevices, setAudioDevice } from './panel/AudioDeviceSelector';
|
||||||
import { StrudelMirror, defaultSettings } from '@strudel/codemirror';
|
import { StrudelMirror, defaultSettings } from '@strudel/codemirror';
|
||||||
import { createContext, useCallback, useEffect, useRef, useState } from 'react';
|
import { createContext, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
@ -44,7 +45,6 @@ if (typeof window !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Repl({ embedded = false }) {
|
export function Repl({ embedded = false }) {
|
||||||
|
|
||||||
const isEmbedded = embedded || isIframe;
|
const isEmbedded = embedded || isIframe;
|
||||||
const { panelPosition, isZen } = useSettings();
|
const { panelPosition, isZen } = useSettings();
|
||||||
|
|
||||||
@ -59,7 +59,6 @@ export function Repl({ embedded = false }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
const editor = new StrudelMirror({
|
const editor = new StrudelMirror({
|
||||||
|
|
||||||
defaultOutput: webaudioOutput,
|
defaultOutput: webaudioOutput,
|
||||||
getTime: () => getAudioContext().currentTime,
|
getTime: () => getAudioContext().currentTime,
|
||||||
transpiler,
|
transpiler,
|
||||||
@ -122,6 +121,20 @@ export function Repl({ embedded = false }) {
|
|||||||
editorRef.current?.updateSettings(editorSettings);
|
editorRef.current?.updateSettings(editorSettings);
|
||||||
}, [_settings]);
|
}, [_settings]);
|
||||||
|
|
||||||
|
// on first load, set stored audio device if possible
|
||||||
|
useEffect(() => {
|
||||||
|
const { audioDeviceName } = _settings;
|
||||||
|
if (audioDeviceName !== defaultAudioDeviceName) {
|
||||||
|
getAudioDevices().then((devices) => {
|
||||||
|
const deviceID = devices.get(audioDeviceName);
|
||||||
|
if (deviceID == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setAudioDevice(deviceID);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
//
|
//
|
||||||
// UI Actions
|
// UI Actions
|
||||||
//
|
//
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { getAudioContext, initializeAudioOutput } from '@strudel.cycles/webaudio';
|
import { getAudioContext, initializeAudioOutput } from '@strudel.cycles/webaudio';
|
||||||
import { SelectInput } from './SelectInput';
|
import { SelectInput } from './SelectInput';
|
||||||
|
import { logger } from '@strudel.cycles/core';
|
||||||
|
|
||||||
const initdevices = new Map();
|
const initdevices = new Map();
|
||||||
export const defaultAudioDeviceName = 'System Standard';
|
export const defaultAudioDeviceName = 'System Standard';
|
||||||
@ -22,7 +23,11 @@ export const setAudioDevice = async (id) => {
|
|||||||
// reset the audio context and dont set the sink id if it is invalid AKA System Standard selection
|
// reset the audio context and dont set the sink id if it is invalid AKA System Standard selection
|
||||||
const audioCtx = getAudioContext(!isValidID);
|
const audioCtx = getAudioContext(!isValidID);
|
||||||
if (isValidID) {
|
if (isValidID) {
|
||||||
await audioCtx.setSinkId(id);
|
try {
|
||||||
|
await audioCtx.setSinkId(id);
|
||||||
|
} catch {
|
||||||
|
logger('failed to set audio interface', 'warning');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
initializeAudioOutput();
|
initializeAudioOutput();
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user