Skip to content

Commit 7fe7d19

Browse files
committed
feat: add feature description; fix wave_producer_valid test
1 parent eea2182 commit 7fe7d19

6 files changed

Lines changed: 318 additions & 85 deletions

File tree

README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# Description
2+
3+
This project aims to run Web Audio API in Android with javascript code. Most of the available APIs have passed wpt test cases.
4+
5+
Now it supports following Web Audio feature:
6+
7+
| Features | Interface Support State | Test State |
8+
| --------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9+
| AudioBuffer | <font color="green">Full Support</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ConvolverNode", "ChannelMergerNode")</font> |
10+
| AudioContext | <font color="green">Partial Support</font> | <font color="yellow">Not Test Yet</font> |
11+
| AudioDestinationNode | <font color="yellow">Full Support</font> | <font color="green">Complete</font> |
12+
| AudioNode | <font color="yellow">Partial Support</font> | <font color="red">Not Test Yet</font> |
13+
| AudioParam | <font color="yellow">Partial Support</font> | <font color="red">Not Test Yet</font> |
14+
| AudioScheduledSourceNode | <font color="yellow">Partial Support</font> | <font color="grey">No Wpt Test</font> |
15+
| BaseAudioContext | <font color="yellow">Partial Support</font> | <font color="grey">No Wpt Test</font> |
16+
| OfflineAudioCompletionEvent | <font color="yellow">Partial Support</font> | <font color="grey">No Wpt Test</font> |
17+
| OfflineAudioContext | <font color="yellow">Partial Support</font> | <font color="green">Complete</font> |
18+
| OscillatorNode | <font color="yellow">Partial Support</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ChannelMergerNode")</font> |
19+
| GainNode | <font color="green">Full Support</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ChannelMergerNode")</font> |
20+
| DelayNode | <font color="green">Full Support</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ConstantSourceNode", "ChannelSplitterNode", "ChannelMergerNode")</font> |
21+
| AudioBufferSourceNode | <font color="green">Full Support</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "AudioWorkletNode", "ChannelMergerNode", "EventListener", "decodeAudioData", "setValueAtTime")</font> |
22+
23+
more detail info is descript [here](./js_api_define/features.md).
24+
125
# Run
226

327
1. run `npm install` for installing dependency
@@ -13,23 +37,3 @@
1337
# Note:
1438

1539
1. `combine` script in package.json is used to make vscode recognize all cpp files in different module inside android module. When Android Build success, scripts in `build.gradle.kts` will move all `compile_commands.json` contents to `.vscode/compile_commands.json`, this will make vscode cpp intelligence works fine.
16-
17-
# Plan
18-
19-
| Features | Complete State | Test State |
20-
| --------------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
21-
| AudioBuffer | <font color="green">Complete</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ConvolverNode", "ChannelMergerNode")</font> |
22-
| AudioContext | <font color="green">Complete</font> | <font color="yellow">Not Test Yet</font> |
23-
| AudioDestinationNode | <font color="yellow">1. All data member is readonly</font> | <font color="green">Complete</font> |
24-
| AudioNode | <font color="green">Complete</font> | <font color="red">Not Test Yet</font> |
25-
| AudioParam | <font color="green">Complete</font> | <font color="red">Not Test Yet</font> |
26-
| AudioScheduledSourceNode | <font color="green">Complete</font> | <font color="grey">No Wpt Test</font> |
27-
| BaseAudioContext | <font color="green">Complete</font> | <font color="grey">No Wpt Test</font> |
28-
| OfflineAudioCompletionEvent | <font color="green">Complete</font> | <font color="grey">No Wpt Test</font> |
29-
| OfflineAudioContext | <font color="green">Complete</font> | <font color="green">Complete</font> |
30-
| OscillatorNode | <font color="green">Complete</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ChannelMergerNode")</font> |
31-
| GainNode | <font color="green">Complete</font> | <font color="yellow">Not Pass All Wpt Test (lack support of "ChannelMergerNode")</font> |
32-
| DelayNode | <font color="green">Complete</font> | <font color="red">Not Test Yet (lack support of "ConstantSourceNode", "AudioBufferSourceNode", "ChannelSplitterNode", "ChannelMergerNode")</font> |
33-
| AudioBufferSourceNode | <font color="red">Not Complete</font> | <font color="red">Not Test Yet (lack support of "AudioWorkletNode", "ChannelMergerNode")</font> |
34-
| MediaRecorderNode | <font color="red">Not Complete</font> | <font color="red">Not Test Yet</font> |
35-
| MicrophoneStreamNode | <font color="red">Not Complete</font> | <font color="red">Not Test Yet</font> |

index.js

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -23,70 +23,9 @@ async function AllTest() {
2323

2424
for (let i = 0; i < task_list.length; i++) {
2525
await task_list[i]();
26+
// do gc() to clear nodejs async queue
2627
global.gc();
2728
}
2829
}
2930

30-
async function GetTuneAudioBuffer(tunes, numberOfChannels, ctx) {
31-
const audioBuffer = new AudioBuffer({
32-
numberOfChannels: numberOfChannels,
33-
length: ctx.sampleRate * tunes.length,
34-
sampleRate: ctx.sampleRate,
35-
});
36-
for (let i = 0; i < tunes.length; i++) {
37-
console.log("flag01");
38-
const offline_audio_ctx = new OfflineAudioContext(
39-
numberOfChannels,
40-
ctx.sampleRate,
41-
ctx.sampleRate
42-
);
43-
console.log("flag02");
44-
const osc = new OscillatorNode(offline_audio_ctx, { frequency: tunes[i] });
45-
console.log("flag03");
46-
osc.connect(offline_audio_ctx.destination);
47-
console.log("flag04");
48-
osc.start();
49-
console.log("flag05");
50-
let buffer = await offline_audio_ctx.startRendering();
51-
audioBuffer.copyToChannel(buffer.getChannelData(0), 0, i * ctx.sampleRate);
52-
audioBuffer.copyToChannel(buffer.getChannelData(1), 1, i * ctx.sampleRate);
53-
}
54-
return audioBuffer;
55-
}
56-
57-
// const tune = [261.625, 293.664, 329.628, 349.228, 391.995, 440, 493.883];
58-
59-
// let ctx = new AudioContext();
60-
61-
async function Test(loopStart, loopEnd, playbackRate) {
62-
// let ctx = new AudioContext();
63-
64-
let audioBuffer = await GetTuneAudioBuffer(tune, 2, ctx);
65-
66-
let audioBufferSourceNode = ctx.createBufferSource();
67-
audioBufferSourceNode.buffer = audioBuffer;
68-
audioBufferSourceNode.loop = true;
69-
audioBufferSourceNode.loopStart = loopStart;
70-
audioBufferSourceNode.loopEnd = loopEnd;
71-
audioBufferSourceNode.playbackRate = playbackRate;
72-
73-
// let audioBufferSourceNode = new AudioBufferSourceNode(ctx, {
74-
// buffer: audioBuffer,
75-
// loop: true,
76-
// loopStart: loopStart,
77-
// loopEnd: loopEnd,
78-
// playbackRate: playbackRate,
79-
// });
80-
console.log("before start");
81-
audioBufferSourceNode.start(0, 0, 20);
82-
console.log("before connect");
83-
audioBufferSourceNode.connect(ctx.destination);
84-
85-
setTimeout(() => {
86-
console.log("before stop");
87-
audioBufferSourceNode.stop();
88-
}, 14000);
89-
}
90-
9131
AllTest();
92-
// Test(3, 7, 1.0);

js_api_define/AudioParam.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
interface AudioParam {
22
value: number /* float */
33
// @ts-ignore
4-
readonly automationRate: AutomationRate // currently only support a-rate
4+
readonly automationRate: AutomationRate // currently only support k-rate
55
readonly defaultValue: number /* float */
66
readonly minValue: number /* float */
77
readonly maxValue: number /* float */
8-
};
8+
};

0 commit comments

Comments
 (0)