diff --git a/util/audio.py b/util/audio.py index 0d6705c..fdbe40d 100644 --- a/util/audio.py +++ b/util/audio.py @@ -59,31 +59,14 @@ class AudioProcess: self.thread.join() def pyaudio_callback(self, _in_data, _frame_count, _time_info, _status): - # samples, read = _in_data, _frame_count - # audio_data = np.fromstring(in_data, dtype=np.float32) samples = np.fromstring(_in_data, dtype=np.float32, count=_frame_count) read = _frame_count is_beat = self.tempo(samples) if is_beat: with self.lock: - # print(self.tempo.get) self.is_beat = True - # samples += click - # print("tick") # avoid print in audio callback audiobuf = samples.tobytes() if read < self.hop_s: return (audiobuf, pa.paComplete) return (audiobuf, pa.paContinue) - - # self.stop = False - # self.thread = threading.Thread(name="AudioProcess", target=self.process) - # self.thread.start() - - # def process(self): - # while not self.stop: - # samples = self.dev.record(self.hop_s, self.rate, 2) - # mono = samples.sum(axis=1) - # is_beat = self.tempo(samples) - - # if is_beat: diff --git a/util/transform.py b/util/transform.py index 72ea3b8..1fbf751 100644 --- a/util/transform.py +++ b/util/transform.py @@ -23,8 +23,10 @@ def transform_bounce( current_x_factor = random.uniform(x_factor[0], x_factor[1]) current_y_factor = random.uniform(y_factor[0], y_factor[1]) - (size_x, size_y), is_beat = yield (bounds.centerx, bounds.centery) + pos_x = bounds.centerx + pos_y = bounds.centery while True: + (size_x, size_y), is_beat = yield (pos_x, pos_y) pos_x = int( math.cos(current_x_factor * phase) * (bounds.width - size_x) // 2 + bounds.centerx @@ -37,7 +39,6 @@ def transform_bounce( phase += current_velocity / 180 * math.pi if on_beat_random_phase and is_beat: phase += random.randrange(0, 360) - (size_x, size_y), _ = yield (pos_x, pos_y) def transform_oscillate( @@ -49,9 +50,12 @@ def transform_oscillate( pos_y = float(initial_pos[1] if initial_pos[1] > 0 else bounds.top) direction = "+" - (size_x, size_y), _ = yield (bounds.left, bounds.top) + pos_x = bounds.left + pos_y = bounds.top while True: + (size_x, size_y), _ = yield (int(pos_x), int(pos_y)) + range_x = bounds.width - size_x range_y = bounds.height - size_y @@ -72,8 +76,6 @@ def transform_oscillate( elif (inc_x and (pos_x < inc_x)) or (inc_y and (pos_y < inc_y)): direction = "+" - (size_x, size_y), _ = yield (int(pos_x), int(pos_y)) - def transform_falling( bounds: pg.Rect, @@ -85,11 +87,12 @@ def transform_falling( pos_x = float(initial_pos[0]) pos_y = float(initial_pos[1]) - (_, size_y), is_beat = yield (bounds.left, bounds.top) - velocity = initial_velocity + pos_x = bounds.left + pos_y = bounds.top while True: + (_, size_y), is_beat = yield (int(pos_x), int(pos_y)) range_y = bounds.height - size_y pos_y += velocity @@ -98,5 +101,3 @@ def transform_falling( if (pos_y > range_y) or (on_beat_reset and is_beat): pos_y = initial_pos[1] velocity = initial_velocity - - (_, size_y), is_beat = yield (int(pos_x), int(pos_y))