-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove numpy, separate eval and plotting
- Loading branch information
Showing
7 changed files
with
143 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from camilladsp_plot.plot_filters import plot_filters, plot_filter, plot_filterstep, plot_all_filtersteps | ||
from camilladsp_plot.plot_pipeline import plot_pipeline | ||
from camilladsp_plot.eval_filterconfig import eval_filter, eval_filterstep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import math | ||
import cmath | ||
from camilladsp_plot.filters import Biquad, BiquadCombo, Conv, DiffEq, Gain | ||
|
||
|
||
def logspace(minval, maxval, npoints): | ||
logmin = math.log10(minval) | ||
logmax = math.log10(maxval) | ||
perstep = (logmax-logmin)/npoints | ||
values = [10.0**(logmin+n*perstep) for n in range(npoints)] | ||
return values | ||
|
||
def eval_filter(filterconf, name=None, samplerate=44100, npoints=1000): | ||
fvect = logspace(1.0, samplerate*0.95/2.0, npoints) | ||
result = {"name": name, "samplerate": samplerate, "f": fvect } | ||
if name is None: | ||
name = "unnamed {}".format(filterconf['type']) | ||
if filterconf['type'] in ('Biquad', 'DiffEq', 'BiquadCombo'): | ||
if filterconf['type'] == 'DiffEq': | ||
currfilt = DiffEq(filterconf['parameters'], samplerate) | ||
elif filterconf['type'] == 'BiquadCombo': | ||
currfilt = BiquadCombo(filterconf['parameters'], samplerate) | ||
else: | ||
currfilt = Biquad(filterconf['parameters'], samplerate) | ||
|
||
_fplot, magn, phase = currfilt.gain_and_phase(fvect) | ||
result["magnitude"] = magn | ||
result["phase"] = phase | ||
elif filterconf['type'] == 'Conv': | ||
if 'parameters' in filterconf: | ||
currfilt = Conv(filterconf['parameters'], samplerate) | ||
else: | ||
currfilt = Conv(None, samplerate) | ||
_ftemp, magn, phase = currfilt.gain_and_phase(fvect) | ||
t, impulse = currfilt.get_impulse() | ||
result["magnitude"] = magn | ||
result["phase"] = phase | ||
result["time"] = t | ||
result["impulse"] = impulse | ||
return result | ||
|
||
def eval_filterstep(conf, pipelineindex, name="filterstep", npoints=1000, toimage=False): | ||
|
||
samplerate = conf['devices']['samplerate'] | ||
fvect = logspace(1.0, samplerate*0.95/2.0, npoints) | ||
pipelinestep = conf['pipeline'][pipelineindex] | ||
totcgain=[1.0 for n in range(npoints)] | ||
for filt in pipelinestep['names']: | ||
filterconf = conf['filters'][filt] | ||
if filterconf['type'] == 'DiffEq': | ||
currfilt = DiffEq(filterconf['parameters'], samplerate) | ||
elif filterconf['type'] == 'BiquadCombo': | ||
currfilt = BiquadCombo(filterconf['parameters'], samplerate) | ||
elif filterconf['type'] == "Biquad": | ||
currfilt = Biquad(filterconf['parameters'], samplerate) | ||
elif filterconf['type'] == "Conv": | ||
currfilt = Conv(filterconf['parameters'], samplerate) | ||
elif filterconf['type'] == "Gain": | ||
currfilt = Gain(filterconf['parameters']) | ||
else: | ||
continue | ||
_, cgainstep = currfilt.complex_gain(fvect) | ||
totcgain = [cg * cgstep for (cg, cgstep) in zip(totcgain, cgainstep)] | ||
gain = [20.0 * math.log10(abs(cg) + 1e-15) for cg in totcgain] | ||
phase = [180 / math.pi * cmath.phase(cg) for cg in totcgain] | ||
result = {"name": name, "samplerate": samplerate, "f": fvect, "magnitude": gain, "phase": phase} | ||
return result | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
# show_config.py | ||
|
||
import numpy as np | ||
import numpy.fft as fft | ||
import csv | ||
import yaml | ||
import sys | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters