SHARE
TWEET

Continuous wave for HDSDR

a guest Jun 3rd, 2013 133 Never
  1. // See reddit rtlsdr post "HDSDR for Linux wo/Borip" for info
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. #define BLOCKSIZE 512
  7. #define NBLOCKS 10000
  8. #define BUFSIZE (BLOCKSIZE * NBLOCKS * 2)
  9. #define SDR_SAMPLERATE 1024000
  10.  
  11. main(int argc,char* argv[] ) {
  12.  
  13. char c;
  14. int i=0;
  15. char * buffer;
  16. FILE *fp;
  17.  
  18. struct headstruct {
  19.   char          riff[4];      
  20.   int32_t       chunksize;      
  21.   char          wave[4];        
  22.   char          fmt[4];        
  23.   int32_t       subchunksize;              
  24.   int16_t       format;    
  25.   int16_t       nchannels;      
  26.   int32_t       srate;          
  27.   int32_t       byteRate;  
  28.   int16_t       blockAlign;
  29.   int16_t       nbits;  
  30.   char          data[4];        
  31.   int32_t       ndata;        
  32. };
  33.  
  34. if (argc <=1) return;
  35.  
  36. struct headstruct iqhead = {"RIFF",BUFSIZE,"WAVE",
  37. "fmt ",16,1,2,SDR_SAMPLERATE,SDR_SAMPLERATE*2,2,8,"data",BUFSIZE};
  38.  
  39. fp = fopen(argv[1],"w");
  40. fwrite(&iqhead,sizeof(struct headstruct),1,fp);
  41. buffer = (char*) malloc(BLOCKSIZE*2);
  42. while( fread (buffer,2,BLOCKSIZE,stdin) > 0 ) {
  43.       fwrite(buffer,2,BLOCKSIZE,fp);
  44.       if (++i > NBLOCKS) {
  45.           fseek(fp,44,SEEK_SET);
  46.           i=0;
  47.           }
  48.       }
  49.    fclose(fp);
  50. }
RAW Paste Data
Top