added an option to fix the "Zoom can't capture the sound" problem (it is IMPORTANT to choose "share sound" when share screen in Zoom).
This commit is contained in:
@@ -7,6 +7,7 @@ import * as Tone from 'tone';
|
||||
import { KGAudioBus } from './KGAudioBus';
|
||||
import type { InstrumentType } from '../track/KGMidiTrack';
|
||||
import { KGCore } from '../KGCore';
|
||||
import { ConfigManager } from '../config/ConfigManager';
|
||||
|
||||
/**
|
||||
* KGAudioInterface - Audio engine interface for the DAW
|
||||
@@ -32,6 +33,10 @@ export class KGAudioInterface {
|
||||
// Master volume control
|
||||
private masterGain: Tone.Gain | null = null;
|
||||
|
||||
// Audio capture for screen sharing
|
||||
private captureDestination: MediaStreamAudioDestinationNode | null = null;
|
||||
private captureStream: MediaStream | null = null;
|
||||
|
||||
// Private constructor to prevent direct instantiation
|
||||
private constructor() {
|
||||
console.log("KGAudioInterface initialized");
|
||||
@@ -66,6 +71,14 @@ export class KGAudioInterface {
|
||||
Tone.Transport.bpm.value = TIME_CONSTANTS.DEFAULT_BPM; // Default BPM
|
||||
Tone.Transport.timeSignature = [TIME_CONSTANTS.DEFAULT_TIME_SIGNATURE.numerator, TIME_CONSTANTS.DEFAULT_TIME_SIGNATURE.denominator]; // Default time signature
|
||||
|
||||
// Check config and setup audio capture if enabled
|
||||
const configManager = ConfigManager.instance();
|
||||
const enableCapture = configManager.get('audio.enable_audio_capture_for_screen_sharing') as boolean;
|
||||
|
||||
if (enableCapture) {
|
||||
this.setupAudioCapture();
|
||||
}
|
||||
|
||||
this.isInitialized = true;
|
||||
console.log("Audio engine initialized successfully");
|
||||
} catch (error) {
|
||||
@@ -115,6 +128,12 @@ export class KGAudioInterface {
|
||||
this.masterGain = null;
|
||||
}
|
||||
|
||||
// Clean up capture resources
|
||||
if (this.captureDestination) {
|
||||
this.captureDestination = null;
|
||||
this.captureStream = null;
|
||||
}
|
||||
|
||||
this.isInitialized = false;
|
||||
this.isAudioContextStarted = false;
|
||||
|
||||
@@ -602,8 +621,27 @@ export class KGAudioInterface {
|
||||
return Object.keys(FLUIDR3_INSTRUMENT_MAP) as InstrumentType[];
|
||||
}
|
||||
|
||||
public getCaptureStream(): MediaStream | null {
|
||||
return this.captureStream;
|
||||
}
|
||||
|
||||
// ===== PRIVATE UTILITY METHODS =====
|
||||
|
||||
/**
|
||||
* Setup audio capture for screen sharing
|
||||
*/
|
||||
private setupAudioCapture(): void {
|
||||
if (this.masterGain && !this.captureDestination) {
|
||||
this.captureDestination = Tone.getContext().createMediaStreamDestination();
|
||||
this.captureStream = this.captureDestination.stream;
|
||||
|
||||
// Connect master gain to both speakers AND capture destination
|
||||
this.masterGain.connect(this.captureDestination);
|
||||
|
||||
console.log('Audio capture enabled for screen sharing');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any tracks are currently soloed
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,9 @@ interface AppConfig {
|
||||
chatbox: {
|
||||
default_open: boolean;
|
||||
};
|
||||
audio: {
|
||||
enable_audio_capture_for_screen_sharing: boolean;
|
||||
};
|
||||
templates: {
|
||||
custom_instructions: string;
|
||||
};
|
||||
@@ -205,6 +208,9 @@ export class ConfigManager {
|
||||
chatbox: {
|
||||
default_open: true
|
||||
},
|
||||
audio: {
|
||||
enable_audio_capture_for_screen_sharing: false
|
||||
},
|
||||
templates: {
|
||||
custom_instructions: ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user