Esempio n. 1
0
    def update(self):
        self.opacity = self.opacity / self.rate
        self.image.opacity = int(self.opacity)
        self.image.position = (self.x, self.y)

        if self.opacity < self.minopacity:
            signal('kill', self)
        elif time.time() - self.created_at > self.seconds_to_live:
            signal('kill', self)
def demonstrate_single(sample_rate, signal_params):
    signal_type = SignalType.from_string(signal_params['signal'])
    analog_signal = signal(signal_type, sample_rate, signal_params)

    widgets = demonstrate_signal(sample_rate, analog_signal,
                                 f'{signal_params["signal"].title()} Signal')
    return widgets
Esempio n. 3
0
    def on_mouse_press(self, x, y, button, modifiers):
        """
        Create a new bullet at the turret. (LEFT CLICK)
        Create a new gravity well. (RIGHT CLICK).
        """
        # left click make a bullet.
        if button == 1:

            if self.ballMeter.active:
                # signal that we are making a bullet.
                signal('shoot')
                self._bullet(x, y)

                # make a new X marks the spot.
                x = self._xmark(x, y)
            
        elif button == 4:
            self._gravity(x, y)
            self.ballMeter.add(3)
def demonstrate_polyharmonic(sample_rate, params_of_signals):
    analog_signals = []
    for signal_params in params_of_signals:
        signal_type = SignalType.from_string(signal_params['signal'])
        analog_signals.append(signal(signal_type, sample_rate, signal_params))
    polyharmonic_analog_signal = aggregate_to_polyharmonic_signal(
        analog_signals)

    widgets = demonstrate_signal(sample_rate, polyharmonic_analog_signal,
                                 'Polyharmonic Signal')
    return widgets
Esempio n. 5
0
    def custom_update(self):
        """
        Find the net force from all of the gravities to me!

        Then work out if I have hit a cat or something...

        also lay a trail as we go.
        """
        gravities = self.parent.gravities

        forcex,forcey = 0,0
        for gravity in gravities:
            _forcex, _forcey = gravity.force_on(self)
            forcex += _forcex
            forcey += _forcey

            # have I hit a vortex?
            if self.hit(gravity):
                signal('vortexhit', gravity=gravity, ball=self)

                # well if that is the case, then time for me to die.
                signal('kill', self)

        self.force = (forcex, forcey)

        # have I hit a cat?
        if self.hit(self.parent.cat):
            signal('cathit')
            # well I did. I should surely die now.
            signal('kill', self)

        # leave a trail but only if we are on the screen.
        if not self.parent.onscreen(self.x, self.y):
            return

        trail = X(self.x, self.y, self.parent.batch, self.parent.images['trail'])
        trail.minopacity = 1
        trail.rate = 1.01
        self.parent.actors.append(trail)
def demonstrate_modulation(sample_rate, signal_params,
                           modulating_signal_params):
    fig, axes = plt.subplots(2, sharex=True)
    fig.canvas.set_window_title('Advanced Signals Modelling')
    fig.suptitle('Amplitude & Frequency Modulation')

    n = range(sample_rate)

    modulating_signal_type = SignalType.from_string(
        modulating_signal_params['signal'])
    modulating_analog_signal = signal(modulating_signal_type, sample_rate,
                                      modulating_signal_params)
    sampled_modulating_signal = tuple(map(modulating_analog_signal, n))

    signal_type = SignalType.from_string(signal_params['signal'])
    analog_signal = signal_for_modulation(signal_type, sample_rate,
                                          signal_params)

    sampled_signal_with_amplitude_modulation = tuple(
        analog_signal(i, sampled_modulating_signal[i],
                      signal_params['frequency']) for i in n)

    accumulator = [0]
    sampled_signal_with_frequency_modulation = \
        tuple(analog_signal(1, signal_params['amplitude'],
                            signal_params['frequency'] + signal_params['frequency'] * sampled_modulating_signal[i], accumulator) for i in n)

    am_soundax = plt.axes([0.79, 0.54, 0.1, 0.04])
    fm_soundax = plt.axes([0.79, 0.12, 0.1, 0.04])

    widgets = [
        show_signal_modulation(axes[0], am_soundax, sample_rate, n,
                               sampled_signal_with_amplitude_modulation,
                               sampled_modulating_signal, 'AM'),
        show_signal_modulation(axes[1], fm_soundax, sample_rate, n,
                               sampled_signal_with_frequency_modulation,
                               sampled_modulating_signal, 'FM')
    ]

    return widgets
Esempio n. 7
0
try:
    path2 = Path(argv[2])
    path3 = Path(argv[3])

except:
    path2 = Path('queries/q1.wav')
    path3 = Path('queries/q2.wav')

freq2, samples2 = wavfile.read(path2)
freq3, samples3 = wavfile.read(path3)
# normalizacia
samples1 = samples1 / 2**15
samples2 = samples2 / 2**15
samples3 = samples3 / 2**15

pdf = PdfPages(path1.stem + '_nas.pdf')

fig = signal(samples1, freq1, 'gigantic', 'parking')
pdf.savefig(fig)
fig.clf()

fig = features(samples1, freq1, pdf=True)
pdf.savefig(fig)
fig.clf()

fig = scores(samples1, freq1, samples2, freq2, samples3, freq3, 'gigantic',
             'parking')
pdf.savefig(fig)
fig.clf()

pdf.close()