Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes and improvements to the APU #716

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Commits on Apr 30, 2024

  1. Fix a bug where tones can cut out if the end of a tick comes in late

    This bug can be recreated by running
    `tone(345, 1, 50, 4)`
    as well as a big time-wasting spin-loop every `update()`.
    majaha committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    cea37cc View commit details
    Browse the repository at this point in the history
  2. Fix a bug where a tone's phase can be reset during a long tick

    This bug can be recreated by running
    `tone(345, 2, 50, 4)`
    as well as a big time-wasting spin-loop every `update()`.
    majaha committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    0bc7e1a View commit details
    Browse the repository at this point in the history
  3. Simplify logic around tones ending

    The old logic could cause sound glitches if a tick comes in earlier than expected.
    majaha committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    4e50857 View commit details
    Browse the repository at this point in the history
  4. Only update the APU at the end of every update()

    This means that tone() calls that are made at different times within a frame all start at the same time.
    majaha committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    eb6e58f View commit details
    Browse the repository at this point in the history
  5. Pause Audio when the menu is open

    Also fixes up the code that pauses audio, which was buggy and some of which was dead code.
    majaha committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    6514a54 View commit details
    Browse the repository at this point in the history

Commits on May 1, 2024

  1. Configuration menu
    Copy the full SHA
    414421a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    336596d View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2024

  1. APU: Make all four ADSR sections tick based

    Each tone call is split into sections, each of which has a start volume and
    frequency, and an end volume and frequency. Each section is played
    continuously until either its end *tick* is reached, ending the section and
    starting the next, or its end *time* is reached, which holds the tone there
    and stretches it out until its end tick is reached.
    majaha committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    4f6570f View commit details
    Browse the repository at this point in the history
  2. APU: Add fade out to reduce popping sounds

    Add a short fade-out period to the end of all tones to prevent audio clicks and pops.
    majaha committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    319bf46 View commit details
    Browse the repository at this point in the history
  3. Remove node types from web runtime

    The web runtime doesn't run on NodeJS, but was using node types. This was causing issues because some node types override the DOM types, like setTimeout().
    
    Adding `"types": []` to tsconfig.json prevents types in node_modules/@types from being used, including node_modules/@types/node, which is installed because it is a dependency of our dependencies.
    majaha committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    1eb964e View commit details
    Browse the repository at this point in the history
  4. Rework update() pacing to be regular and work in background

    This commit reworks the frame timing of the runtime ensuring a regular update
    every frame on 60 fps monitors, while still supporting other framerates both
    higher and lower. It achieves this by measuring the framerate continuously, and
    updating in a requestAnimationFrame() callback when the framerate is close to
    60, but switching to a setTimer() timing scheme otherwise.
    
    This keeps animation smooth on a 60 fps screen, but keeps updates both
    full-speed and at regular 16ms intervals on a 30 fps screen, important for
    making tick-based audio timings accurate. This also has the effect of allowing
    you to run the runtime in a minimised or background browser window. This is
    really improves the audio experience, allows you to run games or demos in the
    background, and also makes it much easier to test netplay without having to
    keep many windows on screen at once.
    majaha committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    065956c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b31723c View commit details
    Browse the repository at this point in the history
  6. Serve favicon.ico locally for w4 run

    Previously favicon.ico was being requested from wasm4.org when developing
    locally. This won't work if the user is offline, the website goes down
    etc. It also doesn't work well with the new CORS headers I'll introduce
    in the next commit.
    majaha committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    85e7680 View commit details
    Browse the repository at this point in the history
  7. Serve web runtime with headers for improved time accuracy

    Setting these security headers grants us access to higher precision time. This
    improves our ability to pace frame timings and make accurate performance
    measurements. I hope to take advantage of this to improve the devtools in the future.
    majaha committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    297f8d5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    35ee003 View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2024

  1. Configuration menu
    Copy the full SHA
    b5edcff View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d3fd6f7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2f2d179 View commit details
    Browse the repository at this point in the history