Example #1
0
class SoundChart(Widget):
    def __init__(self):
        super(SoundChart, self).__init__()
        self.nc = NotesCollector()
        octaves = range(2, 5)
        self.sound_graph = self.ids.sound_graph
        # self.reset_plots()
        self.sound_plot = MeshLinePlot(color=[0, 0, 1, 1])
        # self.sound_plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
        self.sound_graph.add_plot(self.sound_plot)

        self.fft_graph = self.ids.fft_graph
        self.fft_plot = MeshLinePlot(color=[0, 1, 0, 1])
        # self.ddf_plot.points = [(x, cos(x / 10.)) for x in range(0, 101)]
        self.fft_graph.add_plot(self.fft_plot)

        for i in range(100):
            Clock.schedule_interval(self.update_graph, 1)

    def update_graph(self, *args):
        if self.nc.listen():
        # print(self.nc.rms_amplitude)
        # if self.nc.rms_amplitude > 0.03:
            points = self.nc.shorts[:len(self.nc.shorts)]
            self.sound_plot.points = zip(range(len(points)), points)
            if min(points) < self.sound_graph.ymin:
                self.sound_graph.ymin = min(points)
            if max(points) > self.sound_graph.ymax:
                self.sound_graph.ymax = max(points)
Example #2
0
    def __init__(self):
        super(SoundChart, self).__init__()
        self.nc = NotesCollector()
        octaves = range(2, 5)
        self.sound_graph = self.ids.sound_graph
        # self.reset_plots()
        self.sound_plot = MeshLinePlot(color=[0, 0, 1, 1])
        # self.sound_plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
        self.sound_graph.add_plot(self.sound_plot)

        self.fft_graph = self.ids.fft_graph
        self.fft_plot = MeshLinePlot(color=[0, 1, 0, 1])
        # self.ddf_plot.points = [(x, cos(x / 10.)) for x in range(0, 101)]
        self.fft_graph.add_plot(self.fft_plot)

        for i in range(100):
            Clock.schedule_interval(self.update_graph, 1)