mirror of
https://github.com/elder-plinius/binaural-beats-generator.git
synced 2026-02-12 16:52:50 +00:00
18 lines
489 B
JavaScript
18 lines
489 B
JavaScript
let context = new AudioContext();
|
|
let oscillator = context.createOscillator();
|
|
let gainNode = context.createGain();
|
|
|
|
oscillator.connect(gainNode);
|
|
gainNode.connect(context.destination);
|
|
|
|
chrome.storage.sync.get('frequency', (data) => {
|
|
oscillator.frequency.value = data.frequency;
|
|
});
|
|
|
|
oscillator.start();
|
|
|
|
chrome.storage.onChanged.addListener((changes, areaName) => {
|
|
if (areaName === 'sync' && changes.frequency) {
|
|
oscillator.frequency.value = changes.frequency.newValue;
|
|
}
|
|
}); |