2.1.1 • Published 3 years ago

web-audio-write v2.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

web-audio-write unstable

Write data to any web-audio node.

Usage

npm install web-audio-write

import createWriter from 'web-audio-write'

const context = new AudioContext()
const write = createWriter(context.destination)

for (let n = 0; n < 10; n++) await write(noise())
write.end()

function noise (frame=1024, channels=2) {
	let data = new Float32Array(channels * frame)
	for (let i = 0; i < data.length; i++) {
		data[i] = Math.random() * 2. - 1.
	}
	return data
}

API

write = createWriter(node = audioContext.destination)

Create a function, writing any data to any AudioNode. Channel number and sample rate is derived from destination node.

async write(samples)

Send data to the destination node. samples can be an array with planar channels layout or a list of arrays, with floats in -1...+1 range. Returns promise that is resolved when data chunk is being consumed, that's a good place to feed more data.

write(null)

Schedules end of writing.

write.node

Exposes worklet web-audio node.

Related

License

(c) 2019 audiojs. MIT License

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago