shared-utils
Contains useful utilities like random number generator for ints or floats in min - max range inclusive
Available at https://github.com/scottstensland/shared-utils
synthesize an audio buffer with random noise OR sinusoidal curve
// ------------ populate buffer with sin curve ------------ // // var SIZE_BUFFER_SOURCE = 5;var SIZE_BUFFER_SOURCE = 256;// var SIZE_BUFFER_SOURCE = 4096;// var SIZE_BUFFER_SOURCE = 16384; var samples_per_cycle = 64; var source_obj = {}; // we populate its buffer then save to output WAV file var target_obj = {}; // then read back WAV file to populate this target buffer then do curve diff to confirm curves match source_obj = audio_utils;
synthesize an audio buffer with random noise
var shared_utils = ;var path = ; shared_utils; // comment out if U want fresh random sequence for each run // otherwise random sequence repeats across subsequent runs of this script var SIZE_BUFFER_SOURCE = 256; var source_obj = {}; // we populate its buffer with random float values then save to output WAV file source_objbuffer = SIZE_BUFFER_SOURCE; var max_index = SIZE_BUFFER_SOURCE; for var index = 0; index < max_index; index++ source_objbufferindex = shared_utils; // console.log(index, " pop_audio_buffer ", source_obj.buffer[index]);
write typed array 32 bit float buffer (Float32Array) to output file WAV format 16 bit precision
var output_dir = processargv2 || "/tmp";var output_format = ".wav";var source_wave = "source_wave_shared_utils_test";var source_wave_filename = path; shared_utils;