lively 0.14.1 → 0.15.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20a2334e950eae8e16b8e6e637e0b078dc78fa026d733161c619566f9491892d
4
- data.tar.gz: b775297b7d46989e7ef63ac4b4a297ee1cd3e617da8e8e07d2be1c8a2cc56644
3
+ metadata.gz: b53e8a7bba336aef8ef7170bdf1aac5870b036ad7e4069c92d2b391c7413664d
4
+ data.tar.gz: 2ca053c24f1f25540b53e44fec743b7445cb139abb8d8f4f44d302fefb0a5bfb
5
5
  SHA512:
6
- metadata.gz: 6a38ccd950afea813d5e512bc15d8da87e78aa29d296c7aa61a294fcc25ac6dc052a9047e1212bf038b855fba7ab48de327ae6b54bdc9264fed9f9166303e31d
7
- data.tar.gz: 2636d7b62105ca052a114585ecf29ddbb443bc20281ef4c6128698625e56e7b46dac7502120bcf43c649fb7954af32ddbd64e8d37f1d60f63375f8d717f0c61b
6
+ metadata.gz: 8655863e04c5eb0d4d7a0306eed6d81a679f51d73304d4d81888f3ac0c56c99ffb20b6ed281ea4b35ed5557c89055f1098697bb6570f317c2d8561babebe5925
7
+ data.tar.gz: 0425a8509065b052bae71e87bd546b229a570555461845713ab663394a115884c6d8f7610966e3213ece45d9a6c74914be206b576adb13828574263e1663f8d2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Lively
8
- VERSION = "0.14.1"
8
+ VERSION = "0.15.0"
9
9
  end
@@ -723,26 +723,41 @@ export class SampleSound extends Sound {
723
723
 
724
724
  // Background Music class extending SampleSound with looping functionality
725
725
  export class BackgroundMusicSound extends SampleSound {
726
- constructor(url, loopStart = 0, loopEnd = 0) {
727
- super(url, 0.8); // Default volume for background music
728
- this.loopStart = loopStart;
729
- this.loopEnd = loopEnd;
726
+ constructor(url, options = {}) {
727
+ const { volume = 0.8, loop = true, loopStart, loopEnd } = options;
728
+ super(url, volume);
729
+
730
+ // Store loop configuration
731
+ this.options = {
732
+ loop,
733
+ loopStart,
734
+ loopEnd
735
+ };
730
736
  }
731
737
 
732
738
  // Override to configure looping with specific loop points
733
739
  configurePlayback(source) {
734
- source.loop = true;
735
- source.loopStart = this.loopStart;
736
- source.loopEnd = this.loopEnd;
740
+ const { loop, loopStart, loopEnd } = this.options;
741
+
742
+ // Only set loop properties if they are explicitly provided:
743
+ if (loop !== undefined) {
744
+ source.loop = loop;
745
+ }
746
+
747
+ if (loopStart !== undefined) {
748
+ source.loopStart = loopStart;
749
+ }
750
+
751
+ if (loopEnd !== undefined) {
752
+ source.loopEnd = loopEnd;
753
+ }
737
754
  }
738
755
 
739
756
  async start(output) {
740
757
  if (this.isPlaying) {
741
- console.log('Background music is already playing');
742
758
  return;
743
759
  }
744
760
 
745
761
  await super.start(output);
746
- console.log('Background music started with loop points:', this.loopStart, 'to', this.loopEnd);
747
762
  }
748
763
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@socketry/live-audio",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "description": "Web Audio API-based game audio synthesis and background music library for Ruby Live applications.",
6
6
  "main": "Live/Audio.js",
7
7
  "files": [
@@ -7,7 +7,7 @@ A Web Audio API-based game audio synthesis and background music library for Ruby
7
7
  ## Features
8
8
 
9
9
  - **Synthesized Sound Effects**: Classic game sounds including jump, coin, power-up, death, explosion, laser, and animal sounds.
10
- - **Background Music**: MP3 playback with loop points and volume control.
10
+ - **Background Music**: Audio file playback with loop points and volume control.
11
11
  - **Audio Visualization**: Real-time waveform display with quality monitoring.
12
12
  - **Anti-Clipping Protection**: Built-in gain management to prevent audio distortion.
13
13
  - **Modular Architecture**: Clean separation between sound synthesis, output routing, and visualization.
@@ -33,7 +33,10 @@ window.liveAudio = Audio.start();
33
33
  // Add sounds using the controller
34
34
  const meow = new MeowSound();
35
35
  const explosion = new ExplosionSound();
36
- const music = new BackgroundMusicSound('/assets/music.mp3', 10.0, 45.0);
36
+ const music = new BackgroundMusicSound('/assets/music.mp3', {
37
+ loopStart: 10.0,
38
+ loopEnd: 45.0
39
+ });
37
40
 
38
41
  window.liveAudio.addSound('meow', meow);
39
42
  window.liveAudio.addSound('explosion', explosion);
@@ -147,7 +150,12 @@ The library includes a comprehensive collection of pre-built sound classes in `L
147
150
  - `AlienSound` - Alien sound with ring modulation
148
151
 
149
152
  ### Background Music
150
- - `BackgroundMusicSound(url, loopStart, loopEnd)` - MP3 background music with required URL and loop points
153
+ - `BackgroundMusicSound(url, options)` - Audio file background music with optional loop configuration
154
+ - Supports common web audio formats: MP3, WAV, OGG, AAC, FLAC, and others supported by the browser
155
+ - `options.loop` - Enable/disable looping (default: true)
156
+ - `options.loopStart` - Loop start time in seconds
157
+ - `options.loopEnd` - Loop end time in seconds
158
+ - `options.volume` - Playback volume (default: 0.8)
151
159
 
152
160
  ### Usage Example
153
161
 
@@ -160,11 +168,30 @@ const controller = Audio.start();
160
168
  // Add sounds from the library
161
169
  const meow = new MeowSound();
162
170
  const explosion = new ExplosionSound();
163
- const music = new BackgroundMusicSound('/assets/background.mp3', 10.5, 45.2);
171
+
172
+ // Background music examples:
173
+ // Default: loops entire track at 80% volume
174
+ const music1 = new BackgroundMusicSound('/assets/background.mp3');
175
+
176
+ // Custom loop points
177
+ const music2 = new BackgroundMusicSound('/assets/background.mp3', {
178
+ loopStart: 10.5,
179
+ loopEnd: 45.2
180
+ });
181
+
182
+ // No looping
183
+ const music3 = new BackgroundMusicSound('/assets/background.mp3', { loop: false });
184
+
185
+ // Custom volume
186
+ const music4 = new BackgroundMusicSound('/assets/background.mp3', {
187
+ volume: 0.6,
188
+ loopStart: 5.0,
189
+ loopEnd: 30.0
190
+ });
164
191
 
165
192
  controller.addSound('meow', meow);
166
193
  controller.addSound('explosion', explosion);
167
- controller.addSound('music', music);
194
+ controller.addSound('music', music1);
168
195
 
169
196
  // Play them
170
197
  controller.playSound('meow');
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lively
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file