From 1dd896b9821214c504ef3347ca0566059c726b51 Mon Sep 17 00:00:00 2001 From: Maciej Makowski <120780663+maciejmakowski2003@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:34:02 +0200 Subject: [PATCH] Docs/road map and docs update (#160) * docs: readme and api coverage update * feat: added missing states * style: yarn format --------- Co-authored-by: Maciej Makowski --- README.md | 3 +- internal-docs/web-audio-coverage.md | 229 ++++++++++-------- .../common/cpp/core/AudioContext.h | 4 +- .../common/cpp/core/OscillatorNode.h | 6 +- 4 files changed, 140 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index 531962d9..4ca6aabb 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,8 @@ allowing developers to generate and modify audio in exact same way it is possibl
[MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) is usefull resource to get familiar with audio processing basics. -For development purposes there is also simplified description of already implemented interfaces as well as overview on Web Audio API coverage. +For development purposes there is overview on Web Audio API coverage. -- [Basic interfaces description](./internal-docs/basic-interfaces.md) - [Web Audio API coverage](./internal-docs/web-audio-coverage.md) ## Examples diff --git a/internal-docs/web-audio-coverage.md b/internal-docs/web-audio-coverage.md index 657961b1..e09b8fc3 100644 --- a/internal-docs/web-audio-coverage.md +++ b/internal-docs/web-audio-coverage.md @@ -1,133 +1,166 @@ -## Web Audio API coverage +# Web Audio API coverage -
- AudioContext
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| --------------------- | --- | ------- | -| 🔹 destination | ✅ | ✅ | -| 🔹 sampleRate | ✅ | ✅ | -| 🔹 state | ✅ | ✅ | -| 🔹 currentTime | ✅ | ✅ | -| 🔘 createGain | ✅ | ✅ | -| 🔘 createOscillator | ✅ | ✅ | -| 🔘 createStereoPanner | ✅ | ✅ | -| 🔘 createBiquadFilter | ✅ | ✅ | -| 🔘 close | ✅ | ✅ | +## Completed Features (**5** out of 33 features) +![](https://geps.dev/progress/15?dangerColor=006600&warningColor=006600&successColor=006600) -
+- **AudioScheduledSourceNode** +- **AudioDestinationNode** +- **GainNode** +- **StereoPannerNode** +- **AudioNode** -
- AudioParam
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ------------------------------ | --- | ------- | -| 🔹value | ✅ | ✅ | -| 🔹defaultValue | ✅ | ✅ | -| 🔹minValue | ✅ | ✅ | -| 🔹maxValue | ✅ | ✅ | -| 🔘setValueAtTime | ✅ | ✅ | -| 🔘linearRampToValueAtTime | ✅ | ✅ | -| 🔘exponentialRampToValueAtTime | ✅ | ✅ | - -
+## In Progress (**7** out of 33 features) +![](https://geps.dev/progress/21?dangerColor=ff9900&warningColor=ff9900&successColor=ff9900)
- AudioBuffer
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ------------------------------ | --- | ------- | -| 🔹sampleRate | ✅ | ✅ | -| 🔹length | ✅ | ✅ | -| 🔹duration | ✅ | ✅ | -| 🔹numberOfChannels | ✅ | ✅ | -| 🔘getChannelData | ✅ | ✅ | -| 🔘setChannelData | ✅ | ✅ | + AudioContext + +| Property 🔹/ Method 🔘 | state | +| ------------------------------- | ----- | +| 🔹 baseLatency | ❌ | +| 🔹 outputLatency | ❌ | +| 🔹 sinkId | ❌ | +| 🔘 close | ✅ | +| 🔘 createMediaElementSource | ❌ | +| 🔘 createMediaStreamSource | ❌ | +| 🔘 createMediaStreamTrackSource | ❌ | +| 🔘 resume | ❌ | +| 🔘 setSinkId | ❌ | +| 🔘 suspend | ❌ |
- AudioNode
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ----------------------- | --- | ------- | -| 🔹context | ✅ | ✅ | -| 🔹numberOfInputs | ✅ | ✅ | -| 🔹numberOfOutputs | ✅ | ✅ | -| 🔹channelCount | ✅ | ✅ | -| 🔹channelCountMode | ✅ | ✅ | -| 🔹channelInterpretation | ✅ | ✅ | -| 🔘connect | ✅ | ✅ | -| 🔘disconnect | ✅ | ✅ | + AudioBuffer + +| Property 🔹/ Method 🔘 | state | +| ------------------------------- | ----- | +| 🔹sampleRate | ✅ | +| 🔹length | ✅ | +| 🔹duration | ✅ | +| 🔹numberOfChannels | ✅ | +| 🔘getChannelData | ✅ | +| 🔘getChannelData | ✅ | +| 🔘setChannelData | ✅ | +| 🔘copyFromChannel | ❌ | +| 🔘copyToChannel | ❌ |
- AudioScheduledSourceNode
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | -| 🔘start | ✅ | ✅ | -| 🔘stop | ✅ | ✅ | + AudioBufferSourceNode + +| Property 🔹/ Method 🔘 | state | +| ------------------------------- | ----- | +| 🔹buffer | ✅ | +| 🔹detune | ❌ | +| 🔹loop | ✅ | +| 🔹loopStart | ❌ | +| 🔹loopEnd | ❌ | +| 🔹playBackRate | ❌ | +| 🔘start(overridden) | ❌ |
- AudioDestinationNode
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | + AudioParam + +| Property 🔹/ Method 🔘 | state | +| ------------------------------- | ----- | +| 🔹value | ✅ | +| 🔹defaultValue | ✅ | +| 🔹minValue | ✅ | +| 🔹maxValue | ✅ | +| 🔘setValueAtTime | ✅ | +| 🔘linearRampToValueAtTime | ✅ | +| 🔘setTargetAtTime | ❌ | +| 🔘setValueCurveAtTime | ❌ | +| 🔘cancelScheduledValues | ❌ | +| 🔘cancelAndHoldAtTime | ❌ |
- OscillatorNode
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | -| 🔹frequency | ✅ | ✅ | -| 🔹detune | ✅ | ✅ | -| 🔹type | ✅ | ✅ | + BaseAudioContext + +| Property 🔹/ Method 🔘 | state | +| --------------------------- | ----- | +| 🔹 audioWorklet | ❌ | +| 🔹 currentTime | ✅ | +| 🔹 destination | ✅ | +| 🔹 listener | ❌ | +| 🔹 sampleRate | ✅ | +| 🔹 state | ✅ | +| 🔘 createAnalyser | ❌ | +| 🔘 createBiquadFilter | ✅ | +| 🔘 createBuffer | ✅ | +| 🔘 createBufferSource | ✅ | +| 🔘 createConstantSource | ❌ | +| 🔘 createChannelMerger | ❌ | +| 🔘 createChannelSplitter | ❌ | +| 🔘 createConvolver | ❌ | +| 🔘 createDelay | ❌ | +| 🔘 createDynamicsCompressor | ❌ | +| 🔘 createGain | ✅ | +| 🔘 createIIRFilter | ❌ | +| 🔘 createOscillator | ✅ | +| 🔘 createPanner | ❌ | +| 🔘 createPeriodicWave | ❌ | +| 🔘 createStereoPanner | ✅ | +| 🔘 createWaveShaper | ❌ | +| 🔘 decodeAudioData | ❌ |
- GainNode
Android: ✅
iOS: ✅
+ OscillatorNode -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | -| 🔹gain | ✅ | ✅ | +| Property 🔹/ Method 🔘 | state | +| ------------------------------- | ----- | +| 🔹frequency | ✅ | +| 🔹detune | ✅ | +| 🔹type | ✅ | +| 🔘setPeriodicWave | ❌ |
- StereoPannerNode
Android: ✅
iOS: ✅
+ BiquadFilterNodee -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | -| 🔹pan | ✅ | ✅ | +| Property 🔹/ Method 🔘 | state | +| ------------------------------- | ----- | +| 🔹frequency | ✅ | +| 🔹detune | ✅ | +| 🔹Q | ✅ | +| 🔹gain | ✅ | +| 🔹type | ✅ | +| 🔘getFrequencyRespons | ❌ |
-
- BiquadFilterNode
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | -| 🔹frequency | ✅ | ✅ | -| 🔹detune | ✅ | ✅ | -| 🔹Q | ✅ | ✅ | -| 🔹gain | ✅ | ✅ | -| 🔹type | ✅ | ✅ | - -
-
- AudioBufferSourceNode
Android: ✅
iOS: ✅
- -| Method / Property | iOS | Android | -| ----------------- | --- | ------- | -| 🔹buffer | ✅ | ✅ | -| 🔹loop | ✅ | ✅ | - -
+## Planned Features (**21** out of 33 features) + +![](https://geps.dev/progress/64?dangerColor=800000&warningColor=800000&successColor=800000) + +- **AudioParamMap** +- **MediaElementAudioSourceNode** +- **MediaStremAudioSourceNode** +- **MediaStremTrackAudioSourceNode** +- **MediaElementAudioSourceNode** +- **ConvolverNode** +- **DelayNode** +- **DynamicsCompressorNode** +- **WaveShaperNode** +- **PeriodicWave** +- **IRRFilterNode** +- **MediaStreamAudioDestinationNode** +- **AnalyserNode** +- **ChannelSplitterNode** +- **MergerNode** +- **AudioListener** +- **PannerNode** +- **AudioWorkletNode** +- **AudioWorkletProcessor** +- **AudioWorkletGlobalScope** +- **OfflineAudioContext** diff --git a/packages/react-native-audio-api/common/cpp/core/AudioContext.h b/packages/react-native-audio-api/common/cpp/core/AudioContext.h index ad3d851e..e0079353 100644 --- a/packages/react-native-audio-api/common/cpp/core/AudioContext.h +++ b/packages/react-native-audio-api/common/cpp/core/AudioContext.h @@ -43,10 +43,12 @@ class AudioContext { std::function renderAudio(); private: - enum class State { RUNNING, CLOSED }; + enum class State { SUSPENDED, RUNNING, CLOSED }; static std::string toString(State state) { switch (state) { + case State::SUSPENDED: + return "suspended"; case State::RUNNING: return "running"; case State::CLOSED: diff --git a/packages/react-native-audio-api/common/cpp/core/OscillatorNode.h b/packages/react-native-audio-api/common/cpp/core/OscillatorNode.h index 0c1aff6a..ab94488f 100644 --- a/packages/react-native-audio-api/common/cpp/core/OscillatorNode.h +++ b/packages/react-native-audio-api/common/cpp/core/OscillatorNode.h @@ -22,7 +22,7 @@ class OscillatorNode : public AudioScheduledSourceNode { bool processAudio(float *audioData, int32_t numFrames) override; private: - enum class WaveType { SINE, SQUARE, SAWTOOTH, TRIANGLE }; + enum class WaveType { SINE, SQUARE, SAWTOOTH, TRIANGLE, CUSTOM }; static float sineWave(double wavePhase) { return static_cast(std::sin(wavePhase)); @@ -76,6 +76,8 @@ class OscillatorNode : public AudioScheduledSourceNode { return WaveType::SAWTOOTH; if (lowerType == "triangle") return WaveType::TRIANGLE; + if (lowerType == "custom") + return WaveType::CUSTOM; throw std::invalid_argument("Unknown wave type: " + type); } @@ -90,6 +92,8 @@ class OscillatorNode : public AudioScheduledSourceNode { return "sawtooth"; case WaveType::TRIANGLE: return "triangle"; + case WaveType::CUSTOM: + return "custom"; default: throw std::invalid_argument("Unknown wave type"); }