Prevent rounding errors in samplefrequency when saving waveform data to EDF.

merge-requests/1/head
Teuniz 2015-10-24 16:37:24 +02:00
rodzic 3c1f084a8b
commit cd240fff7e
4 zmienionych plików z 18 dodań i 57 usunięć

Wyświetl plik

@ -3819,7 +3819,7 @@ int edf_set_datarecord_duration(int handle, int duration)
return(-1);
}
if((duration < 100) || (duration > 6000000))
if((duration < 1) || (duration > 6000000))
{
return(-1);
}
@ -3845,46 +3845,6 @@ int edf_set_datarecord_duration(int handle, int duration)
}
int edf_set_double_datarecord_duration(int handle, double duration)
{
if(handle<0)
{
return(-1);
}
if(handle>=EDFLIB_MAXFILES)
{
return(-1);
}
if(hdrlist[handle]==NULL)
{
return(-1);
}
if(!(hdrlist[handle]->writemode))
{
return(-1);
}
if(hdrlist[handle]->datarecords)
{
return(-1);
}
if((duration < 1e-6) || (duration > 10))
{
return(-1);
}
hdrlist[handle]->long_data_record_duration = duration * EDFLIB_TIME_DIMENSION;
hdrlist[handle]->data_record_duration = ((double)(hdrlist[handle]->long_data_record_duration)) / EDFLIB_TIME_DIMENSION;
return(0);
}
int edfwrite_digital_short_samples(int handle, short *buf)
{
int i, p,

Wyświetl plik

@ -605,8 +605,6 @@ int edf_set_datarecord_duration(int handle, int duration);
/* or set the samplefrequency to 1 Hz and the datarecord duration to 2 seconds. */
/* Do not use this function, except when absolutely necessary! */
int edf_set_double_datarecord_duration(int, double);
int edf_set_number_of_annotation_signals(int handle, int annot_signals);
/* Sets the number of annotation signals. The default value is 1 */

Wyświetl plik

@ -33,7 +33,7 @@
#define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.31_1510091627"
#define PROGRAM_VERSION "0.31_1510241634"
#define MAX_PATHLEN 4096

Wyświetl plik

@ -171,8 +171,9 @@ void UI_Mainwindow::save_memory_waveform()
short *wavbuf[4];
double rec_len = 0,
yinc[MAX_CHNS];
long long rec_len=0LL;
double yinc[MAX_CHNS];
if(device == NULL)
{
@ -227,11 +228,12 @@ void UI_Mainwindow::save_memory_waveform()
goto OUT_ERROR;
}
rec_len = mempnts / devparms.samplerate;
rec_len = (EDFLIB_TIME_DIMENSION * (long long)mempnts) / devparms.samplerate;
if(rec_len < 1e-6)
if(rec_len < 100)
{
strcpy(str, "Can not save waveforms shorter than 1 uSec.");
strcpy(str, "Can not save waveforms shorter than 10 uSec.\n"
"Set the horizontal timebase to 1 uSec or higher.");
goto OUT_ERROR;
}
@ -484,7 +486,7 @@ void UI_Mainwindow::save_memory_waveform()
goto OUT_ERROR;
}
if(edf_set_double_datarecord_duration(hdl, rec_len / datrecs))
if(edf_set_datarecord_duration(hdl, (rec_len / 100LL) / datrecs))
{
strcpy(str, "Can not set datarecord duration of EDF file.");
goto OUT_ERROR;
@ -664,8 +666,9 @@ void UI_Mainwindow::save_screen_waveform()
short *wavbuf[4];
double rec_len = 0,
yinc[MAX_CHNS];
long long rec_len=0LL;
double yinc[MAX_CHNS];
if(device == NULL)
{
@ -683,16 +686,16 @@ void UI_Mainwindow::save_screen_waveform()
if(devparms.timebasedelayenable)
{
rec_len = devparms.timebasedelayscale * devparms.hordivisions;
rec_len = EDFLIB_TIME_DIMENSION * devparms.timebasedelayscale * devparms.hordivisions;
}
else
{
rec_len = devparms.timebasescale * devparms.hordivisions;
rec_len = EDFLIB_TIME_DIMENSION * devparms.timebasescale * devparms.hordivisions;
}
if(rec_len < 1e-6)
if(rec_len < 10LL)
{
strcpy(str, "Can not save waveforms when timebase < 100nS.");
strcpy(str, "Can not save waveforms when timebase < 1uSec.");
goto OUT_ERROR;
}
@ -848,7 +851,7 @@ void UI_Mainwindow::save_screen_waveform()
goto OUT_ERROR;
}
if(edf_set_double_datarecord_duration(hdl, rec_len))
if(edf_set_datarecord_duration(hdl, rec_len / 100LL))
{
strcpy(str, "Can not set datarecord duration of EDF file.");
goto OUT_ERROR;