%23%20gallery_category%3A%20Allpass%20FDNs%0A%23%20gallery_title%3A%20Homogeneous%20allpass%20FDN%20(SISO)%0A%23%20gallery_description%3A%20Build%20a%20single-input%2C%20single-output%20homogeneous%20allpass%20FDN%20and%20validate%20its%20allpass%20response.%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.24.0%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20pyFDN)%3A%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%23%20Homogeneous%20allpass%20FDN%20(SISO)%0A%0A%20%20%20%20Example%20for%20an%20allpass%20FDN%20with%20**homogeneous%20decay**%20so%20that%20all%20poles%20have%20the%20same%20decay%20rate.%0A%0A%20%20%20%20See%20%7BpyFDN.paper_link(%22Allpass_Feedback_Delay_Networks%22)%7D.%0A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20numpy%20as%20np%0A%0A%20%20%20%20import%20pyFDN%0A%0A%20%20%20%20np.random.seed(1)%0A%20%20%20%20fs%20%3D%2048000%0A%20%20%20%20return%20fs%2C%20np%2C%20pyFDN%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Build%20homogeneous%20allpass%20FDN%0A%0A%20%20%20%20Random%20delays%2C%20gain%20matrix%20**G**%2C%20random%20admissible%20diagonal%20**X**%2C%20then%20**homogeneous_allpass_fdn(G%2C%20X)**.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(fs%2C%20np%2C%20pyFDN)%3A%0A%20%20%20%20N%20%3D%206%0A%20%20%20%20delays%20%3D%20np.random.randint(300%2C%20700%2C%20size%3DN)%0A%20%20%20%20g%20%3D%20pyFDN.rt_to_gain_per_sample(0.5%2C%20fs)%0A%20%20%20%20G%20%3D%20np.diag(g**delays)%0A%0A%20%20%20%20X%20%3D%20pyFDN.rand_admissible_homogeneous_allpass(G%2C%20(0.7%2C%200.99))%0A%20%20%20%20A%2C%20b%2C%20c%2C%20d%2C%20_U%20%3D%20pyFDN.homogeneous_allpass_fdn(G%2C%20X%2C%20verbose%3DFalse)%0A%20%20%20%20return%20A%2C%20b%2C%20c%2C%20d%2C%20delays%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Test%3A%20uniallpass%0A%0A%20%20%20%20Check%20that%20the%20system%20is%20uniallpass%2C%20i.e.%2C%20allpass%20for%20any%20delays.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(A%2C%20b%2C%20c%2C%20d%2C%20pyFDN)%3A%0A%20%20%20%20is_a%2C%20_%20%3D%20pyFDN.is_uniallpass(A%2C%20b%2C%20c%2C%20d%2C%20tol%3D1e-7)%0A%20%20%20%20assert%20is_a%2C%20%22Expected%20allpass%20for%20homogeneous%20FDN%20with%20these%20delays%22%0A%20%20%20%20print(%22is_allpass%3A%20OK%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Plot%20system%20matrix%0A%0A%20%20%20%20Visualize%20**%5BA%2C%20b%3B%20c%2C%20d%5D**%20as%202%C3%972%20block%20heatmaps.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(A%2C%20b%2C%20c%2C%20d%2C%20pyFDN)%3A%0A%20%20%20%20pyFDN.plot_system_matrix(A%2C%20b%2C%20c%2C%20d)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Impulse%20response%0A%0A%20%20%20%20Compute%20the%20impulse%20response%20with%20**dss_to_impz**%20(SISO%3A%20single%20input%2Foutput).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(A%2C%20b%2C%20c%2C%20d%2C%20delays%2C%20fs%2C%20pyFDN)%3A%0A%20%20%20%20impulse_response%20%3D%20pyFDN.dss_to_impz(2%20*%20fs%2C%20delays%2C%20A%2C%20b%2C%20c%2C%20d).squeeze()%0A%20%20%20%20return%20(impulse_response%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Time%20domain%20and%20play%0A%0A%20%20%20%20Plot%20the%20impulse%20response%20in%20the%20time%20domain%20and%20use%20the%20audio%20widget%20to%20play%20it.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(fs%2C%20impulse_response%2C%20mo%2C%20pyFDN)%3A%0A%20%20%20%20_fig%20%3D%20pyFDN.plot_impulse_response(%0A%20%20%20%20%20%20%20%20impulse_response%2C%0A%20%20%20%20%20%20%20%20fs%3Dfs%2C%0A%20%20%20%20%20%20%20%20title%3D%22Homogeneous%20allpass%20FDN%20%E2%80%94%20impulse%20response%22%2C%0A%20%20%20%20)%0A%0A%20%20%20%20mo.vstack(%5B_fig%2C%20mo.audio(impulse_response%2C%20fs)%5D)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
1b358cbf8cc46311ec361048d6e32740