rcrath / wvtbl

Wavetable processor
GNU General Public License v3.0
0 stars 0 forks source link

log drum (a) sample produces wrong-length output #3

Closed rcrath closed 7 months ago

rcrath commented 7 months ago

I have a file with 44100 samples in it that is 1.5 seconds long, mono, 192 k and 16bit, oddly. I ran the script accepting all defaults. the concat file for the 94Hz wavecycles is 98304 samples long, or 0.512 seconds, which is therefore 48 2048 sample wavecycles long, therefore < 256 wavecycles needed for a serum wavetable. the closest_pitch concat file is 48152 samples long, half the size of the first and set to 1024 sample wavecycles. which produces a 256ms file that is 48 1024 wavecycles long.

the two kinds of output file should always be 2048*256=524288samples long, one with two wavecycles/frame and the other with a power of 2 wavecycle/frame. to get closer to the mode_frequency.Instead I have a 2048 output that is 196608 samples long and the "closest pitch" output is 98304 samples long.Can we fix this so that if there are not enough samples to create a full 256 frames, can the remainder be filled with denormalized "silence" samples with a random stepwise walk (i.e. drunken walk) all below the amplitude tolerance set up at the beginning, set to -60 dB in the variable amplitude_tolerance. Here is the relevant part of block 11.

block 11

make wavetables and cleanup

closest_pitch_folder = base hz_94_folder = base

data_closest_pitch, sr_closest_pitch = sf.read(output_path_pwr2, dtype='float32') total_samples_closest_pitch = len(data_closest_pitch)

data_94hz, sr_94hz = sf.read(output_path_2048, dtype='float32') total_samples_94hz = len(data_94hz)

Now you have the total number of samples for each file

print(f"Total samples in closest pitch file: {total_samples_closest_pitch}")

print(f"Total samples in 94Hz file: {total_samples_94hz}")

For 'closest_pitch' wavetable type

num_full_files_closest_pitch = math.ceil(total_samples_closest_pitch / 524288) split_and_save_wav_with_correct_padding(closest_pwr2_all_path, closest_pitch_folder, base, "closest_pitch", num_full_files_closest_pitch)

For '94Hz' wavetable type

num_full_files_94hz = math.ceil(total_samples_94hz / 524288) split_and_save_wav_with_correct_padding(hz_94_all_path, hz_94_folder, base, "94Hz", num_full_files_94hz)

Stop the spinner and print your statement

stop_spinner = True spinner_thread.join() # Wait for the spinner to finish

Use the 'concat_folder' variable as the directory where your wavetable files are stored

wavetable_files = [os.path.join(concat_folder, f) for f in os.listdir(concat_folder) if f.endswith('.wav')]

Normalize each wavetable file in the concat_folder

for wavetable_file in wavetable_files: normalize_audio_to_peak(wavetable_file, target_peak=-6)

print(f"All files in '{concat_folder}' have been normalized to peak -6 dBFS.")