The piano tone captured by the iPhone voice memo was converted to wav and displayed as a waveform (navy).
I made this script.signal.stft/istft and displayed the waveform again with matplotlib (aquamarine).
The corresponding code and output are as follows:
import numpy as np import wave as wave import scipy.signal as sp import matplotlib.pyplot as plt import math file = wave.open ('/Users/***/Desktop/Musica/doremi.wav') data = file.readframes (file.getnframes ()) data = np.frombuffer (data, dtype = np.int16) duration = file.getnframes () /file.getframerate () x1_list =  for i in range (len (data)): x1_list.append (duration * i/len (data)) x1 = np.array (x1_list) y1 = np.array (data) f, t, stft_i = sp.stft (data, fs = file.getframerate (), window ='hann', nperseg = 512, noverlap = 256) stft_i = 10 * np.log (np.abs (stft_i)) t, istft_i = sp.istft (stft_i, fs = file.getframerate (), window ='hann', nperseg = 512, noverlap = 256) x2 = t y2 = istft_i plt.title ('Spectrogram of DoReMi') plt.xlabel ('Times (s)') plt.ylabel ('Intensity (Pa)') plt.plot (x1, y1, color ='navy') plt.plot (x2, y2, color ='aquamarine') plt.show ()
The time of the re-synthesized waveform is doubled. Unlike x1, t here is a complex signal, but why does the total length change?Question ②
Intensity is completely different from before Fourier transform/inverse transform in the first place. What was wrong?
I'm sorry for the amateur question, but if there are any points that you can help, please teach me.
Answer # 1
Between conversion and inverse conversion
stft_i = 10 * np.log (np.abs (stft_i))
Isn't it because it contains?
In particular, it seems that the inverse conversion is in a flat shape because the volume is crushed as a whole by log.
- how to specify a text file after a python file at the windows command prompt
- [python3] i want to scroll the screen after screen transition
- python - about the presence or absence of () after print
- python - after sorting by date, how to sort by name while keeping it
- python - how to read the record information after 10 seconds
- python - i want to make the header one row after pivoting with multiple columns in pandas
- python - pandas replacing values after a few seconds
- waveform display of voice data recorded with voice memo of python/iphone
- python - even if i try to display the waveform display of audio data with matplotlib, the dimensions of (x, y) do not match beca
- i want to add special tags before and after python json
- python - i want to get only the value of the first stage (after roipool) of faster r-cnn of torchvision
- i want to wait until the next process can be performed after executing the process in python
- python - even if it starts after updating to spyder4, it goes down immediately
- python fourier series the expanded formula is output to the graph
- python - i can't find some url paths after deploying django
- python 3x - error after changing to csv file
- python - [beginner] i want to delete line breaks/n after reading and outputting a file
- python - elements cannot be acquired after screen transition in selenium
- python - merge after pandas pivot
- python : I want to create and display multiple box heeds in Seaborn
- python : Problems with MATPLOTLIB graphs display in the PyQT5 window
- Python Seaborn Heatmaps: Formatting Heat Card Cell
- python : A certain number of columns from the CSV file for schedule
- python : How to create a schedule from the data received?
- python : How to implement the construction of a graph from the CSV file data?
- python : How to color the segments of the graph with different colors from the list of values?
- python : Build graphs from the TXT file
- python : Building two charts on one schedule
- python : ValueRerror: Operands Could Not Be Broadcast Together With Shapes -How does the plot work?