added missing Settings functionality, moved ntfy setting
This commit is contained in:
@@ -24,8 +24,12 @@ import { getRadioStream } from "_helpers/radioEffect";
|
||||
let interval: NodeJS.Timeout;
|
||||
|
||||
type TalkState = {
|
||||
micDeviceId: string | null;
|
||||
micVolume: number;
|
||||
settings: {
|
||||
micDeviceId: string | null;
|
||||
micVolume: number;
|
||||
radioVolume: number;
|
||||
dmeVolume: number;
|
||||
};
|
||||
isTalking: boolean;
|
||||
transmitBlocked: boolean;
|
||||
removeMessage: () => void;
|
||||
@@ -34,7 +38,7 @@ type TalkState = {
|
||||
connectionQuality: ConnectionQuality;
|
||||
remoteParticipants: number;
|
||||
toggleTalking: () => void;
|
||||
setMic: (micDeviceId: string | null, volume: number) => void;
|
||||
setSettings: (settings: Partial<TalkState["settings"]>) => void;
|
||||
connect: (roomName: string, role: string) => void;
|
||||
disconnect: () => void;
|
||||
speakingParticipants: Participant[];
|
||||
@@ -54,9 +58,14 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
localRadioTrack: undefined,
|
||||
transmitBlocked: false,
|
||||
message: null,
|
||||
micDeviceId: null,
|
||||
speakingParticipants: [],
|
||||
micVolume: 1,
|
||||
settings: {
|
||||
micDeviceId: null,
|
||||
micVolume: 1,
|
||||
radioVolume: 0.8,
|
||||
dmeVolume: 0.8,
|
||||
},
|
||||
state: "disconnected" as const,
|
||||
remoteParticipants: 0,
|
||||
connectionQuality: ConnectionQuality.Unknown,
|
||||
@@ -84,9 +93,19 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
set({ transmitBlocked: false, message: null, isTalking: true });
|
||||
}
|
||||
},
|
||||
setMic: (micDeviceId, micVolume) => {
|
||||
set({ micDeviceId, micVolume });
|
||||
if (get().state === "connected") {
|
||||
setSettings: (newSettings) => {
|
||||
const oldSettings = get().settings;
|
||||
set((s) => ({
|
||||
settings: {
|
||||
...s.settings,
|
||||
...newSettings,
|
||||
},
|
||||
}));
|
||||
if (
|
||||
get().state === "connected" &&
|
||||
(oldSettings.micDeviceId !== newSettings.micDeviceId ||
|
||||
oldSettings.micVolume !== newSettings.micVolume)
|
||||
) {
|
||||
const { room, disconnect, connect } = get();
|
||||
const role = room?.localParticipant.attributes.role;
|
||||
console.log(role);
|
||||
@@ -150,13 +169,13 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
|
||||
const inputStream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: {
|
||||
deviceId: get().micDeviceId ?? undefined,
|
||||
deviceId: get().settings.micDeviceId ?? undefined,
|
||||
noiseSuppression: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Funk-Effekt anwenden
|
||||
const radioStream = getRadioStream(inputStream, get().micVolume);
|
||||
const radioStream = getRadioStream(inputStream, get().settings.micVolume);
|
||||
if (!radioStream) throw new Error("Konnte Funkstream nicht erzeugen");
|
||||
|
||||
const [track] = radioStream.getAudioTracks();
|
||||
|
||||
Reference in New Issue
Block a user