diff --git a/edflib.c b/edflib.c index b15470a..4c9dc1c 100644 --- a/edflib.c +++ b/edflib.c @@ -3792,6 +3792,58 @@ int edf_set_number_of_annotation_signals(int handle, int annot_signals) } +int edf_set_datarecord_us_duration(int handle, int 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 < 1) || (duration > 6000000)) + { + return(-1); + } + + hdrlist[handle]->long_data_record_duration = (long long)duration * 10LL; + + if(hdrlist[handle]->long_data_record_duration < (EDFLIB_TIME_DIMENSION * 10LL)) + { + hdrlist[handle]->long_data_record_duration /= 10LL; + + hdrlist[handle]->long_data_record_duration *= 10LL; + } + else + { + hdrlist[handle]->long_data_record_duration /= 100LL; + + hdrlist[handle]->long_data_record_duration *= 100LL; + } + + hdrlist[handle]->data_record_duration = ((double)(hdrlist[handle]->long_data_record_duration)) / EDFLIB_TIME_DIMENSION; + + return(0); +} + int edf_set_datarecord_duration(int handle, int duration) { if(handle<0) diff --git a/edflib.h b/edflib.h index 117656b..9551f63 100644 --- a/edflib.h +++ b/edflib.h @@ -605,6 +605,12 @@ 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_datarecord_us_duration(int handle, int duration); + +/* Sets the datarecord duration. The default value is 1 second. */ +/* ATTENTION: the argument "duration" is expressed in units of 1 microSecond! */ + + int edf_set_number_of_annotation_signals(int handle, int annot_signals); /* Sets the number of annotation signals. The default value is 1 */ diff --git a/global.h b/global.h index 6a40d50..4541299 100644 --- a/global.h +++ b/global.h @@ -35,7 +35,7 @@ #define PROGRAM_NAME "DSRemote" -#define PROGRAM_VERSION "0.32_1602061510" +#define PROGRAM_VERSION "0.32_1602081148" #define MAX_PATHLEN 4096 diff --git a/save_data.cpp b/save_data.cpp index 840525a..0a9eaa9 100644 --- a/save_data.cpp +++ b/save_data.cpp @@ -494,12 +494,16 @@ void UI_Mainwindow::save_memory_waveform() goto OUT_ERROR; } - if(edf_set_datarecord_duration(hdl, (rec_len / 100LL) / datrecs)) + if(edf_set_datarecord_us_duration(hdl, (rec_len / 10LL) / datrecs)) { strcpy(str, "Can not set datarecord duration of EDF file."); goto OUT_ERROR; } + +printf("smps_per_record: %i datrecs: %i rec_len: %lli\n", smps_per_record, datrecs, rec_len); + + j = 0; for(chn=0; chn