feat: added lookAhead option
This commit is contained in:
@@ -719,4 +719,26 @@ export class KGAudioInterface {
|
||||
console.log('Audio context sample rate:', Tone.getContext().sampleRate);
|
||||
console.log('Audio context state:', Tone.getContext().state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audio lookahead time
|
||||
* Lower values reduce MIDI input latency but may cause audio glitches
|
||||
* @param seconds Lookahead time in seconds (e.g., 0.01 for 10ms, 0.1 for 100ms)
|
||||
*/
|
||||
public setLookaheadTime(seconds: number): void {
|
||||
try {
|
||||
Tone.getContext().lookAhead = seconds;
|
||||
console.log(`Audio lookahead time set to: ${seconds}s (${seconds * 1000}ms)`);
|
||||
} catch (error) {
|
||||
console.error('Error setting lookahead time:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current audio lookahead time
|
||||
* @returns Lookahead time in seconds
|
||||
*/
|
||||
public getLookaheadTime(): number {
|
||||
return Tone.getContext().lookAhead;
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,7 @@ interface AppConfig {
|
||||
};
|
||||
audio: {
|
||||
enable_audio_capture_for_screen_sharing: boolean;
|
||||
lookahead_time: number;
|
||||
};
|
||||
templates: {
|
||||
custom_instructions: string;
|
||||
@@ -227,7 +228,8 @@ export class ConfigManager {
|
||||
default_open: true
|
||||
},
|
||||
audio: {
|
||||
enable_audio_capture_for_screen_sharing: false
|
||||
enable_audio_capture_for_screen_sharing: false,
|
||||
lookahead_time: 0.05
|
||||
},
|
||||
templates: {
|
||||
custom_instructions: ''
|
||||
|
||||
Reference in New Issue
Block a user