File IO#
in pysndlib.clm
- file2ndarray(filename, channel=None, beg=None, size=None)#
return an ndarray with samples from file and the sample rate of the data
- Parameters:
filename – filename
channel – if None, will read all channels, otherwise just channel specified
beg – beginning positions to read in samples
size – size in samples to read
- Returns:
tuple of np.ndarray and sample rate
- Return type:
tuple
- ndarray2file(filename, arr, size=None, sr=None, sample_type=None, header_type=None, comment=None)#
write an ndarray of samples to file
- Parameters:
filename – name of file
arr – np.ndarray of samples
size – number of samples to write. if None write all
sr – sample rate of file to write
sample_type – type of sample type to use. defaults to clm.sample_type
header_type – header of sample type to use. defaults to clm.header_type
- Returns:
length in samples of file
- Return type:
int