Fixing drifting frames from samples (#26)

* Merge from main (#16)

* Modified NormalizedAmplitudeToNumber and added FloatArrayToGraph (#8)

* added my 2 nodes

* fixed broken new node mod

got it working again

* modifications example

modified the normalized to float/int node to include an addative input, with ceiling control and threshold activation.

added float array to graph node

* Add Load VHS Audio node (#13)

Add a node to load audio from Video Helper Suite, which exports a lambda
for lazy loading.

Co-authored-by: Isaac Emesowum <isaac@emesowum.com>

* Return the limit of frames used rather than total if a limit is specificed in the AudioToFFTs

* Clean up duplicate function

* Updated basic example

---------

Co-authored-by: PhotoniX <master@ascendism.com>
Co-authored-by: iemesowum <isaac.emesowum@gmail.com>
Co-authored-by: Isaac Emesowum <isaac@emesowum.com>

* Updating the two amplitude example

* Updated full example

* Updated so that LoadAudio no longer name collison with ComfyUI's "LoadAudio":

- Removed "LoadAudio" as a node.  Instead use LoadVHSAudio or AudioToAudioData to either load from vhs node suite or from ComfyUI's LoadAudio
- Changed the "AUDIO" type to "AUDIO_DATA" type to not clash with ComfyUI's "AUDIO" type

* Removed LoadVHSAudio. No longer needed as "AudioToAudioData" can fulfill the role for both the VHS audio loading and the regular one

* Updating the examples

* Fixing sample frame drift due to rounding up errors. Instead, keep rounding through each loop.

---------

Co-authored-by: PhotoniX <master@ascendism.com>
Co-authored-by: iemesowum <isaac.emesowum@gmail.com>
Co-authored-by: Isaac Emesowum <isaac@emesowum.com>
This commit is contained in:
a1lazydog
2024-08-07 20:04:08 -07:00
committed by GitHub
co-authored by PhotoniX iemesowum Isaac Emesowum
parent adbc4b6fff
commit fdf8ddd0f6
+4 -2
View File
@@ -85,7 +85,7 @@ class AudioToFFTs:
# Number of samples in the audio data
total_samples = len(audio_data)
samples_per_frame = int(np.ceil(audio.sample_rate / frames_per_second))
samples_per_frame = audio.sample_rate / frames_per_second
# Calculate the number of frames
total_frames = int(np.ceil(total_samples / samples_per_frame))
@@ -112,8 +112,10 @@ class AudioToFFTs:
if i_next >= total_samples:
i_next = total_samples
i_current = i * samples_per_frame
# Extract the current frame of audio data
frame = audio_data[i * samples_per_frame : i_next]
frame = audio_data[round(i_current) : round(i_next)]
ffts.append(AudioFFTData(frame, audio.sample_rate))