-
-
Notifications
You must be signed in to change notification settings - Fork 34
feat: audio node options in ctor #807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mdydek
wants to merge
32
commits into
main
Choose a base branch
from
feat/audio-node-options-in-ctor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
d74dee6
feat: gain impl
mdydek 62ae75f
feat: better consistency
mdydek 5790ce5
docs: docs proposition
mdydek 4fd5487
feat: stereo panner options
mdydek 5d7cc69
feat: added web
mdydek add1958
feat: convolver options
mdydek 022683b
test: tests
mdydek 0a539d1
feat: constant source options
mdydek a90f428
Merge branch 'main' into feat/audio-node-options-in-ctor
mdydek a052c45
feat: web for convolver
mdydek a47447b
feat: periodic wave
mdydek 1aa6443
feat: analyser node
mdydek 3b0b1b7
feat: biquad filter
mdydek 1dcdaa6
feat: oscillator
mdydek 1f62ba8
feat: mobile audio buffer sources
mdydek f80292a
feat: streamer node options
mdydek 67df87d
feat: recorder adapter
mdydek 617188a
feat: worklets
mdydek 0a6f8d8
feat: audiobuffer
mdydek f074c12
feat: audiobuffer on web
mdydek 4617720
docs: documentation for new constructors
mdydek 002b5c3
feat: absn on web
mdydek 25c9327
Merge branch 'main' into feat/audio-node-options-in-ctor
mdydek 829c019
feat: delay node
mdydek 2c6a512
feat: iirfilter
mdydek e487709
test: test fix
mdydek bf1ad3d
feat: better absn for web
mdydek 5632d68
feat: reverted pitch correction option in factory method for absn
mdydek 97eb239
feat: slowly removing shared ptr in options
mdydek 7a99505
feat: removed options as shared ptr
mdydek b19e1fd
test: test fix
mdydek e12c3da
feat: changes after review
mdydek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/react-native-audio-api/common/cpp/audioapi/HostObjects/utils/NodeOptions.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #pragma once | ||
|
|
||
| #include <audioapi/core/types/ChannelCountMode.h> | ||
| #include <audioapi/core/types/ChannelInterpretation.h> | ||
|
|
||
| namespace audioapi { | ||
| struct AudioNodeOptions { | ||
poneciak57 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| int channelCount; | ||
| ChannelCountMode channelCountMode; | ||
| ChannelInterpretation channelInterpretation; | ||
| }; | ||
|
|
||
| struct GainOptions : AudioNodeOptions { | ||
| float gain; | ||
| explicit GainOptions(AudioNodeOptions nodeOptions) | ||
| : AudioNodeOptions(nodeOptions) {} | ||
| }; | ||
| } // namespace audioapi | ||
63 changes: 63 additions & 0 deletions
63
packages/react-native-audio-api/common/cpp/audioapi/HostObjects/utils/NodeOptionsParser.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #pragma once | ||
|
|
||
| #include <audioapi/jsi/RuntimeLifecycleMonitor.h> | ||
| #include <jsi/jsi.h> | ||
| #include <memory> | ||
| #include <utility> | ||
| #include <vector> | ||
| #include <cstddef> | ||
|
|
||
| #include <audioapi/HostObjects/utils/NodeOptions.h> | ||
|
|
||
| namespace audioapi::option_parser { | ||
| std::shared_ptr<AudioNodeOptions> parseAudioNodeOptions( | ||
| jsi::Runtime &runtime, | ||
| const jsi::Object &optionsObject | ||
| ) { | ||
| AudioNodeOptions options; | ||
|
|
||
| options.channelCount = | ||
| static_cast<int>(optionsObject | ||
| .getProperty(runtime, "channelCount") | ||
| .getNumber()); | ||
|
|
||
| auto channelCountModeStr = optionsObject | ||
| .getProperty(runtime, "channelCountMode") | ||
| .asString(runtime) | ||
| .utf8(runtime); | ||
|
|
||
| if (channelCountModeStr == "max") { | ||
| options.channelCountMode = ChannelCountMode::MAX; | ||
| } else if (channelCountModeStr == "clamped-max") { | ||
| options.channelCountMode = ChannelCountMode::CLAMPED_MAX; | ||
| } else if (channelCountModeStr == "explicit") { | ||
| options.channelCountMode = ChannelCountMode::EXPLICIT; | ||
| } | ||
|
|
||
| auto channelInterpretationStr = optionsObject | ||
| .getProperty(runtime, "channelInterpretation") | ||
| .asString(runtime) | ||
| .utf8(runtime); | ||
|
|
||
| if (channelInterpretationStr == "speakers") { | ||
| options.channelInterpretation = ChannelInterpretation::SPEAKERS; | ||
| } else if (channelInterpretationStr == "discrete") { | ||
| options.channelInterpretation = ChannelInterpretation::DISCRETE; | ||
| } | ||
|
|
||
| return std::make_shared<AudioNodeOptions>(options); | ||
| } | ||
|
|
||
| GainOptions parseGainOptions( | ||
| jsi::Runtime &runtime, | ||
| const jsi::Object &optionsObject) { | ||
| std::shared_ptr<AudioNodeOptions> nodeOptions = parseAudioNodeOptions(runtime, optionsObject); | ||
| GainOptions options(*nodeOptions.get()); | ||
| options.gain = static_cast<float>(optionsObject | ||
| .getProperty(runtime, "gain") | ||
| .getNumber()); | ||
| return options; | ||
mdydek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
mdydek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } // namespace audioapi::option_parser | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,20 @@ | ||
| import { IGainNode } from '../interfaces'; | ||
| import { GainOptions } from '../defaults'; | ||
| import { TGainOptions } from '../types'; | ||
| import AudioNode from './AudioNode'; | ||
| import AudioParam from './AudioParam'; | ||
| import BaseAudioContext from './BaseAudioContext'; | ||
|
|
||
| export default class GainNode extends AudioNode { | ||
| readonly gain: AudioParam; | ||
|
|
||
| constructor(context: BaseAudioContext, gain: IGainNode) { | ||
| super(context, gain); | ||
| this.gain = new AudioParam(gain.gain, context); | ||
| constructor(context: BaseAudioContext, gainOptions?: TGainOptions) { | ||
| const finalOptions: TGainOptions = { | ||
| ...GainOptions, | ||
| ...gainOptions, | ||
| }; | ||
| const gainNode: IGainNode = context.context.createGain(finalOptions); | ||
| super(context, gainNode); | ||
| this.gain = new AudioParam(gainNode.gain, context); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { TAudioNodeOptions, TGainOptions } from './types'; | ||
|
|
||
| export const AudioNodeOptions: TAudioNodeOptions = { | ||
| channelCount: 2, | ||
| channelCountMode: 'max', | ||
| channelInterpretation: 'speakers', | ||
| }; | ||
|
|
||
| export const GainOptions: TGainOptions = { | ||
| ...AudioNodeOptions, | ||
| gain: 1, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.