JIQFile
Open a existing IQ File from file system, with random access. Internally the IQFile object has a "reader position" initialized to 0 on start. The file can then be processed :
- sequentially using getSamples(count) where the reader position will be updated
- randomly using getSampleRange( from, to ) where any section of the file can be read.
The reader position can be retrieved by getOffset() or changed by goto(offset).
- IQData blocks are timestamped based on the intial timestamp (first sample) and offset. You can set the intial timestamp with setStartTimestamp()
- Unless samples are extracted from a WAV file, the sampling rate is not knwon and must be provided via setSampleRate()
object IQFile {
constructor IQFile();
bool open( string filename );
number getSampleCount();
bool goto( offset );
number getOffset();
IQData getSamples( count );
IQData getSampleRange( from, to );
setCenterFreq( center_MHz );
setSampleRate( sample_rate_hz );
number getSampleRate();
setStartTimestamp( t0_epoch );
}
Constructor IQFile
.open( filename )
The extension is used to recognize the file type. The following extensions are valid :
- .CF32 or .FC32 or .IQ32 : Complex float single precision (8 bytes by sample, 4 for I, 4 for Q)
- .CS16 : Complex signed integer : 16 bits
- .CS8 : Complex signed integer: 8 bits
- .WAV : wave files, max two channels (float only)
Example:
var filename = "/home/me/sdrcode/data/airdata.wav"
var f = new IQFile();
if (f.open(filename) == false) {
print('cannot open file ?');
exit();
}
.getSampleCount()
Example:
var samples = f.getSampleCount();
print(' We have ' + samples + ' samples.');
print(' file duration is ' + samples * 1.0 / f.getSampleRate() + ' secs.');
.getSamples()
Reads a fixed number of samples from the current reading position, and shift the reading position.
Example:
for (; ;) {
var IQ = f.getSamples(25000);
if( IQ.getLength() == 0 ) {
break ;
}
...
}
Last update: March 12, 2023