Reputation: 85
For now, I have code that shows the magnitude and its frequency
def plot_fft(p, xf, fs, notes, dimensions=(960, 540)):
xf_bet=xf-160
layout = go.Layout(
title="frequency spectrum",
autosize=False,
width=dimensions[0],
height=dimensions[1],
xaxis_title="Frequency (note)",
yaxis_title="Magnitude",
font={'size': 24}
)
fig = go.Figure(layout=layout,
layout_xaxis_range=[FREQ_MIN, FREQ_MAX],
layout_yaxis_range=[0, 1]
)
fig.add_trace(go.Scatter(
x=xf_bet,
y=p))
for note in notes:
# Dodanie wartości częstotliwości do nazwy dźwięku
note_name_with_freq = f"{note[1]} ({round(note[0]-160, 2)} Hz)"
fig.add_annotation(x=note[0] + 10, y=note[2],
text=note_name_with_freq,
font={'size': 48},
showarrow=False)
return fig
The idea of the program is to create many plots and ultimately combine them into an MP4
Upvotes: 0
Views: 59
Reputation: 833
I can think of two ways:
Simply create the individual sine waves. Each frequency wave is then
y = A * sin(2 * np.pi * f + phi)
with amplitude A, frequency f and phase-shift phi.
Upvotes: 1