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

Add xod/waves library #2000

Merged
merged 1 commit into from
Sep 1, 2020
Merged

Add xod/waves library #2000

merged 1 commit into from
Sep 1, 2020

Conversation

evgenykochetkov
Copy link
Contributor

and deprecate old *-wave nodes from xod/core:
xod/core/saw-wave
xod/core/saw-wave-map
xod/core/sine-wave
xod/core/sine-wave-map
xod/core/square-wave
xod/core/tri-wave
xod/core/tri-wave-map

@gabbapeople
Copy link
Contributor

I still suggest that the zero value of the period should not cause an error. It is also confusing to use the future tense in the pin descriptions of some nodes. But, in eneral, everything is ok.

@evgenykochetkov
Copy link
Contributor Author

I still suggest that the zero value of the period should not cause an error.

How do you think the node should behave in this case?

@gabbapeople
Copy link
Contributor

I still suggest that the zero value of the period should not cause an error.

How do you think the node should behave in this case?

Depending on the node. But, theoretically, if the distance between the extreme vertices of the graph tends to 0, the graph turns into a straight line, output = 1, or true.

emitValue<output_OUT>(ctx, true);
} else if (!enabled && state->wasEnabled) {
// just paused
// TODO: we can get rid of storing nextSwitchTime if API would
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good and not complex to implement. How about doing it a part of this PR and remove a TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This particular implementation is just a copy of xod/core/square-wave.
I'm not sure about growing the API for a single use-case. Do you have some examples where it could also be useful?

Copy link
Member

Choose a reason for hiding this comment

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

Suggest leaving it as is for now to limit the PR scope


void evaluate(Context ctx) {
auto fractionalPart = fmod(getValue<input_X>(ctx), 1);
auto peakPosition = constrain(getValue<input_PP>(ctx), 0.0, 1.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I got an error in simulation:

error: use of undeclared identifier 'constrain'
    auto peakPosition = constrain(getValue<input_PP>(ctx), 0.0, 1.0);
                        ^
1 error generated.

So you probably have to use conditions or make a patch to our wasm package with the implementation of this function (and pray to God that every Arduino package developers add it into core.h 😄 ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and pray to God that every Arduino package developers add it into core.h 😄

I'm pretty sure they do. It's not like it's some obscure undocumented function: https://www.arduino.cc/reference/en/#functions

Copy link
Member

@nkrkv nkrkv left a comment

Choose a reason for hiding this comment

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

Like it 🤗

A few thoughts though:

  • Would it be more robust if all waves (except square) output φ (phase) instead of N? If one needs integer, he can trivially xod/math/floor.
  • The variable-triangle-wave is cool but somewhat inconsistent in naming: variable-tri-wave… What if it would be named as saw-wave with PP set to 0.5 by default. Well, it’s a saw, the saw might be customized.

@brusherru
Copy link
Contributor

BTW, what about replacing usage of the deprecated nodes for the new ones in the standard library (xod/core/flip-n-times and xod-dev/ws2812/example/example-pattern-police)? 🤔

and deprecate *-wave nodes from xod/core:
xod/core/saw-wave
xod/core/saw-wave-map
xod/core/sine-wave
xod/core/sine-wave-map
xod/core/square-wave
xod/core/tri-wave
xod/core/tri-wave-map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants