Commit 738ba039 authored by Robozman's avatar Robozman

MERGEEEEEEE...and diabled plotting code

parent 559f5505
......@@ -9,8 +9,8 @@ import math
import msaf
import librosa
import sys
from functools import lru_cache
import pickle
import cv2
import librosaToWave
import generate_waves
......@@ -68,15 +68,21 @@ elif load_from_file == True:
plt.ion()
fig = plt.figure()
fft_plot = fig.add_subplot(111)
fft_plot = fig.add_subplot(121)
#image = fig.add_subplot(122)
sounddevice.play(wav_data, rate)
timestep = .01
timestep = 1/24
t = time.time()
origin = time.time()
nextBeat = 0
cap = cv2.VideoCapture(0)
while t - origin < len(wav_data) / rate:
ret, frame = cap.read()
if load_from_file == True:
try:
if time.time() - origin >= beat_times[nextBeat]:
......@@ -98,12 +104,29 @@ while t - origin < len(wav_data) / rate:
transform = np.abs(np.fft.fft(second[:]))
plot_transform = np.fft.fftshift(transform)
peaks, _ = signal.find_peaks(plot_transform, prominence=20)
plot = True
max_val = np.amax(transform)
hsv_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
h, s, v = cv2.split(hsv_frame)
#v = np.where(True, 255 * (350 - max_val) / 350, 255)
#v *= math.floor((350 - max_val) / 350)
np.multiply(v, (350 - max_val) / 350, out=v, casting='unsafe')
final_hsv = cv2.merge((h, s, v))
img = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)
#image.xticks([])
#image.ytacks([])
#image.show()
cv2.imshow('frame', img)
cv2.waitKey(1)
peaks, _ = signal.find_peaks(transform, prominence=20)
plot = False
if plot is True:
print(peaks)
fft_plot.clear()
if load_from_file == True:
fft_plot.plot(plot_transform) # np.abs(np.fft.fftshift(np.fft.fft(second[:])))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment