Exemple #1
0
bool dlpspec_is_slewcfgtype(void *struct_p, size_t buffer_size)
{
	char *fmt;
	char scan_type;

	fmt = tpl_peek(TPL_MEM | TPL_DATAPEEK, struct_p, buffer_size, "c", &scan_type);
	free (fmt);

	if(scan_type == SLEW_TYPE)
		return true;
	else
		return false;
}
Exemple #2
0
bool dlpspec_is_slewdatatype(void *struct_p, size_t buffer_size)
{
	char *fmt;
	bool ret;
    char std_cfg_format[] = "S(" SCAN_DATA_FORMAT ")";

	fmt = tpl_peek(TPL_MEM, struct_p, buffer_size);

	if(fmt == NULL)
		return false;

    if(strcmp(fmt, std_cfg_format) == 0)
        ret = false;
	else
        ret = true;

	free (fmt);
	return ret;
}
Exemple #3
0
int main() {
    tpl_node *tn;
    /* some meaningless test data */
    struct st s = {'z', {0.9, 0.8, 0.7, 0.6, 0.5 }};
    int j; 
    int i[ILEN] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10};
    int k[KLEN] = {100, 200, 300, 400, 500, 600, 700, 800};
    char a = '&';
    char b = 'x';
    const char *fmt;
    uint32_t num_fxlens, *fxlens;

    tn = tpl_map("cA(i#)S(cf#)A(ci#)", &a, i, ILEN, &s, FLEN, &b, k, KLEN);
    tpl_pack(tn,0);

    tpl_pack(tn,1);
    for(j=0; j < ILEN; j++) i[j]--;
    tpl_pack(tn,1);
    for(j=0; j < ILEN; j++) i[j]--;
    tpl_pack(tn,1);

    tpl_pack(tn,2);
    b++;
    for(j=0; j < KLEN; j++) k[j] += 50;  
    tpl_pack(tn,2);
    b++;
    for(j=0; j < KLEN; j++) k[j] += 50; 
    tpl_pack(tn,2);

    tpl_dump(tn,TPL_FILE,filename);
    tpl_free(tn);

    /* now peek at the fxlens */
    fmt = tpl_peek(TPL_FILE|TPL_FXLENS, filename, &num_fxlens, &fxlens);
    printf("format %s\n", fmt);
    printf("num_fxlens %u\n", num_fxlens);
    for(j=0; j<num_fxlens; j++) printf("fxlens[%u] %u\n", j, fxlens[j]);
    if (num_fxlens>0) free(fxlens);
    return(0);
}
Exemple #4
0
int main(int argc, char *argv[]) {
  int rc = -1;

  void *buf=NULL;
  size_t sz;
  if (tpl_gather(TPL_GATHER_BLOCKING, STDIN_FILENO, &buf, &sz) <= 0) goto done;

  /* peek into the saved image to see how many samples it has in it */
  uint32_t num_fxlens, *fxlens;
  char *fmt = tpl_peek(TPL_MEM|TPL_FXLENS, buf, sz, &num_fxlens, &fxlens);
  if ((!fmt) || (num_fxlens<1)) {fprintf(stderr,"invalid buffer\n"); goto done;}
  cfg.nsamples = fxlens[0];
  free(fxlens);

  /* make a buffer to load the PCM data into */
  /* TODO assert cfg.resolution == cfg.resolution in the image */
  size_t pcmlen = cfg.resolution * cfg.nsamples;
  int16_t *pcm;
  pcm = (int16_t*)malloc(pcmlen);
  if (!pcm) {fprintf(stderr,"out of memory\n"); goto done;}
  
  tpl_node *tn = tpl_map("iiij#", &cfg.sample_rate, &cfg.duration, &cfg.resolution, 
                         pcm, cfg.nsamples);
  tpl_load(tn, TPL_MEM, buf, sz);
  tpl_unpack(tn,0);
  tpl_free(tn);

  if (cfg.verbose) fprintf(stderr,"read the PCM file: "
                 "duration %u s, sample rate %u hz, resolution %u bits\n",
                 cfg.duration, cfg.sample_rate, cfg.resolution*8);

  play_pcm(argc, argv, pcm, pcmlen, cfg.sample_rate, cfg.verbose);

  /* TODO cycle if requested, reusing buf? */
  rc = 0;

 done:
  if (buf) free(buf);
  return rc;
}