This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Abrupt tone generator switching off
#1
When the "new" tone generator is called many times it is switched off while the program continues measuring (see post https://phyphox.org/forums/showthread.ph...07#pid2207). I do not think it is something new, it was observed with previous versions of phyphox. The number of points before the switching off depends of the frequency value.

Best
Mikhail
1.1.8-beta1


Attached Files Thumbnail(s)
   
Reply
#2
This was probably the most annoying bug to test I have ever seen as I had to actually run the tone generator for about 20 minutes to hear when it fails and I had to do so every time I tried something. But the solution is simple and to me somewhat satisfyingly "low level".

Ths short version: The problem occurs on Android and maybe 32bit iPhones (i.e. the iPhone 5s of those supporting phyphox). It is independent of how often you set the frequency, but happens after an exact number of periods - even on the built in tone generator experiment.

In detail, the problem was that there was an integer overflow while calculating the index for the sine lookup table. Instead of calculating the sine function for each sample (which would mean 48000 sines per second - and that is not a quick and simple calculation) phyphox generates a table of 4096 pre-calculated sine values (thanks to sine's symmetry we could do with a fourth of this, but the implementation is easier this way). When generating the tone we then need to calculate the index of these values, which simply means that instead of calculating a phase from 0 to 2pi, we calculate an integer phase from 0 to 4095. And since it is cyclic, we just calculate an absurdly large number and map it to the 0 to 4095 range with the modulo function. And this absurdly large number hit the maximum of a signed 32bit integer of 2^31-1.

In terms of the tone generator, this means that limit is reached after (2^31-1)/48000 periods. So, if you try the default frequency of the included tone generator at 440 Hz, the tone will stop after 1192 seconds (almost 20 minutes). If you set it to 100 Hz it works for over an hour and if you set it to 8738Hz it breaks after exactly one minute.

The good news is that this is an easy fix included in the next update (probably another beta). The bad news is that this will be a while since it is a rather niche problem and the first change since we published the last beta version just before Christmas. Unfortunately, there is not much you can do about it except for trying to work around the problem by finishing the measurement with fewer total periods (I know, a very strange and hard to control limitation) or pausing the measurement, saving the current state and re-opening the state to continue from there. You might also be able to use two or more tone generators as the phase is tracked for each generator individually (using a different tone generator for different frequency range while keeping the others at a frequency of zero), but this is quite certainly not worth the hassle.
Reply
#3
Thank you, Sebastian.
I supposed something like this. But there is another problem with the tone generator of probably different origin. When I clean the data the generator does not restart and I have to quit the program to make it working again.
Reply
#4
Sorry, forgot to enable the subscription to this thread...

Do you mean after it turned off after a long run? That is to be expected. The phase is not stored in the data buffers of the experiment but in the instance of the experiment class that is created when the experiment is loaded, so it is not reset when you clear the buffer.

Edit:
BTW: Seems like my estimate for a fix was way to pessimistic. I will release a new beta as soon as you confirm that this is not an additional bug Smile
Reply
#5
I have verified once more..
- You just start measurements and you do not like something, so you press "trash" to clear buffers without pressing "pause".
- Clean up puts the program to pause, but if you press "run" nothing happens.
- To restart the measurements you have to press "pause" and then "run" again. Going out of the program is not necessary.

So it is not really a bug.
Reply
#6
(01-07-2021, 06:38 PM)solid Wrote: So it is not really a bug.

That's what I love to hear most Wink I have now submitted the beta version with the fix, which should appear soon.
Reply
#7
Thank you Sebastian.

With phyphox version 1.1.8-beta2 the tone generator has no problem and no limits ! Big Grin 

Mikhail


Attached Files Thumbnail(s)
   
Reply


Forum Jump: