def update_response(self): """ Update the response plot """ speaker = VentedSpeaker(self.current_driver, self.current_box) freqs, amplitude = speaker.frequency_response() self.amplitude_line.set_xdata(freqs) self.amplitude_line.set_ydata(amplitude) manufacturer = self.current_driver.manufacturer model = self.current_driver.model box_volume = 1e3*self.current_box.Vab box_tuning = self.current_box.fb label = '{0} {1} in {2:2g}l / {3}Hz'.format( manufacturer, model, box_volume, box_tuning) self.amplitude_line.set_label(label) self.amplitude_axes.legend(loc='lower right') self.canvas.draw()
def add_new_response(self): """ Add an additional response to the plot """ speaker = VentedSpeaker(self.current_driver, self.current_box) freqs, amplitude = speaker.frequency_response() self.amplitude_line, = self.amplitude_axes.semilogx( freqs, amplitude) manufacturer = self.current_driver.manufacturer model = self.current_driver.model box_volume = 1e3*self.current_box.Vab box_tuning = self.current_box.fb label = '{0} {1} in {2:2g}l / {3}Hz'.format( manufacturer, model, box_volume, box_tuning) self.amplitude_line.set_label(label) self.amplitude_axes.legend(loc='lower right') self.set_plot_options() self.canvas.draw()
def test_cutoff_calculation(self): driver_db = driver_database.DriverDB.from_file('driver_db.json') driver = driver_db[0] box = vented_box.VentedBox(Vab=90.0, fb=43.0, Ql=20.0) speaker = VentedSpeaker(driver, box) self.assertAlmostEqual(speaker.f_3(), 36.9606852)