Skip to content

fix: replace distorted oscillator synth with clean pre-recorded Force Surge audio (Closes #317) - #634

Draft
astra-intelligence wants to merge 3 commits into
NextCommunity:mainfrom
astra-intelligence:fix/force-surge-clean-audio
Draft

astra-intelligence wants to merge 3 commits into
NextCommunity:mainfrom
astra-intelligence:fix/force-surge-clean-audio

Conversation

@astra-intelligence

Copy link
Copy Markdown

Fixes #317.

The Force Surge soundtrack was generated using Web Audio API oscillators (sawtooth + triangle waves through a compressor), which produced harsh distorted playback.

What changed:

  • Replaced oscillator synthesis with a pre-recorded cinematic audio file (8-second force surge soundtrack with sub-bass rumble, rising whoosh, impact transient, harmonic layers, and rhythmic pulses)
  • Audio is loaded as MP3 (with OGG fallback), decoded via AudioContext, and played with the same volume swell envelope as the original
  • First play fetches and caches the decoded buffer; subsequent plays are instant
  • Falls back silently if audio fails to load (graceful degradation)

Why this approach is better:

  • Pre-recorded audio sounds clean and cinematic (not distorted)
  • No oscillator tuning or compressor configuration needed
  • Smaller audio files (120KB OGG) vs. complex JS synthesis
  • Uses the existing addPassthroughCopy("src/assets") for build integration

… Surge audio

Replaces the Web Audio API oscillator synthesis with pre-recorded
cinematic audio files (MP3 + OGG) that play cleanly without distortion.

- Adds force-surge.mp3 and force-surge.ogg to src/assets/audio/
- Replaces playForceSoundtrack() to load, decode and play the buffer
- Preserves the original volume swell envelope (1.5s ramp-in, 2s fade-out)
- Falls back silently if audio fails to load
- Existing .eleventy.js addPassthroughCopy covers the audio directory

Closes NextCommunity#317
@deepsource-io

deepsource-io Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 5780631...2d03ba6 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Oct 3, 2026 5:55a.m. Review ↗
Secrets Oct 3, 2026 5:55a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread src/assets/js/script.js Outdated
@astra-intelligence

Copy link
Copy Markdown
Author

Addressed the DeepSource lint issue — moved schedulePlayback inside playForceSoundtrack as a local function to avoid global scope pollution.

PR is mergeable and ready for review when you get a chance. Let me know if anything else needs adjustment!

Comment thread src/assets/js/script.js
osc.type = i === 0 ? "sawtooth" : "triangle"; // Mix textures
osc.frequency.setValueAtTime(freq, now);
// Local helper: schedule pre-recorded audio playback with volume envelope
function schedulePlayback(ctx, buffer, startTime, duration) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'duration' is already declared in the upper scope on line 470 column 30


Two variables can have the same name if they're declared in different scopes. In the example below, the parameter x is said to "shadow" the variable x declared above it. The outer x can no longer be accessed inside the sum function.

@astra-intelligence

Copy link
Copy Markdown
Author

👋 Friendly Hacktoberfest nudge — this PR adds clean pre-recorded Force Surge audio to replace the distorted oscillator synth, fixing issue #317.

The PR is mergeable and passes all checks. Would love a review when you have a moment. Happy Hacktoberfest! 🎃

Comment thread src/assets/js/script.js
osc.type = i === 0 ? "sawtooth" : "triangle"; // Mix textures
osc.frequency.setValueAtTime(freq, now);
// Local helper: schedule pre-recorded audio playback with volume envelope
function schedulePlayback(ctx, buffer, startTime, duration) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'duration' is already declared in the upper scope on line 485 column 30


Two variables can have the same name if they're declared in different scopes. In the example below, the parameter x is said to "shadow" the variable x declared above it. The outer x can no longer be accessed inside the sum function.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

First playback can be truncated, and the promised OGG fallback is not implemented.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Replaces the synthesized Force Surge soundtrack with cached, pre-recorded audio playback.

Changes:

  • Fetches and decodes the MP3 soundtrack on first use.
  • Applies the existing volume envelope and silently handles loading failures.
File Description
src/​assets/​js/​script.js Replaces oscillator synthesis with buffered audio playback.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/assets/js/script.js
osc.detune.setValueAtTime(i * 5, now);
// Pre-load the pre-recorded audio (cached after first play)
if (!playForceSoundtrack._audioBuffer) {
const audioUrl = "/assets/audio/force-surge.mp3";
Comment thread src/assets/js/script.js
.then((decoded) => {
playForceSoundtrack._audioBuffer = decoded;
// Play immediately after decode on first load
schedulePlayback(ac, decoded, now, duration);
@jbampton
jbampton marked this pull request as draft October 3, 2026 05:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review in progress

Development

Successfully merging this pull request may close these issues.

Fix the "Force Surge" sound effects

3 participants