I am wondering how to get the array of envelopes in every sound duration. Every sound duration means 0.79s in first sound event, 0.21s in second, 0.9s in third and so on.
The current code is extracted from get the array of envelopes:
debussy_file = "1-01-1.wav"
debussy, sr = librosa.load(debussy_file)
FRAME_SIZE = 1024
HOP_LENGTH = 512
def amplitude_envelope(signal, frame_size, hop_length):
"""Calculate the amplitude envelope of a signal with a given frame size nad hop length."""
amplitude_envelope = []
# calculate amplitude envelope for each frame
for i in range(0, len(signal), hop_length):
amplitude_envelope_current_frame = max(signal[i:i+frame_size])
amplitude_envelope.append(amplitude_envelope_current_frame)
return np.array(amplitude_envelope)
# number of frames in amplitude envelope
ae_debussy = amplitude_envelope(debussy, FRAME_SIZE, HOP_LENGTH)
#Visualising amplitude envelope
frames = range(len(ae_debussy))
t = librosa.frames_to_time(frames, hop_length=HOP_LENGTH)
ax = plt.subplot(3, 1, 1)
librosa.display.waveplot(debussy, alpha=0.5)
plt.plot(t, ae_debussy, color="r")
plt.title("Debusy")
It shows like this.
But I want to see the value in every duration of sound event(I already have the duration information), not the whole audio.
Perhaps is an easy question, but I don't know how to correct from the code.
I appreciate it if someone is willing to help me.!
P.s. If I need to explain more, plz tell me! Thx