refactor sounds and use different sound for captcha
This commit is contained in:
parent
3afd3eeaae
commit
d76d6f652d
|
@ -16,25 +16,26 @@ export default (store) => (next) => (action) => {
|
|||
case 'SELECT_COLOR': {
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.detune.value = -600;
|
||||
|
||||
oscillatorNode.frequency.setValueAtTime(600, context.currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(700, context.currentTime + 0.1);
|
||||
oscillatorNode.frequency.setValueAtTime(600, currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(700, currentTime + 0.1);
|
||||
|
||||
|
||||
gainNode.gain.setValueAtTime(0.3, context.currentTime);
|
||||
gainNode.gain.setValueAtTime(0.3, currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(
|
||||
0.2,
|
||||
context.currentTime + 0.1,
|
||||
currentTime + 0.1,
|
||||
);
|
||||
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.2);
|
||||
oscillatorNode.stop(currentTime + 0.2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -45,85 +46,100 @@ export default (store) => (next) => (action) => {
|
|||
}
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.detune.value = -1200;
|
||||
|
||||
oscillatorNode.frequency.setValueAtTime(500, context.currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(600, context.currentTime + 0.1);
|
||||
oscillatorNode.frequency.setValueAtTime(500, currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(600, currentTime + 0.1);
|
||||
|
||||
gainNode.gain.setValueAtTime(0.3, context.currentTime);
|
||||
gainNode.gain.setValueAtTime(0.3, currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(
|
||||
0.2,
|
||||
context.currentTime + 0.1,
|
||||
currentTime + 0.1,
|
||||
);
|
||||
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.2);
|
||||
oscillatorNode.stop(currentTime + 0.2);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'PIXEL_WAIT': {
|
||||
/*
|
||||
* TODO refactor other sounds also like this one
|
||||
* i.e. gain sould ramp to 0, do oscillator first
|
||||
*/
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
oscillatorNode.type = 'sine';
|
||||
// oscillatorNode.detune.value = -600
|
||||
|
||||
oscillatorNode.frequency.setValueAtTime(1479.98, context.currentTime);
|
||||
oscillatorNode.start(currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(1479.98, currentTime);
|
||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||
493.88,
|
||||
context.currentTime + 0.01,
|
||||
currentTime + 0.01,
|
||||
);
|
||||
|
||||
|
||||
gainNode.gain.setValueAtTime(0.5, context.currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(
|
||||
0.2,
|
||||
context.currentTime + 0.1,
|
||||
);
|
||||
|
||||
oscillatorNode.stop(currentTime + 0.1);
|
||||
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||
gainNode.gain.setTargetAtTime(0, currentTime, 0.1);
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.1);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'ALERT': {
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
if (action.alertType === 'captcha') {
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.detune.value = -600;
|
||||
oscillatorNode.start(currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(1479.98, currentTime);
|
||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||
493.88,
|
||||
currentTime + 0.01,
|
||||
);
|
||||
oscillatorNode.stop(currentTime + 0.1);
|
||||
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||
gainNode.gain.setTargetAtTime(0, currentTime, 0.1);
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
} else {
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.detune.value = -900;
|
||||
oscillatorNode.frequency.setValueAtTime(600, context.currentTime);
|
||||
oscillatorNode.start(currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(600, currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(
|
||||
1400,
|
||||
context.currentTime + 0.025,
|
||||
currentTime + 0.025,
|
||||
);
|
||||
oscillatorNode.frequency.setValueAtTime(
|
||||
1200,
|
||||
context.currentTime + 0.05,
|
||||
currentTime + 0.05,
|
||||
);
|
||||
oscillatorNode.frequency.setValueAtTime(
|
||||
900,
|
||||
context.currentTime + 0.075,
|
||||
currentTime + 0.075,
|
||||
);
|
||||
|
||||
oscillatorNode.stop(currentTime + 0.3);
|
||||
const lfo = context.createOscillator();
|
||||
lfo.type = 'sine';
|
||||
lfo.frequency.value = 2.0;
|
||||
lfo.connect(gainNode.gain);
|
||||
lfo.start(currentTime);
|
||||
lfo.frequency.setValueAtTime(2.0, currentTime);
|
||||
lfo.stop(currentTime + 0.3);
|
||||
lfo.connect(gainNode);
|
||||
gainNode.gain.setValueAtTime(1.0, currentTime);
|
||||
gainNode.gain.setTargetAtTime(0, currentTime, 3);
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
lfo.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -134,25 +150,26 @@ export default (store) => (next) => (action) => {
|
|||
const clrFreq = 100 + Math.log(color / colorsAmount + 1) * 300;
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.frequency.setValueAtTime(clrFreq, context.currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(clrFreq, currentTime);
|
||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||
1400,
|
||||
context.currentTime + 0.2,
|
||||
currentTime + 0.2,
|
||||
);
|
||||
|
||||
gainNode.gain.setValueAtTime(0.5, context.currentTime);
|
||||
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(
|
||||
0.2,
|
||||
context.currentTime + 0.1,
|
||||
currentTime + 0.1,
|
||||
);
|
||||
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.1);
|
||||
oscillatorNode.stop(currentTime + 0.1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -165,29 +182,30 @@ export default (store) => (next) => (action) => {
|
|||
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.frequency.setValueAtTime(349.23, context.currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(349.23, currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(
|
||||
523.25,
|
||||
context.currentTime + 0.1,
|
||||
currentTime + 0.1,
|
||||
);
|
||||
oscillatorNode.frequency.setValueAtTime(
|
||||
698.46,
|
||||
context.currentTime + 0.2,
|
||||
currentTime + 0.2,
|
||||
);
|
||||
|
||||
gainNode.gain.setValueAtTime(0.5, context.currentTime);
|
||||
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(
|
||||
0.2,
|
||||
context.currentTime + 0.15,
|
||||
currentTime + 0.15,
|
||||
);
|
||||
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.3);
|
||||
oscillatorNode.stop(currentTime + 0.3);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -196,15 +214,17 @@ export default (store) => (next) => (action) => {
|
|||
|
||||
const { isPing, channel } = action;
|
||||
const { mute: muteCh, chatChannel } = state.chatRead;
|
||||
if (muteCh.includes(channel)) break;
|
||||
if (muteCh.includes(`${channel}`)) break;
|
||||
if (muteCh.includes(channel) || muteCh.includes(`${channel}`)) {
|
||||
break;
|
||||
}
|
||||
const { channels } = state.chat;
|
||||
|
||||
const oscillatorNode = context.createOscillator();
|
||||
const gainNode = context.createGain();
|
||||
const { currentTime } = context;
|
||||
|
||||
oscillatorNode.type = 'sine';
|
||||
oscillatorNode.frequency.setValueAtTime(310, context.currentTime);
|
||||
oscillatorNode.frequency.setValueAtTime(310, currentTime);
|
||||
/*
|
||||
* ping if user mention or
|
||||
* message in DM channel that is not currently open
|
||||
|
@ -219,20 +239,20 @@ export default (store) => (next) => (action) => {
|
|||
) ? 540 : 355;
|
||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||
freq,
|
||||
context.currentTime + 0.025,
|
||||
currentTime + 0.025,
|
||||
);
|
||||
|
||||
gainNode.gain.setValueAtTime(0.1, context.currentTime);
|
||||
gainNode.gain.setValueAtTime(0.1, currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(
|
||||
0.1,
|
||||
context.currentTime + 0.1,
|
||||
currentTime + 0.1,
|
||||
);
|
||||
|
||||
oscillatorNode.connect(gainNode);
|
||||
gainNode.connect(context.destination);
|
||||
|
||||
oscillatorNode.start();
|
||||
oscillatorNode.stop(context.currentTime + 0.075);
|
||||
oscillatorNode.stop(currentTime + 0.075);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user