@ain1084/audio-worklet-stream 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +11 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -142,9 +142,7 @@ The library does not handle the construction or destruction of AudioContext. Whe
142
142
  Example:
143
143
 
144
144
  ```typescript
145
- import { StreamNodeFactory,
146
- type OutputStreamNode,
147
- } from '@ain1084/audio-worklet-stream'
145
+ import { StreamNodeFactory, type OutputStreamNode } from '@ain1084/audio-worklet-stream'
148
146
 
149
147
  let audioContext: AudioContext | null = null
150
148
  let factory: StreamNodeFactory | null = null
@@ -157,23 +155,23 @@ const clicked = async () => {
157
155
 
158
156
  // Create manual buffer stream
159
157
  const channelCount = 1
160
- const [node, writer] = await factory.createManualBufferNode(
161
- { channelCount, frameBufferSize: 4096 }
162
- )
158
+ const [node, writer] = await factory.createManualBufferNode({
159
+ channelCount,
160
+ frameCount: 4096,
161
+ })
163
162
 
164
163
  // Write frames
165
- writer.write((buffer) => {
166
- const samplesPerFrame = channelCount
167
- for (let i = 0; i < buffer.length; i += samplePerFrame) {
168
- for (let channel = 0; channel < samplesPerFrame; ++channel)
169
- buffer[i + channel] = sampleValue /* TODO: Write sample */
164
+ writer.write((segment) => {
165
+ for (let frame = 0; frame < segment.frameCount; frame++) {
166
+ for (let channel = 0; channel < segment.channels; ++channel) {
167
+ segment.set(frame, channel, /* TODO: Write sample value */)
170
168
  }
171
169
  }
172
170
  // Return the count of written frames
173
- return buffer.length / samplesPerFrame
171
+ return segment.frameCount
174
172
  })
175
173
 
176
- // Play start
174
+ // Start playback
177
175
  node.start()
178
176
  audioContext.connect(audioContext.destination)
179
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ain1084/audio-worklet-stream",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "module": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [