dear all,
I'd like to implement a kind of audio feedback control that makes the phone playing a sound everytime the gyroscope x-axis signal goes above a given threshold. Using the online editor, first I added an audio output in the "Output" tab of the editor. Then, in the "Analysis" tab, should I just add a "threshold" module with the x output of the sensor block as the y-input of the "threshold" module and then connect its output ("position") with the input of the "audio" module?
Thanks,
Pietro
In my understanding, you would like to play a tone whenever the gyroscope-y exceeds a certain value and none if it is below. You need a bit more logic in the analysis block, so that the tone in fact also stops.
A quick and dirty solution would perhaps be to set a brief sleep period for the analysis block and check with “max” (put a clear flag to that buffer!) if you are above threshold. With “if” you (un)set the tone…
09-19-2023, 01:28 AM (This post was last modified: 09-19-2023, 01:28 AM by pietropicerno.)
Hi Jens,
yes, you got it right! I've actually decided to use the phone's inclination about the y-axis to make things smoother. I created a simple experiment using atan2(ax,az) that outputs the inclination of the phone in degrees in the xz plane. Now, let's say that I want a sound when the inclination goes over 10° and it quits playing the sound when the inclination returns below 10°.
Unfortunately, I didn't really get your advices. Would a "threshold" module be ok rather than using "max" module? I tried to make the "if" module work but without succes. Would you please try to add some control to the attached experiment? Many thanks, Pietro.
feedback inclinometer.phyphox (Size: 2.08 KB / Downloads: 218)
09-25-2023, 02:22 PM (This post was last modified: 09-25-2023, 03:08 PM by pietropicerno.)
Hi Jens,
sorry to bother you again. I tried to use the "if" module like shown in the attached picture and I succeeded to play the sound when the signal crosses the value of "10". The problem is that it doesn't quit when the signal goes below 10. Honestly, I'm having some troubles in fully understanding how the "if" module works (not a general "if" statement I mean, as I usually program in Matlab, but PhyPhox's "if" module specifically.
In PhyPhox wiki on the analysis modules, about the "if" module, I read: " For example if you set the true input to empty, do not connect the false input and set the output to clear, it will only clear the output if the condition is true, but leaves it alone otherwise. This can be used as a reset condition." This looks like a possible solution to stop quit the tone and I tried to implement it but I couldn't make it work.
dear Jens,
as this thread hasn't got any reply since more than two months, I think this thread can be closed. I'm going to open a new thread to look for some support on the general use of the if-module (that is striclty related to the aim of this thread). Thanks for your time, Pietro
Hi, somehow I have not been aware of the (unanswered) original post – and it has taken some time to look into this now…
It is hard to tell from your screenshot what exactly is going on in the resulting xml code. I suppose that “Note, that since the visual editor does not support reusing buffers, you probably cannot do this there in a reasonable way...”, see https://phyphox.org/wiki/index.php/Analysis_modules#if, might be the reason.
We hope that we can settle this with a new blockly-based editor that will (keeping fingers crossed) be released soon…ish.
Until then, you likely need to fine tune the resulting code with a text editor (that sounds harder than it is, particularly, when you know a bit about XML).
ok thank you Jens! I'm looking forward for the update! (ish.... :-) )
In the meanwhile, I'm able to use the if-module in a reasonable way now. I've also discovered that the audio module wants a binary input and it works perfectly with the if-module as you can set the output to "1" or "0".
So we can keep this thread open!
Keep in touch. Regards,
Pietro
I played a bit with the xlm file of the original gyroscope experiment, and here is a way to do it. If you want to modify it, just open the file with a text editor, I am not sure whether the online phyphox editor will handle the file.
thanks! it actually works if embedded in PhyPhox app using the QR code but in the editor the audio block appears unlinked. But I'll start from here. Thanks!
Pietro