mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
feat: 立体声音效
This commit is contained in:
parent
d580405037
commit
cb761aede0
@ -3398,7 +3398,9 @@ control.prototype.getPlayingSounds = function (name) {
|
||||
////// 检查bgm状态 //////
|
||||
control.prototype.checkBgm = function () {
|
||||
const bgm = Mota.require('var', 'bgm');
|
||||
if (!bgm.playing) {
|
||||
if (bgm.disable) {
|
||||
bgm.pause();
|
||||
} else if (!bgm.playing) {
|
||||
bgm.changeTo(bgm.now ?? main.startBgm);
|
||||
}
|
||||
};
|
||||
|
@ -51,6 +51,7 @@ export class SoundEffect extends AudioPlayer {
|
||||
});
|
||||
|
||||
this._stereo = stereo;
|
||||
this.initAudio(stereo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,6 +71,8 @@ export class SoundEffect extends AudioPlayer {
|
||||
this.panner = null;
|
||||
this.merger = null;
|
||||
if (stereo) {
|
||||
console.log(1);
|
||||
|
||||
this.panner = ac.createPanner();
|
||||
this.panner.connect(this.gain);
|
||||
if (channel === 1) {
|
||||
@ -131,6 +134,7 @@ export class SoundEffect extends AudioPlayer {
|
||||
*/
|
||||
setPanner(source: Partial<Panner>, listener: Partial<Listener>) {
|
||||
if (!this.panner) return;
|
||||
console.log(2);
|
||||
for (const [key, value] of Object.entries(source)) {
|
||||
this.panner[key as keyof Panner].value = value;
|
||||
}
|
||||
@ -149,12 +153,12 @@ export class SoundController extends ResourceController<
|
||||
|
||||
/**
|
||||
* 添加一个新的音频
|
||||
* @param uri 音频的uri
|
||||
* @param uri 音频的uri,由于音频也是一种资源,因此格式为`sounds.xxx`
|
||||
* @param data 音频的ArrayBuffer信息,会被解析为AudioBuffer
|
||||
*/
|
||||
add(uri: string, data: ArrayBuffer) {
|
||||
const stereo = resource.stereoSE.includes(uri);
|
||||
const se = new SoundEffect(data, stereo);
|
||||
const se = new SoundEffect(data, true);
|
||||
if (this.list[uri]) {
|
||||
console.warn(`Repeated sound effect: '${uri}'.`);
|
||||
}
|
||||
|
@ -457,8 +457,8 @@ loading.once('coreInit', () => {
|
||||
'screen.smoothView': !!storage.getValue('screen.smoothView', true),
|
||||
'screen.criticalGem': !!storage.getValue('screen.criticalGem', false),
|
||||
'action.fixed': !!storage.getValue('action.fixed', true),
|
||||
'audio.bgmEnabled': !!storage.getValue('sound.bgmEnabled', true),
|
||||
'audio.bgmVolume': storage.getValue('sound.bgmVolume', 80),
|
||||
'audio.bgmEnabled': !!storage.getValue('audio.bgmEnabled', true),
|
||||
'audio.bgmVolume': storage.getValue('audio.bgmVolume', 80),
|
||||
'utils.betterLoad': !!storage.getValue('utils.betterLoad', true),
|
||||
'utils.autoScale': !!storage.getValue('utils.autoScale', true),
|
||||
'fx.paraLight': !!storage.getValue('fx.paraLight', true),
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { has } from '@/plugin/utils';
|
||||
|
||||
export class GameStorage<T extends object = any> {
|
||||
static list: GameStorage<any>[] = [];
|
||||
|
||||
@ -40,7 +42,7 @@ export class GameStorage<T extends object = any> {
|
||||
getValue<K extends keyof T>(key: K, defaults: T[K]): T[K];
|
||||
getValue<T>(key: string, defaults?: T): T;
|
||||
getValue<K extends keyof T>(key: K, defaults?: T[K]) {
|
||||
if (this.data[key]) return this.data[key];
|
||||
if (has(this.data[key])) return this.data[key];
|
||||
else {
|
||||
if (defaults !== void 0) {
|
||||
this.data[key] = defaults;
|
||||
|
@ -210,6 +210,8 @@ gameKey
|
||||
function bgm() {
|
||||
core.triggerBgm();
|
||||
soundChecked.value = !soundChecked.value;
|
||||
mainSetting.setValue('audio.bgmEnabled', soundChecked.value);
|
||||
console.log(mainSetting.getValue('audio.bgmEnabled'));
|
||||
}
|
||||
|
||||
async function setFullscreen() {
|
||||
|
Loading…
Reference in New Issue
Block a user