valtech-components 4.0.421 → 4.0.422

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,7 +58,7 @@ import fixWebmDuration from 'fix-webm-duration';
58
58
  * Current version of valtech-components.
59
59
  * This is automatically updated during the publish process.
60
60
  */
61
- const VERSION = '4.0.421';
61
+ const VERSION = '4.0.422';
62
62
 
63
63
  // Control de estado de refresco (singleton a nivel de módulo)
64
64
  let isRefreshing = false;
@@ -63203,6 +63203,9 @@ class RetroAudioService {
63203
63203
  async startGameMusic() {
63204
63204
  await this.startMusic('game');
63205
63205
  }
63206
+ async startBubbleBlitzMusic() {
63207
+ await this.startMusic('bubble');
63208
+ }
63206
63209
  async startMusic(mode = 'game') {
63207
63210
  if (!this.canPlayMusic())
63208
63211
  return;
@@ -63217,17 +63220,19 @@ class RetroAudioService {
63217
63220
  this.fadeMasterTo(1, 0.24);
63218
63221
  this.activeMelody = mode;
63219
63222
  this.noteIndex = 0;
63220
- const melody = mode === 'menu' ? this.menuMelody() : this.gameMelody();
63221
- const intervalMs = mode === 'menu' ? 640 : 190;
63222
- const wave = mode === 'menu' ? 'triangle' : 'square';
63223
- const gain = mode === 'menu' ? 0.018 : 0.025;
63223
+ const melody = mode === 'menu' ? this.menuMelody() : mode === 'bubble' ? this.bubbleMelody() : this.gameMelody();
63224
+ const intervalMs = mode === 'menu' ? 640 : mode === 'bubble' ? 760 : 190;
63225
+ const wave = mode === 'game' ? 'square' : 'triangle';
63226
+ const gain = mode === 'menu' ? 0.018 : mode === 'bubble' ? 0.014 : 0.025;
63224
63227
  this.musicTimer = window.setInterval(() => {
63225
63228
  const step = this.noteIndex;
63226
63229
  const [freq, duration] = melody[this.noteIndex % melody.length];
63227
63230
  this.noteIndex += 1;
63228
- this.tone(freq, duration, wave, gain);
63231
+ void this.musicTone(freq, duration, wave, gain);
63229
63232
  if (mode === 'menu')
63230
63233
  this.savannaPulse(step);
63234
+ if (mode === 'bubble')
63235
+ this.bubbleAmbientPulse(step);
63231
63236
  }, intervalMs);
63232
63237
  }
63233
63238
  stopMusic() {
@@ -63695,6 +63700,33 @@ class RetroAudioService {
63695
63700
  [659.25, 0.18],
63696
63701
  ];
63697
63702
  }
63703
+ bubbleMelody() {
63704
+ return [
63705
+ [261.63, 0.72],
63706
+ [0, 0.18],
63707
+ [329.63, 0.66],
63708
+ [392, 0.78],
63709
+ [0, 0.24],
63710
+ [349.23, 0.64],
63711
+ [293.66, 0.72],
63712
+ [0, 0.28],
63713
+ [440, 0.84],
63714
+ [392, 0.7],
63715
+ [329.63, 0.78],
63716
+ [0, 0.32],
63717
+ ];
63718
+ }
63719
+ bubbleAmbientPulse(step) {
63720
+ if (step % 4 === 0) {
63721
+ window.setTimeout(() => void this.musicTone(130.81, 1.35, 'sine', 0.009), 24);
63722
+ }
63723
+ if (step % 6 === 2) {
63724
+ window.setTimeout(() => void this.musicTone(196, 0.95, 'triangle', 0.008), 120);
63725
+ }
63726
+ if (step % 8 === 5) {
63727
+ window.setTimeout(() => void this.musicTone(523.25, 0.42, 'sine', 0.006), 180);
63728
+ }
63729
+ }
63698
63730
  async sequence(notes, wave = 'square', gain = 0.055, intervalMs = 90) {
63699
63731
  if (!this.enabled())
63700
63732
  return;
@@ -63814,6 +63846,25 @@ class RetroAudioService {
63814
63846
  oscillator.start();
63815
63847
  oscillator.stop(ctx.currentTime + duration + 0.02);
63816
63848
  }
63849
+ async musicTone(freq, duration = 0.1, type = 'triangle', gainValue = 0.018) {
63850
+ if (!this.canPlayMusic())
63851
+ return;
63852
+ if (freq <= 0)
63853
+ return;
63854
+ const ctx = await this.wakeAudio();
63855
+ const oscillator = ctx.createOscillator();
63856
+ const gain = ctx.createGain();
63857
+ oscillator.type = type;
63858
+ oscillator.frequency.value = freq;
63859
+ gain.gain.setValueAtTime(0.0001, ctx.currentTime);
63860
+ gain.gain.exponentialRampToValueAtTime(gainValue * this.musicVolume(), ctx.currentTime + 0.08);
63861
+ gain.gain.setTargetAtTime(gainValue * this.musicVolume() * 0.74, ctx.currentTime + 0.12, 0.2);
63862
+ gain.gain.exponentialRampToValueAtTime(0.0001, ctx.currentTime + duration);
63863
+ oscillator.connect(gain);
63864
+ gain.connect(this.masterGain ?? ctx.destination);
63865
+ oscillator.start();
63866
+ oscillator.stop(ctx.currentTime + duration + 0.08);
63867
+ }
63817
63868
  async sweep(fromFreq, toFreq, duration = 0.16, type = 'triangle', gainValue = 0.03) {
63818
63869
  if (!this.canPlaySfx())
63819
63870
  return;
@@ -67767,7 +67818,7 @@ class BubbleBlitzGameComponent {
67767
67818
  this.selectedGroupKey.set('');
67768
67819
  this.animating.set(false);
67769
67820
  this.clearAnimationTimer();
67770
- void this.audio.startGameMusic().catch(() => undefined);
67821
+ void this.audio.startBubbleBlitzMusic().catch(() => undefined);
67771
67822
  this.startTimer();
67772
67823
  }
67773
67824
  resetToSetup() {