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

Async data/event #52

Closed
mfkiwl opened this issue Aug 10, 2023 · 6 comments
Closed

Async data/event #52

mfkiwl opened this issue Aug 10, 2023 · 6 comments

Comments

@mfkiwl
Copy link

mfkiwl commented Aug 10, 2023

Many thanks for sharing this data centric programing framework. Actually I love it very much and think it will simplifies a lot of programming effort when dealing with streaming data.

After reading the docs, I come across a question that if there are async event, such as user input, or history data based decision branch, that generating data not synced with the main data stream, what is the best way to do with the DSPatch framework?

Best regards,
Xing

@MarcusTomlinson
Copy link
Member

Hi Xing, if I understand the question, you want to inject some sort of data from a different thread to the one the circuit is processing on - data that may come in at any time.

Well, components are just regular classes right, so you can add what ever public methods you like to them. E.g. a Gain component could expose a SetGain() method that simply updates a member variable in the class - that member used to apply gain to the signal within your Process method.

@mfkiwl
Copy link
Author

mfkiwl commented Aug 10, 2023

Nice! I got the point. Can I ask if you have similar examples just as you mentioned “SetGain”?

@MarcusTomlinson
Copy link
Member

Sure: https://github.com/cross-platform/dspatchables/blob/master/Components/Gain/Gain.cpp

This is also an example of how one could use a component input for setting the gain as well.

@mfkiwl
Copy link
Author

mfkiwl commented Aug 11, 2023

Thanks I read the Gain.cpp. Could you please point out the example you are referring to ? I tried hard and didn't find it.

@MarcusTomlinson
Copy link
Member

You can see the component has a public method "SetGain()" here: https://github.com/cross-platform/dspatchables/blob/master/Components/Gain/Gain.cpp#L64 (this is the answer to your original question)

You can also see here that input 2 of the component can accept a gain value from another component (if you want that): https://github.com/cross-platform/dspatchables/blob/master/Components/Gain/Gain.cpp#L92

@mfkiwl
Copy link
Author

mfkiwl commented Aug 24, 2023

Many thanks

@mfkiwl mfkiwl closed this as completed Aug 24, 2023
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

No branches or pull requests

2 participants