Bugfix in exporting measurement file to wave
This commit is contained in:
parent
e268a55680
commit
5e32b6264d
@ -5,6 +5,7 @@ from .lasp_imptube import *
|
||||
from .lasp_measurement import *
|
||||
from .lasp_octavefilter import *
|
||||
from .lasp_slm import *
|
||||
from .lasp_siggen import *
|
||||
from .lasp_weighcal import *
|
||||
from .wrappers import *
|
||||
from .device import AvType
|
||||
|
@ -21,7 +21,6 @@ __all__ = ['AvStream']
|
||||
video_x, video_y = 640, 480
|
||||
|
||||
|
||||
|
||||
class AvStream:
|
||||
"""Audio and video data stream, to which callbacks can be added for
|
||||
processing the data."""
|
||||
|
@ -593,7 +593,8 @@ class Measurement:
|
||||
return False
|
||||
|
||||
|
||||
def exportAsWave(self, fn=None, force=False, newsampwidth=None, normalize=True):
|
||||
def exportAsWave(self, fn=None, force=False, newsampwidth=None,
|
||||
normalize=True, channels=None):
|
||||
"""Export measurement file as wave. In case the measurement data is
|
||||
stored as floats, the values are scaled to the proper integer (PCM)
|
||||
data format.
|
||||
@ -621,7 +622,16 @@ class Measurement:
|
||||
if os.path.exists(fn) and not force:
|
||||
raise RuntimeError(f'File already exists: {fn}')
|
||||
|
||||
|
||||
if not np.isclose(self.samplerate%1,0):
|
||||
raise RuntimeError(f'Sample rates should be approximately integer for exporting to Wave to work')
|
||||
|
||||
# TODO: With VERY large files, this is not possible!
|
||||
data = self.rawData()
|
||||
if np.issubdtype(data.dtype, np.floating):
|
||||
if newsampwidth is None:
|
||||
raise ValueError('Newsampwidth parameter should be given for floating point raw data')
|
||||
|
||||
|
||||
if normalize:
|
||||
maxabs = np.max(np.abs(data), axis=0)
|
||||
@ -642,7 +652,8 @@ class Measurement:
|
||||
|
||||
data = (data*scalefac).astype(newtype)
|
||||
|
||||
wavfile.write(fn, self.samplerate, data)
|
||||
|
||||
wavfile.write(fn, int(self.samplerate), data)
|
||||
|
||||
@staticmethod
|
||||
def fromtxt(fn,
|
||||
|
Loading…
Reference in New Issue
Block a user