Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delay #186

Merged
merged 5 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
by declaring explicitly np.array(some_ragged_list , dtype=object) or by handling the elements of ragged list indidually
([chipmuenk](https://github.com/chipmuenk))

- [Issue \#184](https://github.com/chipmuenk/pyfda/issues/184) "Filter type "Delay" can crash pyfda",
syntax errors in the UI description have been fixed. As the filter class does not produce a proper
delay, it is commented out in the configuratiion file for the time being
(see [Issue \#184](https://github.com/chipmuenk/pyfda/issues/185))


- When the gain k has been changed in the P/Z input widget, highlight the save button.

- Fix several small bugs and deprecation warnings in the Coeff input widget
Expand All @@ -22,13 +28,15 @@

(only available when [mplcursors](https://mplcursors.readthedocs.io/) module is installed and for matplotlib >= 3.1.)

- [PR \#183:](https://github.com/chipmuenk/pull/183) Replace simpleeval library by numexpr. This enables the creation of formula based stimuli
- [PR \#183:](https://github.com/chipmuenk/pull/183) Replace simpleeval library by numexpr.
This enables the creation of formula based stimuli, closing [Issue \#162](https://github.com/chipmuenk/issues/162)

- Add chirp stimulus

- The top level module name for generated Verilog netlists (Fixpoint tab) is now derived from the
specified file name. The module name is converted to lower cased and sanitized so that is only
contains alpha-numeric characters and '_'.
contains alpha-numeric characters and '_'. ([(Issue \#176)](https://github.com/chipmuenk/pyfda/issues/176),
"allow different module names for verilog export").

- Add CHANGELOG.md (this file)

Expand Down
136 changes: 54 additions & 82 deletions pyfda/filter_designs/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,11 @@ def __init__(self):
self.rt_dict = {
'COM': {'man': {'fo':('a', 'N'),
'msg':('a',
"<span>Enter desired filter order <b><i>N</i></b>, corner "
"frequencies of pass and stop band(s), <b><i>F<sub>PB</sub></i></b>"
"&nbsp; and <b><i>F<sub>SB</sub></i></b>&nbsp;, and relative weight "
"values <b><i>W&nbsp; </i></b> (1 ... 10<sup>6</sup>) to specify how well "
"the bands are approximated.</span>")
"<span>Enter desired number of delays <b><i>N</i></b>.</span>")
},
},
'LP': {'man':{'wspecs': ('u','W_PB','W_SB'),
'tspecs': ('u', {'frq':('a','F_PB','F_SB'),
'amp':('u','A_PB','A_SB')})
},
},
'HP': {'man':{'wspecs': ('u','W_SB','W_PB')},
},
'BP': {
},
'BS': {'man':{'wspecs': ('u','W_PB','W_SB','W_PB2'),
'tspecs': ('u', {'frq':('a','F_PB','F_SB','F_SB2','F_PB2'),
'amp':('u','A_PB','A_SB','A_PB2')})
}
}
'AP': {'man':{}
}
}

self.info_doc = []
Expand All @@ -93,51 +77,56 @@ def construct_UI(self):
These subwidgets are instantiated dynamically when needed in
select_filter.py using the handle to the filter instance, fb.fil_inst.
"""
self.lbl_delay = QLabel("Delays", self)
self.lbl_delay.setObjectName('wdg_lbl_delays')
self.led_delay = QLineEdit(self)
self.led_delay.setText(str(self.N))
self.led_delay.setObjectName('wdg_led_delay')
self.led_delay.setToolTip("Number of delays, N > 0 produces poles, N < 0 zeros.")

self.layHWin = QHBoxLayout()
self.layHWin.setObjectName('wdg_layGWin')
self.layHWin.addWidget(self.lbl_delay)
self.layHWin.addWidget(self.led_delay)
self.layHWin.setContentsMargins(0,0,0,0)
# Widget containing all subwidgets (cmbBoxes, Labels, lineEdits)
self.wdg_fil = QWidget(self)
self.wdg_fil.setObjectName('wdg_fil')
self.wdg_fil.setLayout(self.layHWin)

#----------------------------------------------------------------------
# SIGNALS & SLOTs
#----------------------------------------------------------------------
self.led_delay.editingFinished.connect(self._update_UI)
# fires when edited line looses focus or when RETURN is pressed
#----------------------------------------------------------------------

self._load_dict() # get initial / last setting from dictionary
self._update_UI()
pass
# =============================================================================
# self.lbl_delay = QLabel("Delays", self)
# self.lbl_delay.setObjectName('wdg_lbl_delays')
# self.led_delay = QLineEdit(self)
# self.led_delay.setText(str(self.N))
# self.led_delay.setObjectName('wdg_led_delay')
# self.led_delay.setToolTip("Number of delays, N > 0 produces poles, N < 0 zeros.")
#
# self.layHWin = QHBoxLayout()
# self.layHWin.setObjectName('wdg_layGWin')
# self.layHWin.addWidget(self.lbl_delay)
# self.layHWin.addWidget(self.led_delay)
# self.layHWin.setContentsMargins(0,0,0,0)
# # Widget containing all subwidgets (cmbBoxes, Labels, lineEdits)
# self.wdg_fil = QWidget(self)
# self.wdg_fil.setObjectName('wdg_fil')
# self.wdg_fil.setLayout(self.layHWin)
#
# #----------------------------------------------------------------------
# # SIGNALS & SLOTs
# #----------------------------------------------------------------------
# self.led_delay.editingFinished.connect(self._update_UI)
# # fires when edited line looses focus or when RETURN is pressed
# #----------------------------------------------------------------------
#
# self._load_dict() # get initial / last setting from dictionary
# self._update_UI()
# =============================================================================

def _update_UI(self):
"""
Update UI when line edit field is changed (here, only the text is read
and converted to integer) and store parameter settings in filter
dictionary
"""
self.N = safe_eval(self.led_delay.text(), self.N,
sign="poszero", return_type='int')
self.led_delay.setText(str(self.N))

if not 'wdg_fil' in fb.fil[0]:
fb.fil[0].update({'wdg_fil':{}})
fb.fil[0]['wdg_fil'].update({'delay':
{'N':self.N}
})

# sig_tx -> select_filter -> filter_specs
self.sig_tx.emit({'sender':__name__, 'filt_changed':'delay'})
# =============================================================================
# def _update_UI(self):
# """
# Update UI when line edit field is changed (here, only the text is read
# and converted to integer) and store parameter settings in filter
# dictionary
# """
# self.N = safe_eval(self.led_delay.text(), self.N,
# sign="poszero", return_type='int')
# self.led_delay.setText(str(self.N))
#
# if not 'wdg_fil' in fb.fil[0]:
# fb.fil[0].update({'wdg_fil':{}})
# fb.fil[0]['wdg_fil'].update({'delay':
# {'N':self.N}
# })
#
# # sig_tx -> select_filter -> filter_specs
# self.sig_tx.emit({'sender':__name__, 'filt_changed':'delay'})
# =============================================================================


def _load_dict(self):
Expand Down Expand Up @@ -179,32 +168,15 @@ def _save(self, fil_dict, arg=None):
"""
if arg is None:
arg = np.zeros(self.N)
#arg =[[0], np.zeros(self.N), 1] # crashes coeff tab
fil_save(fil_dict, arg, self.FRMT, __name__)

def LPman(self, fil_dict):
def APman(self, fil_dict):
self._get_params(fil_dict)
if not self._test_N():
return -1
self._save(fil_dict)


def HPman(self, fil_dict):
self._get_params(fil_dict)
if not self._test_N():
return -1
self._save(fil_dict)

def BPman(self, fil_dict):
self._get_params(fil_dict)
if not self._test_N():
return -1
self._save(fil_dict)

def BSman(self, fil_dict):
self._get_params(fil_dict)
if not self._test_N():
return -1
self._save(fil_dict)
#------------------------------------------------------------------------------

if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions pyfda/libs/pyfda_template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ version = 2
#------------------------------------------------------------------------------

#
IIR = [Bessel, Butter, Cheby1, Cheby2, ellip]
IIR = [Bessel, Butter, Cheby1, Cheby2, Ellip]
FIR = [Equiripple, Firwin]

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -127,7 +127,7 @@ ellip_zero
equiripple
firwin
ma
delay
# delay # still buggy

# --- Manual (both FIR and IIR) ---
manual
Expand All @@ -144,4 +144,4 @@ manual

# iir_df1 = ${Common:IIR}
fir_df = ${Common:FIR}
fx_delay = ['Equiripple', 'Delay']
# fx_delay = ['Equiripple', 'Delay'] # need to fix fx_delay and Delay modules
2 changes: 1 addition & 1 deletion pyfda/pyfda_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

# Dictionary with translations between short method names and long names for
# response types - the long name can be changed as you like, but don't change
# change the short name - it is used to construct the filter design method names
# the short name - it is used to construct the filter design method names
rt_names = {"LP":"Lowpass", "HP":"Highpass", "BP":"Bandpass",
"BS":"Bandstop", "AP":"Allpass", "MB":"Multiband",
"HIL":"Hilbert", "DIFF":"Differentiator"}
Expand Down