Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // See reddit rtlsdr post "HDSDR for Linux wo/Borip" for info
- #include <stdio.h>
- #include <stdlib.h>
- #define BLOCKSIZE 512
- #define NBLOCKS 10000
- #define BUFSIZE (BLOCKSIZE * NBLOCKS * 2)
- #define SDR_SAMPLERATE 1024000
- main(int argc,char* argv[] ) {
- char c;
- int i=0;
- char * buffer;
- FILE *fp;
- struct headstruct {
- char riff[4];
- int32_t chunksize;
- char wave[4];
- char fmt[4];
- int32_t subchunksize;
- int16_t format;
- int16_t nchannels;
- int32_t srate;
- int32_t byteRate;
- int16_t blockAlign;
- int16_t nbits;
- char data[4];
- int32_t ndata;
- };
- if (argc <=1) return;
- struct headstruct iqhead = {"RIFF",BUFSIZE,"WAVE",
- "fmt ",16,1,2,SDR_SAMPLERATE,SDR_SAMPLERATE*2,2,8,"data",BUFSIZE};
- fp = fopen(argv[1],"w");
- fwrite(&iqhead,sizeof(struct headstruct),1,fp);
- buffer = (char*) malloc(BLOCKSIZE*2);
- while( fread (buffer,2,BLOCKSIZE,stdin) > 0 ) {
- fwrite(buffer,2,BLOCKSIZE,fp);
- if (++i > NBLOCKS) {
- fseek(fp,44,SEEK_SET);
- i=0;
- }
- }
- fclose(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement