Commit Graph

85 Commits

Author SHA1 Message Date
relrelb f6153ff7c1 chore: Appease clippy 2022-05-06 10:36:38 -07:00
Mike Welsh 755676c64e chore: Remove doc comments from extern blocks
Doc comments are ignored here and can generate warnings, so change
to regular comments.
2022-03-27 18:56:13 -07:00
Mike Welsh bb3ef68499 web: Handle gaps in MP3 SoundStreamBlock tags 2022-01-07 13:23:53 -08:00
Mike Welsh 04d84a3386 web: Implement WebAudioBackend::get_sound_position 2021-10-16 22:53:25 -07:00
Mike Welsh bca31b2c51 audio: Grab Sound.position from audio backend
* Change `AudioBackend::get_sound_position` to return `f64` to
   match `AudioBackend::get_sound_duration`.
 * Wire up `AudioBackend::get_sound_position` to `Sound.position`.
 * Remove unimplmeneted warning from `Sound.position`.
2021-10-16 22:53:25 -07:00
Chris Midgley c5ad8e76ee
audio: Fail to create invalid ADPCM decoder 2021-10-13 23:12:32 -07:00
Chris Midgley 2abea5aeba
web: don't panic if failing to create an audio buffer 2021-09-11 15:48:30 -07:00
David Wendt 116fb1f323 avm2: Impl `Sound.play`
This does not (yet) implement the third `SoundTransform` parameter on `play`.
2021-09-03 16:47:02 -06:00
David Wendt 3b6eea2a1d core: Report sound duration as `f64` and round down in AS1 2021-09-03 16:47:02 -06:00
David Wendt 89b411593f avm2: Impl `Sound.bytesTotal` 2021-09-03 16:47:02 -06:00
relrelb 0fd1c05fd5 chore: Use into() in more places 2021-06-22 11:49:41 -07:00
Mike Welsh 61e20024e9 chore: Appease clippy 2021-05-22 20:28:31 -07:00
Mike Welsh dca97afdd7 chore: Remove puremp3 feature
Wasn't being used, remove the puremp3 dependency.
2021-05-02 19:31:01 -07:00
relrelb 79bcee07f5 audio: Properly round sound duration
Previously it was always rounded down. Change it to the nearest
integer.
2021-04-17 09:11:50 -07:00
Mike Welsh 3099914374 chore: Appease clippy 2021-02-27 16:10:46 -08:00
Mike Welsh e5fb1f09e7 chore: Appease clippy
* #[derive(Collect)] should be before #[collect]
 * Replace redunant `&buf[..]` with `buf`
 * Changes most cases of UPPERCase to UpperCase
 * Allow upper_case_acronym on most SWF types, as they are from
   SWF spec/more annoying to change.
2021-02-12 06:32:42 -08:00
relrelb 074731e1a4 audio: Add Nellymoser support 2021-02-02 00:41:01 -08:00
Mike Welsh 07ab770d4c web: Fix panning of mono sounds (fix #3017) 2021-02-01 13:18:24 -08:00
Toad06 b62ca3d589
web: Move `allowScriptAccess` to `BaseLoadOptions` 2021-01-30 16:59:58 -08:00
Mike Welsh 008f0f596c core: Clip event slices are from parent movie in PlaceObject
Since 19034b7, clip event scripts are returned as slices from the
SWF. This caused a panic when a movie was loaded into a clip,
because the loaded clip's `movie` would be used as the source for
clip events. However, clip events are placed by the parent's
PlaceObject tags, so the movie in this case should be the parent's
movie.

Fixes #2870.
2021-01-28 16:36:42 -08:00
Mads Marquart bb4240ad1f chore: Add a few comments about unsafe usage 2021-01-28 14:39:35 -08:00
Mike Welsh a4699a3ca5 audio: Sound transforms apply to stream sounds
This unifies the code path for event sounds and stream sounds.
Both `AudioBackend::start_stream` and `start_sound` return a
`SoundHandle`. `stop_stream` is removed (`stop_sound` can be
used for both cases).

Also removes references to `CharacterId` from the `AudioBackend`
(instead, an increasing ID is returned to identiy streams while
loading).
2021-01-27 15:25:04 -08:00
Mike Welsh 95ce2abf17 audio: Remove AudioBackend::stop_sounds_with_handle/is_sound_playing_with_handle 2021-01-27 15:25:04 -08:00
Mike Welsh da2dd3b36c core: Implement sound transforms and Sound.setPan 2021-01-27 15:25:04 -08:00
Mike Welsh 34f60b127a core: Add AudioManager to handle actively playing sounds
Add an AudioManager struct to handle this list of actively playing
sounds. This will maintain information for each sound instance,
such as the owning display object, AVM1 object, etc.

This will allow us to implement the awkward AVM1 Sound API in a
fairly backend-agnostic way.
2021-01-27 15:25:04 -08:00
Mike Welsh e655cf0c08 web: Add Ruffle::audio_context getter 2020-11-24 16:36:33 -08:00
Nathan Adams 5b5091b4b9 web: Rename copy_to_audio_buffer to copyToAudioBuffer 2020-11-24 16:36:33 -08:00
Nathan Adams 8abb8df299 web: core no longer uses webpack, but selfhosted still does 2020-11-24 16:36:33 -08:00
Nathan Adams 5ff7168fe9 web: Switched core package from javascript to typescript 2020-11-24 16:36:33 -08:00
Nathan Adams d7b94316c6 web: Always set the end point of audio clips - fixes #1304 2020-11-03 15:15:34 -08:00
Mike Welsh ef4d75e7d9 web: Fix incorrect handle used in audio ended handler (fix #1405) 2020-10-27 19:54:46 -07:00
Mike Welsh 956f40a26f web: Use a Drop impl to ensure sounds are stopped 2020-10-25 20:41:20 -07:00
Mike Welsh 796805c31b web: Avoid bug in generational-arena (fix #1315)
An issue with Arena::clear allowed stale sound instance indices
to be remain valid, causing certain sounds to be removed when they
shouldn't (#1315). Workaround this issue by forcing Arena to bump
the generational index.
2020-10-25 20:41:20 -07:00
Mike Welsh 827a80c837 web: Remove sound instances upon completion
Sounds were not being removed from the instance list when they
completed playing. This could also cause StartSound tags with
NoMultiple set to not play, because the previous sound was presumed
to be playing.

Fixes part of #1245.
2020-10-12 15:28:31 -07:00
Sean-Thomas a9538f81d0 web: Renamed "prime_audio" and "suspend_audio"
Renamed "prime_audio" and "suspend_audio" to "play" and "pause" respectfully.
2020-09-29 11:05:23 -07:00
Sean-Thomas 6b54cc4311 web: Add pause method for web player
Adds a suspend_audio method to compliment prime_audio on WebAudioBackend, as well as logic in player.rs on the set_is_playing method to suspend audio when is_playing is set to false. Exposes pause method for the ruffle player in JavaScript with logic to display the play button when paused.
2020-09-29 11:05:23 -07:00
Mike Welsh 8e97fdfe0c web: Fix WebAudioBackend::stop_sounds_with_handle (fix #752)
This would incorrectly stop all audio nodes whenever a Stop sound
event was encountered.
2020-06-25 23:04:47 -07:00
Mike Welsh 33cbc1fe2f web: Avoid panics on unimplemented audio codecs 2020-06-17 12:14:08 -07:00
Mike Welsh 83feeefeeb audio: Don't panic on unimplemented codecs
Remove `unimplemented` calls when encountring unsupported codecs
such as Nellymoser. Instead, return an Error that can be
gracefully handled.
2020-06-17 12:14:08 -07:00
Mike Welsh 3a8c705e95 chore: Fix clippy lints 2020-05-30 03:47:12 -07:00
Nathan Adams b8e63045b2 web: Moved source of core into core/src, to prep for tests 2020-05-19 11:42:54 +02:00
Nathan Adams b6523324ed web: Move each web package into a packages/ directory 2020-05-19 11:42:53 +02:00
Mike Welsh 87bf0f44c4 render: Move canvas renderer to separate subcrate 2020-04-29 23:26:41 -07:00
Mike Welsh 0921f18417 web: Avoid out-of-bounds slice from zero sample SoundStreamBlock 2020-04-27 07:49:59 -07:00
David Wendt 2137b9f1fd Migrate `set_frame_rate` into the core `AudioBackend` trait 2020-02-21 23:44:05 -05:00
Mike Welsh 087f15f28c web: Clear audio decoding buffer before each decode (fix #357) 2020-01-29 12:29:54 -08:00
Mike Welsh f983af3f65 web: Fix decoding of PCM sounds 2020-01-15 21:12:45 -08:00
Mike Welsh ad719ad586 web: Fix timing of sound envelopes
The endTime parameter of AudioParam.linearRampToValueAtTime is
on the global AudioContext's timeline, not local to the sound.
Adding the sound's start time to the parameter fixes sound
envelopes not playing back correctly.
2020-01-15 20:38:43 -08:00
Mike Welsh 12ee4c7432 web: Duplicate left channel when playing a mono sound with envelope (fix #323) 2020-01-15 20:36:05 -08:00
Mike Welsh f576a39760 web: Fix must_use warning on AudioContext::decode_audio_data
web-sys 0.3.34 added `must_use` to `Promise`. Add `let _ =` to
squlech this warning.
2020-01-06 13:01:39 -08:00