Skip to content
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

Feat/android/gain node #39

Merged
merged 8 commits into from
Jul 25, 2024
Merged

Feat/android/gain node #39

merged 8 commits into from
Jul 25, 2024

Conversation

maciejmakowski2003
Copy link
Collaborator

-Implemented classes for GainNode and whole necessary logic in AudioContext classes
-Implemented get method in AudioNodeHostObject in order to call it from derived classes
-Refactored imports, friend class marks, etc.

Closes: #22

Copy link
Member

@michalsek michalsek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small js nitpicks, overall looks good


namespace audiocontext {

using namespace facebook::jni;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this file then? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right

}
minimumValue={0.0}
maximumValue={1.0}
step={0.1}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: why only 10 steps instead of 100 with step of 0.01 or even go with [0, 100] scope and normalize it when setting a gainRef property

Comment on lines 38 to 50
const handleSliderChange = (
value: number[],
defaultValue: number,
setValue: (value: number) => void,
ref: React.MutableRefObject<{ [key: string]: any } | null>,
propName: string
) => {
const newValue = value[0] || defaultValue;
setValue(newValue);
if (ref.current) {
ref.current[propName] = newValue;
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't notice is earlier, why so over-complicated?

Suggested change
const handleSliderChange = (
value: number[],
defaultValue: number,
setValue: (value: number) => void,
ref: React.MutableRefObject<{ [key: string]: any } | null>,
propName: string
) => {
const newValue = value[0] || defaultValue;
setValue(newValue);
if (ref.current) {
ref.current[propName] = newValue;
}
};
const handleSliderChange = (value: number[]) => {
const newValue = value[0] || 0.0;
setValue(newValue);
ganinRef.current?.gain = value;
};

if we would like to have generic way of modify'ing nodes via sliders we could create a hook and/or components for that

useNodeValue(node: AudioNode) {
   // state
   // callbacks
   // return values?
}

...

useNodeValue(gainNodeRef.current);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I have implemented three handlers each for parameter. In future I will introduce sth like a hook that u mentioned.

@michalsek
Copy link
Member

Fix conflicting files, consider the comments and you can merge this branch :)

@maciejmakowski2003 maciejmakowski2003 merged commit 5f2694f into main Jul 25, 2024
2 checks passed
@maciejmakowski2003 maciejmakowski2003 deleted the feat/android/gain-node branch July 25, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement GainNode on Android
2 participants