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': {
|
case 'SELECT_COLOR': {
|
||||||
const oscillatorNode = context.createOscillator();
|
const oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
oscillatorNode.type = 'sine';
|
||||||
oscillatorNode.detune.value = -600;
|
oscillatorNode.detune.value = -600;
|
||||||
|
|
||||||
oscillatorNode.frequency.setValueAtTime(600, context.currentTime);
|
oscillatorNode.frequency.setValueAtTime(600, currentTime);
|
||||||
oscillatorNode.frequency.setValueAtTime(700, context.currentTime + 0.1);
|
oscillatorNode.frequency.setValueAtTime(700, currentTime + 0.1);
|
||||||
|
|
||||||
|
|
||||||
gainNode.gain.setValueAtTime(0.3, context.currentTime);
|
gainNode.gain.setValueAtTime(0.3, currentTime);
|
||||||
gainNode.gain.exponentialRampToValueAtTime(
|
gainNode.gain.exponentialRampToValueAtTime(
|
||||||
0.2,
|
0.2,
|
||||||
context.currentTime + 0.1,
|
currentTime + 0.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
oscillatorNode.connect(gainNode);
|
oscillatorNode.connect(gainNode);
|
||||||
gainNode.connect(context.destination);
|
gainNode.connect(context.destination);
|
||||||
|
|
||||||
oscillatorNode.start();
|
oscillatorNode.start();
|
||||||
oscillatorNode.stop(context.currentTime + 0.2);
|
oscillatorNode.stop(currentTime + 0.2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,85 +46,100 @@ export default (store) => (next) => (action) => {
|
||||||
}
|
}
|
||||||
const oscillatorNode = context.createOscillator();
|
const oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
oscillatorNode.type = 'sine';
|
||||||
oscillatorNode.detune.value = -1200;
|
oscillatorNode.detune.value = -1200;
|
||||||
|
|
||||||
oscillatorNode.frequency.setValueAtTime(500, context.currentTime);
|
oscillatorNode.frequency.setValueAtTime(500, currentTime);
|
||||||
oscillatorNode.frequency.setValueAtTime(600, context.currentTime + 0.1);
|
oscillatorNode.frequency.setValueAtTime(600, currentTime + 0.1);
|
||||||
|
|
||||||
gainNode.gain.setValueAtTime(0.3, context.currentTime);
|
gainNode.gain.setValueAtTime(0.3, currentTime);
|
||||||
gainNode.gain.exponentialRampToValueAtTime(
|
gainNode.gain.exponentialRampToValueAtTime(
|
||||||
0.2,
|
0.2,
|
||||||
context.currentTime + 0.1,
|
currentTime + 0.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
oscillatorNode.connect(gainNode);
|
oscillatorNode.connect(gainNode);
|
||||||
gainNode.connect(context.destination);
|
gainNode.connect(context.destination);
|
||||||
|
|
||||||
oscillatorNode.start();
|
oscillatorNode.start();
|
||||||
oscillatorNode.stop(context.currentTime + 0.2);
|
oscillatorNode.stop(currentTime + 0.2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'PIXEL_WAIT': {
|
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 oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
oscillatorNode.type = 'sine';
|
||||||
// oscillatorNode.detune.value = -600
|
oscillatorNode.start(currentTime);
|
||||||
|
oscillatorNode.frequency.setValueAtTime(1479.98, currentTime);
|
||||||
oscillatorNode.frequency.setValueAtTime(1479.98, context.currentTime);
|
|
||||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||||
493.88,
|
493.88,
|
||||||
context.currentTime + 0.01,
|
currentTime + 0.01,
|
||||||
);
|
);
|
||||||
|
oscillatorNode.stop(currentTime + 0.1);
|
||||||
|
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||||
gainNode.gain.setValueAtTime(0.5, context.currentTime);
|
gainNode.gain.setTargetAtTime(0, currentTime, 0.1);
|
||||||
gainNode.gain.exponentialRampToValueAtTime(
|
|
||||||
0.2,
|
|
||||||
context.currentTime + 0.1,
|
|
||||||
);
|
|
||||||
|
|
||||||
oscillatorNode.connect(gainNode);
|
oscillatorNode.connect(gainNode);
|
||||||
gainNode.connect(context.destination);
|
gainNode.connect(context.destination);
|
||||||
|
|
||||||
oscillatorNode.start();
|
|
||||||
oscillatorNode.stop(context.currentTime + 0.1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'ALERT': {
|
case 'ALERT': {
|
||||||
const oscillatorNode = context.createOscillator();
|
const oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
if (action.alertType === 'captcha') {
|
||||||
oscillatorNode.detune.value = -900;
|
oscillatorNode.type = 'sine';
|
||||||
oscillatorNode.frequency.setValueAtTime(600, context.currentTime);
|
oscillatorNode.detune.value = -600;
|
||||||
oscillatorNode.frequency.setValueAtTime(
|
oscillatorNode.start(currentTime);
|
||||||
1400,
|
oscillatorNode.frequency.setValueAtTime(1479.98, currentTime);
|
||||||
context.currentTime + 0.025,
|
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||||
);
|
493.88,
|
||||||
oscillatorNode.frequency.setValueAtTime(
|
currentTime + 0.01,
|
||||||
1200,
|
);
|
||||||
context.currentTime + 0.05,
|
oscillatorNode.stop(currentTime + 0.1);
|
||||||
);
|
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||||
oscillatorNode.frequency.setValueAtTime(
|
gainNode.gain.setTargetAtTime(0, currentTime, 0.1);
|
||||||
900,
|
oscillatorNode.connect(gainNode);
|
||||||
context.currentTime + 0.075,
|
gainNode.connect(context.destination);
|
||||||
);
|
} else {
|
||||||
|
oscillatorNode.type = 'sine';
|
||||||
const lfo = context.createOscillator();
|
oscillatorNode.detune.value = -900;
|
||||||
lfo.type = 'sine';
|
oscillatorNode.start(currentTime);
|
||||||
lfo.frequency.value = 2.0;
|
oscillatorNode.frequency.setValueAtTime(600, currentTime);
|
||||||
lfo.connect(gainNode.gain);
|
oscillatorNode.frequency.setValueAtTime(
|
||||||
oscillatorNode.connect(gainNode);
|
1400,
|
||||||
gainNode.connect(context.destination);
|
currentTime + 0.025,
|
||||||
|
);
|
||||||
oscillatorNode.start();
|
oscillatorNode.frequency.setValueAtTime(
|
||||||
lfo.start();
|
1200,
|
||||||
oscillatorNode.stop(context.currentTime + 0.3);
|
currentTime + 0.05,
|
||||||
|
);
|
||||||
|
oscillatorNode.frequency.setValueAtTime(
|
||||||
|
900,
|
||||||
|
currentTime + 0.075,
|
||||||
|
);
|
||||||
|
oscillatorNode.stop(currentTime + 0.3);
|
||||||
|
const lfo = context.createOscillator();
|
||||||
|
lfo.type = 'sine';
|
||||||
|
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);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,25 +150,26 @@ export default (store) => (next) => (action) => {
|
||||||
const clrFreq = 100 + Math.log(color / colorsAmount + 1) * 300;
|
const clrFreq = 100 + Math.log(color / colorsAmount + 1) * 300;
|
||||||
const oscillatorNode = context.createOscillator();
|
const oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
oscillatorNode.type = 'sine';
|
||||||
oscillatorNode.frequency.setValueAtTime(clrFreq, context.currentTime);
|
oscillatorNode.frequency.setValueAtTime(clrFreq, currentTime);
|
||||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||||
1400,
|
1400,
|
||||||
context.currentTime + 0.2,
|
currentTime + 0.2,
|
||||||
);
|
);
|
||||||
|
|
||||||
gainNode.gain.setValueAtTime(0.5, context.currentTime);
|
gainNode.gain.setValueAtTime(0.5, currentTime);
|
||||||
gainNode.gain.exponentialRampToValueAtTime(
|
gainNode.gain.exponentialRampToValueAtTime(
|
||||||
0.2,
|
0.2,
|
||||||
context.currentTime + 0.1,
|
currentTime + 0.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
oscillatorNode.connect(gainNode);
|
oscillatorNode.connect(gainNode);
|
||||||
gainNode.connect(context.destination);
|
gainNode.connect(context.destination);
|
||||||
|
|
||||||
oscillatorNode.start();
|
oscillatorNode.start();
|
||||||
oscillatorNode.stop(context.currentTime + 0.1);
|
oscillatorNode.stop(currentTime + 0.1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,29 +182,30 @@ export default (store) => (next) => (action) => {
|
||||||
|
|
||||||
const oscillatorNode = context.createOscillator();
|
const oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
oscillatorNode.type = 'sine';
|
||||||
oscillatorNode.frequency.setValueAtTime(349.23, context.currentTime);
|
oscillatorNode.frequency.setValueAtTime(349.23, currentTime);
|
||||||
oscillatorNode.frequency.setValueAtTime(
|
oscillatorNode.frequency.setValueAtTime(
|
||||||
523.25,
|
523.25,
|
||||||
context.currentTime + 0.1,
|
currentTime + 0.1,
|
||||||
);
|
);
|
||||||
oscillatorNode.frequency.setValueAtTime(
|
oscillatorNode.frequency.setValueAtTime(
|
||||||
698.46,
|
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(
|
gainNode.gain.exponentialRampToValueAtTime(
|
||||||
0.2,
|
0.2,
|
||||||
context.currentTime + 0.15,
|
currentTime + 0.15,
|
||||||
);
|
);
|
||||||
|
|
||||||
oscillatorNode.connect(gainNode);
|
oscillatorNode.connect(gainNode);
|
||||||
gainNode.connect(context.destination);
|
gainNode.connect(context.destination);
|
||||||
|
|
||||||
oscillatorNode.start();
|
oscillatorNode.start();
|
||||||
oscillatorNode.stop(context.currentTime + 0.3);
|
oscillatorNode.stop(currentTime + 0.3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,15 +214,17 @@ export default (store) => (next) => (action) => {
|
||||||
|
|
||||||
const { isPing, channel } = action;
|
const { isPing, channel } = action;
|
||||||
const { mute: muteCh, chatChannel } = state.chatRead;
|
const { mute: muteCh, chatChannel } = state.chatRead;
|
||||||
if (muteCh.includes(channel)) break;
|
if (muteCh.includes(channel) || muteCh.includes(`${channel}`)) {
|
||||||
if (muteCh.includes(`${channel}`)) break;
|
break;
|
||||||
|
}
|
||||||
const { channels } = state.chat;
|
const { channels } = state.chat;
|
||||||
|
|
||||||
const oscillatorNode = context.createOscillator();
|
const oscillatorNode = context.createOscillator();
|
||||||
const gainNode = context.createGain();
|
const gainNode = context.createGain();
|
||||||
|
const { currentTime } = context;
|
||||||
|
|
||||||
oscillatorNode.type = 'sine';
|
oscillatorNode.type = 'sine';
|
||||||
oscillatorNode.frequency.setValueAtTime(310, context.currentTime);
|
oscillatorNode.frequency.setValueAtTime(310, currentTime);
|
||||||
/*
|
/*
|
||||||
* ping if user mention or
|
* ping if user mention or
|
||||||
* message in DM channel that is not currently open
|
* message in DM channel that is not currently open
|
||||||
|
@ -219,20 +239,20 @@ export default (store) => (next) => (action) => {
|
||||||
) ? 540 : 355;
|
) ? 540 : 355;
|
||||||
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
oscillatorNode.frequency.exponentialRampToValueAtTime(
|
||||||
freq,
|
freq,
|
||||||
context.currentTime + 0.025,
|
currentTime + 0.025,
|
||||||
);
|
);
|
||||||
|
|
||||||
gainNode.gain.setValueAtTime(0.1, context.currentTime);
|
gainNode.gain.setValueAtTime(0.1, currentTime);
|
||||||
gainNode.gain.exponentialRampToValueAtTime(
|
gainNode.gain.exponentialRampToValueAtTime(
|
||||||
0.1,
|
0.1,
|
||||||
context.currentTime + 0.1,
|
currentTime + 0.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
oscillatorNode.connect(gainNode);
|
oscillatorNode.connect(gainNode);
|
||||||
gainNode.connect(context.destination);
|
gainNode.connect(context.destination);
|
||||||
|
|
||||||
oscillatorNode.start();
|
oscillatorNode.start();
|
||||||
oscillatorNode.stop(context.currentTime + 0.075);
|
oscillatorNode.stop(currentTime + 0.075);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user