You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project aims to run Web Audio API in Android with javascript code. Most of the available APIs have passed wpt test cases.
@@ -22,18 +25,32 @@ Now it supports following Web Audio feature:
22
25
23
26
more detail info is descript [here](./js_api_define/features.md).
24
27
25
-
# Run
28
+
# Build & Run
26
29
27
30
1. run `npm install` for installing dependency
28
31
2. run `npm start` to get server address like `http://xxx.xxx.xxx.xxx:20490`
29
-
3. add this line `js_entry="http://xxx.xxx.xxx.xxx:20490/index.js"` to local.property file
32
+
3. open root folder with Android Studio
33
+
4. add this line `js_entry="http://xxx.xxx.xxx.xxx:20490/index.js"` to local.property file
34
+
5. build and run app
30
35
31
-
# Develop
36
+
# App Interface
37
+
38
+
After running app, you can see five buttons:
32
39
33
-
## VSCode
40
+
1.`START`: Start running js code in `index.js`
41
+
2.`STOP`: Stop js event loop. You need to press `RESTART` button to re-run js code.
42
+
3.`PAUSE`: Pause js event loop.
43
+
4.`RESUME`: Resume js event from pause.
44
+
5.`RESTART`: Restart app.
45
+
46
+
NOTE: all console message in js code will be output to Android Studio Logcat.
47
+
48
+
# Develop
34
49
35
-
1. You should open root folder by vscode after running app or building app at `app/build.gradle.kts` page. This will make Android Studio generate `.vscode/compile_commands.json` file, which is used by vscode to recognize cpp headers.
50
+
see [develop.md](./docs/develop.md)
36
51
37
-
# Note:
52
+
# Thanks
38
53
39
-
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.
54
+
1. Test case based on [wpt](https://github.com/web-platform-tests/wpt).
55
+
2. NAPI_IH base on [node-addon-api-helper](https://github.com/ajihyf/node-addon-api-helper).
56
+
3. Use [ProcessPhoenix](https://github.com/JakeWharton/ProcessPhoenix) to restart Android App.
"start": "npm run compress && http-server -p 20490"
13
+
},
14
+
```
15
+
16
+
1.`compress`: each NAPI module which needs to be exported in js is export by `globalThis.ModuleApiName = process._linkedBinding("ModuleName").ApiName;`. These js code are put in `**/preload_script.js` file, which will be converted to c string saved in `**/preload_script.hpp`. This process is handled by `compress` command.
17
+
2.`combine`: cpp code of this project is developed in vscode, so we need to add all relative file paths to the `compileCommands` options of `.vscode/c_cpp_properties.json`. These cpp relative files will be created when do build in Android Studio, `combine` command is used to collect and add them to `.vscode/compile_commands.json`, then vscode can recognize cpp symbol.
18
+
3.`valid`: Use to check if WaveProducer, a tool used in OscillatorNode, works correctly.
19
+
4.`start`: do `compress` and start a http-server accessed by app to load js code which need to be run.
20
+
21
+
## cpp hint
22
+
23
+
If you write cpp layer in vscode, you should build once after Android Studio sync. Build will trigger `combine` command which makes vscode recognize cpp symbol.
24
+
25
+
NOTE: if you find vscode not recognize cpp symbol, make sure to switch the Android Studio tab to `app/build.gradle.kts`, then build.
26
+
27
+
## NAPI
28
+
29
+
### NodeJS
30
+
31
+
The node env of this project is based on [v14.17.0](https://github.com/toyobayashi/node-android-build/releases/tag/v14.17.0) of [node-android-build](https://github.com/toyobayashi/node-android-build). The build tutorial is referenced to [在 Android 应用中嵌入 Node.js](https://toyobayashi.github.io/2021/03/29/NodeEmbedding/)
32
+
33
+
### NAPI_IH
34
+
35
+
The goal of the project architecture is to make the structure of the napi layer consistent with the cpp layer. But NAPI do not support inheritance, so we make a pitch to NAPI, that is [NAPI_IH](./napi_ih_api.md).
Copy file name to clipboardExpand all lines: docs/napi_ih_api.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Description
1
+
# NAPI_IH
2
2
3
3
`napi_ih` means "napi inheritance helper" which is a pitch to napi to support inheritance and try to keep the style of napi. The implementation is inspired by https://github.com/ajihyf/node-addon-api-helper and https://mmomtchev.medium.com/-class-inheritance-with-node-api-and-node-addon-api-c180334d9902
0 commit comments