Let SLM work without filterbank.
This commit is contained in:
parent
2e83942771
commit
9f96858de1
@ -12,7 +12,7 @@
|
||||
#include "lasp_mat.h"
|
||||
|
||||
#define MAX_SOS_FILTER_BANK_SIZE 40
|
||||
#define MAX_SOS_FILTER_BANK_NSECTIONS 6
|
||||
#define MAX_SOS_FILTER_BANK_NSECTIONS 10
|
||||
|
||||
typedef struct Sosfilterbank Sosfilterbank;
|
||||
|
||||
|
@ -5,7 +5,7 @@ Description: Read data from image stream and record sound at the same time
|
||||
"""
|
||||
#import cv2 as cv
|
||||
from .lasp_atomic import Atomic
|
||||
from threading import Thread, Condition, Lock
|
||||
from threading import Thread, Lock
|
||||
import numpy as np
|
||||
|
||||
import time
|
||||
@ -94,7 +94,6 @@ class AvStream:
|
||||
self._callbacklock = Lock()
|
||||
|
||||
self._running = Atomic(False)
|
||||
self._running_cond = Condition()
|
||||
|
||||
self._video = video
|
||||
self._video_started = Atomic(False)
|
||||
@ -187,8 +186,10 @@ class AvStream:
|
||||
# present, and there should be output callbacks, we explicitly set
|
||||
# the output buffer to zero
|
||||
noutput_cb = len(self._callbacks[AvType.audio_output])
|
||||
|
||||
shouldhaveoutput = (self.avtype == AvType.audio_output or
|
||||
self.daqconfig.duplex_mode)
|
||||
|
||||
if noutput_cb == 0 and shouldhaveoutput and outdata is not None:
|
||||
outdata[:, :] = 0
|
||||
|
||||
@ -212,14 +213,15 @@ class AvStream:
|
||||
|
||||
def stop(self):
|
||||
self._running <<= False
|
||||
with self._running_cond:
|
||||
self._running_cond.notify()
|
||||
|
||||
if self._video:
|
||||
self._videothread.join()
|
||||
self._videothread = None
|
||||
|
||||
self._aframectr <<= 0
|
||||
self._vframectr <<= 0
|
||||
self._video_started <<= False
|
||||
|
||||
self._audiobackend.stop()
|
||||
self._audiobackend = None
|
||||
|
||||
|
@ -31,7 +31,7 @@ class SLM:
|
||||
|
||||
def __init__(self,
|
||||
fs,
|
||||
fbdesigner,
|
||||
fbdesigner=None,
|
||||
tw=TimeWeighting.fast,
|
||||
fw=FreqWeighting.A,
|
||||
xmin = None,
|
||||
@ -58,10 +58,16 @@ class SLM:
|
||||
"""
|
||||
|
||||
self.fbdesigner = fbdesigner
|
||||
if xmin is None:
|
||||
if xmin is None and fbdesigner is not None:
|
||||
xmin = fbdesigner.xs[0]
|
||||
if xmax is None:
|
||||
elif fbdesigner is None:
|
||||
xmin = 0
|
||||
|
||||
if xmax is None and self.fbdesigner is not None:
|
||||
xmax = fbdesigner.xs[-1]
|
||||
elif fbdesigner is None:
|
||||
xmax = 0
|
||||
|
||||
self.xs = list(range(xmin, xmax + 1))
|
||||
|
||||
nfilters = len(self.xs)
|
||||
@ -81,12 +87,16 @@ class SLM:
|
||||
# 'Probe' size of filter coefficients
|
||||
self.nom_txt = []
|
||||
|
||||
# This is a bit of a hack, as the 5 is hard-encoded here, but should in
|
||||
# fact be coming from somewhere else..
|
||||
sos_overall = np.array([1,0,0,1,0,0]*5, dtype=float)
|
||||
|
||||
if fbdesigner is not None:
|
||||
assert fbdesigner.fs == fs
|
||||
sos0 = fbdesigner.createSOSFilter(self.xs[0]).flatten()
|
||||
sos_firstx = fbdesigner.createSOSFilter(self.xs[0]).flatten()
|
||||
self.nom_txt.append(fbdesigner.nominal_txt(self.xs[0]))
|
||||
sos = np.empty((nfilters, sos0.size), dtype=float, order='C')
|
||||
sos[0, :] = sos0
|
||||
sos = np.empty((nfilters, sos_firstx.size), dtype=float, order='C')
|
||||
sos[0, :] = sos_firstx
|
||||
|
||||
for i, x in enumerate(self.xs[1:]):
|
||||
sos[i+1, :] = fbdesigner.createSOSFilter(x).flatten()
|
||||
@ -95,16 +105,17 @@ class SLM:
|
||||
if include_overall:
|
||||
# Create a unit impulse response filter, every third index equals
|
||||
# 1, so b0 = 1 and a0 is 1 (by definition)
|
||||
sos[-1,:] = 0
|
||||
sos[-1,::3] = 1
|
||||
# a0 = 1, b0 = 1, rest is zero
|
||||
sos[-1,:] = sos_overall
|
||||
self.nom_txt.append('overall')
|
||||
|
||||
else:
|
||||
# No filterbank, means we do only compute the overall values. This
|
||||
# means that in case of include_overall, it creates two overall
|
||||
# channels. That would be confusing, so we do not allow it.
|
||||
assert include_overall == False
|
||||
sos = None
|
||||
self.nom_txt.append('overall')
|
||||
if include_overall:
|
||||
sos = sos_overall[np.newaxis,:]
|
||||
self.nom_txt.append('overall')
|
||||
|
||||
self.slm = pyxSlm(prefilter, sos,
|
||||
fs, tw[0], level_ref_value)
|
||||
|
Loading…
Reference in New Issue
Block a user