Ejemplo n.º 1
0
int jth_height_percentile(struct waveform_data* d, int channel, int j) {
	int index_from;
	int index_to;
	int i;
	int height;
	int arr_size;
	int* arr;
	int SKIP;
	
	SKIP = 16;
	
	index_from = (d->w->numSamples)/(d->width)*(MAX(j-2, 0));
	index_to = (d->w->numSamples)/(d->width)*(MIN(j+1+2, d->width));
	
	arr_size = (index_to-index_from)/SKIP;
	arr = malloc(sizeof(int)*(arr_size));
	
	for (i=0; i<arr_size; i++) {
		arr[i] = ABS(sample_at(d->w, channel, i*SKIP+index_from));
	}
	
	qsort(arr, arr_size, sizeof(int), compare_int);
	
	height = arr[(arr_size)*3/4];
	
	free(arr);
	
	return height;
}
Ejemplo n.º 2
0
void eeprom_write_buffer(struct sample_buffer* buffer, uint16_t pos) {
  eeprom_busy_wait();
  eeprom_update_word((uint16_t*) pos, buffer->count);
  pos += 2;
  
  for (uint16_t i = 0; i < buffer->count; i++) {
    eeprom_busy_wait();  
    eeprom_update_byte((uint8_t*) pos + i, sample_at(buffer, i));
  }
}
Ejemplo n.º 3
0
void print_sample_buffer(struct sample_buffer* buffer, FILE* stream) {
  for (uint16_t i = 0; i < buffer->count; i++) {
    fprintf(stream, "%02u", sample_at(buffer, i));
    if (i + 1 < buffer->count) {
      fputc(' ', stream);      
    }
    if ((i + 1) % 25 == 0) {
      fputc('\n', stream);
    }    
  }
  fputc('\n', stream);
  fputc('\n', stream);
}
Ejemplo n.º 4
0
int jth_height_max(struct waveform_data* d, int channel, int j) {
	int index_from;
	int index_to;
	int i, max;
	
	index_from = (d->w->numSamples)/(d->width)*j;
	index_to = (d->w->numSamples)/(d->width)*(j+1);
	
	max = 0;
	for (i=index_from; i<index_to; i++) {
		max = MAX(max, ABS(sample_at(d->w, channel, i)));
	}
	
	return max;
}