google / google/codeworld

Sound

Open
#47 19 comments 1 reaction 0 assignees View on GitHub
discussion
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

We could support programmatic generation of sound by using a function Number -> Number (time to amplitude sample). The sampling frequency would need to be FAR higher than the animation frequency, so we'd batch it and use a buffer.

Problems:
- The [JavaScript audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) doesn't work with Internet Explorer (possibly other browsers).
- Performance would be a challenge, and we need to make sure this can be done efficiently to avoid stuttering, even on slow computers.
- It's not clear how to merge this into games. The obvious way would be

audibleInteractionOf(initial, step, event, draw, sound)

But this ties the audio sample rate to the frame rate, which is bad. Another way would be to maintain a different World type for sound, but this is too complicated. Definitely could use some thought.
- We'd need a reasonable kind of abstraction that doesn't involve new ADTs with complicated behaviors. Working directly with wave forms might be an educational experience for a bit, but it shouldn't be unreasonably hard to just choose a timbre and play a melody.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the proposed Number -> Number waveform model, the audibleInteractionOf(initial, step, event, draw, sound) idea, and the linked JavaScript audio API documentation. The work is done when the project has an agreed abstraction for independent audio sampling, efficient buffering, browser support, and integration with games without stuttering.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, javascript
Domain
audio-video-rtc
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.