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

FP style #89

Closed
dy opened this issue Sep 7, 2019 · 4 comments
Closed

FP style #89

dy opened this issue Sep 7, 2019 · 4 comments

Comments

@dy
Copy link
Owner

dy commented Sep 7, 2019

Spect may come useful in audio-js as:

import output from 'audio-speaker'
import oscillate from 'audio-oscillator'
import spect from 'spect'

spect.use(output, oscillate)

// initial code
let buf = new AudioBuffer({ channels: 2, sampleRate: 44100, length: 1024 })
;(async function frame() {
  await output(oscillate(buf, { frequency: 440 })))
  frame()
})()

// aspect code
spect(new AudioBuffer({ channels: 2, sampleRate: 44100, length: 1024 })).use(({ oscillate, output, update }) => {
  oscillate(440)
  await output()
  update()
})
@dy
Copy link
Owner Author

dy commented Sep 12, 2019

That's a TODO #17 case.

@dy dy closed this as completed Sep 13, 2019
@dy
Copy link
Owner Author

dy commented Sep 20, 2019

Isn't that beautiful to just have linked effects as

use(new AudioBuffer({ channels: 2, sampleRate: 44100, length: 1024 }), (buf) => {
  oscillate(buf, 440)
  await output(buf)
  update(buf)
})

@dy dy reopened this Sep 20, 2019
@dy
Copy link
Owner Author

dy commented Sep 21, 2019

#43

@dy
Copy link
Owner Author

dy commented Oct 6, 2019

8.0.0 is functional style.

@dy dy closed this as completed Oct 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant