From 5a41aa2f86b230b10dca669a62a9f4bac2fd51bc Mon Sep 17 00:00:00 2001 From: parking_turkeys Date: Mon, 26 Oct 2026 15:29:30 -0400 Subject: [PATCH] My personal notes for pitch because it's hard sob --- colon3sampler.h | 2 +- f0_notes.txt | 61 +++++++++++++++++++++++++++++++++++++++++++++ get_pitch.c | 2 +- main.c | 2 +- readme.txt | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 f0_notes.txt create mode 100644 readme.txt diff --git a/colon3sampler.h b/colon3sampler.h index 29275a4..0c777a4 100644 --- a/colon3sampler.h +++ b/colon3sampler.h @@ -12,7 +12,7 @@ * otherwise. Length required is in BYTES. */ int get_important_wave(int16_t orig_wave[], int w_B, int16_t new_wave[], float offset, float cutoff, float consonant); -float get_pitch(int16_t wave[], int w_B); +float get_pitch(int16_t wave[], int w_B, int consonant_i); /* Broken :p */ float midi_to_hz(char *note); int change_pitch(int16_t wave[], int w_B, float pitch_multiplier, int16_t out_wave[]); /* Give NULL for length */ diff --git a/f0_notes.txt b/f0_notes.txt new file mode 100644 index 0000000..5250b38 --- /dev/null +++ b/f0_notes.txt @@ -0,0 +1,61 @@ +UHH IF YOU ARENT ME AND ARE READING THIS IT WONT MAKE ANY SENSE I JUST NEED TO +WRITE THINGS DOWN AND ALSO IM TOO LAZY TO READ THE DOCS LOLL + +so i need to figure out how this works but im too lazy to actually learn how it +works so im looking at projects that use it to figure out how they work +because i dont understand cpp enough lmao so i dont want to have to read +through that, but i assume there's a reason basically every utau resampler uses +WORLD lmao + +straycat: calls pyworld.harvest(, 44100, 71.0, 800.0) +this returns an array of f0s, and also the time they're at i think???? + +pyworld: InitializeHarvestOption()s, then sets f0_floor and ceil ,and frame_period +then it gets the length of the output through GetSamplesForHarvest(44100, +wave_lengthinsamples, option.frame_period) +then it makes an array of float64s (??) with length f0_length and initializes +it with 0s i think +but it's an np.ndarray that might be some weird python thing idk +then it does that again for the temporal positions + +then it uh +Harvest(w, w_len_samples, samplerate, &option, temporal_positions, f0); +and returns f0 lmaoo + + +WORLD: ok heres the hard part... +InitializeHarvestOption() just uhh initializes it with default options +what even is a harvest loll +GetSamplesForHarvest: +returns int (1000.0*wavelen/fs/frame_period)+1; idk why +Harvest() uhh +sets target sampling rate to 8000.0 i think +sets dimension_ratio to round(samplerate/target_samplerate) +sets channels_in_octave to 40?? + +if frame period is 1 it just goes straight to HarvestGeneralBody and returns +otherwise uh +sets basic_frameperiod to 1 +GetSamplesForHarvest()s with the basicfp instead and calls that basicf0len +it makes a double array *basic_f0 and *basic_temporal_positions +Then it HarvestGeneralBody()s +then it does GetSamplesForHarvest but with like the normal frame period and +calls that f0_length +then it loops i < f0_len + sets temp_pos[i] to i*o->fp/1000.0 + f0[i] to basic_f0[MyMinInt(basic_f0len -1, + round(temporal_positions[i]*1000.0))] +wtf + + +HarvestGeneralBody: "estimates the f0 contour based on harvest" +changes f0floor *0.9 and ceil*1.1 +i give up for today wtf is this.... i need to find a more simply designed thing +ok actually i realized ijust need to find out how to call the function not all +the other stuff + +Ok i have no idea what this does maybe i shoudl give up this is a bit too smart for me + +but like tbh it should be totally easy if you think about it, all i need is +this f array and then i get f[0] right +uhh im,, , going back to the docs diff --git a/get_pitch.c b/get_pitch.c index 71bed29..f908630 100644 --- a/get_pitch.c +++ b/get_pitch.c @@ -2,7 +2,7 @@ static int is_through_zero(int16_t last, int16_t current); static float old_get_pitch(int16_t w[], int w_B); -float get_pitch(int16_t w[], int w_B) +float get_pitch(int16_t w[], int w_B, int co_i) { return old_get_pitch(w, w_B); }; diff --git a/main.c b/main.c index e17ac2f..1242b31 100644 --- a/main.c +++ b/main.c @@ -145,7 +145,7 @@ int main(int argc, char *argv[]) if (cons_i == -1) goto error; printf("%d\n", cons_i); get_pitch: - float pitch_Hz = get_pitch(phoneme, ph_B); + float pitch_Hz = get_pitch(phoneme, ph_B, cons_i); printf("The pitch is %f Hz.\n", pitch_Hz); change_pitch: float pitch_mult = pitch_Hz/midi_to_hz(argv[3]); diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..7f4eee0 --- /dev/null +++ b/readme.txt @@ -0,0 +1,66 @@ +colon3sampler (awesome and cool) + +1. what is it +a resampler for the UTAU singing synthesis program, which i dont feel like +explaining right now + +2. how does it work +it doesnt +uhh it finds the pitch (and by this i mean it doesnt i havent figured that out +yet) and then makes the wave higher and changes the length and writes it to a +file idk + +3. languages and stuff +C because it's awesome +Also you might have to install fftw but i havent started that part yet lwk + +4. licenses +it's gplv3 +I use some stuff from other programs! one of them is cited directly in the code +in a comment right when I use it. yay. (Ty tho to it for existing so i could +figure out how to do smth) +things i need to do the license thing for (i cant do that rn but in a second): +- openutau (for how to do stuff) (like pitch bends) (MIT) +- WORLD (maybe?? i havent actually used anything from it yet) (BSD) +- fftw (im about to use this) (i think) (gplv2+) +wait --- +when do you have to cite a code????? I have no idea tbh... like I just needed +to know how to call a library sob + +5. (nothing to put here but too lazy to edit the others...) + +UTAU I HATE HATE HATE You WHY DO YOU SEND THE PITCH BEND LIKE THAT?? WHY DO YOU +SEND THE MIDI NOTE LIKE THAT YOU HAVE IT AS A NUMBER ALREADY FROM THE UST YET +YOU HATE ME SO YOU WONT GIVE IT TO ME HATE HATE HATE HATE + +6. how to compile +Use make. +On linux: "make linux" (or "make linux-test" to make it AND run it once) +On windows: "make win" (or "make win-test") +On MacOS: Find the nearest computer capable of running windows or linux, +install it, and then follow the corresponding instruction. +Or if you really want to use macOS all you have to do probably is just like uhh +look at the Makefile it's suuuper simple +Entirely serious about it being simple btw. Like it's basically just cc *.c *.h +with libraries (like the normal ones) and some config options + +On the config options: +-std=c99 (self-explanatory) +-Wall -Werror (Warnings are good) +-Wno-unused-labels (IMPORTANT. I like using labels as comments) +-lfftw3 -lm (Libraries i think) +-o colon3sampler OR -o colon3sampler.exe (exe for windows :)) + +7. Why i made this +I love UTAU and I finally found something documenting the arguments it calls +resamplers with. Also colon3sampler is a really good name imo +Also i didnt think itd be this hard i thought wav files stored pitch not +amplitude at first sob + +8. How to use +IMPORTANT: go to UTAU and select "calculate length on UI frontend". It's +somewhere in the options. Not sure if this exists on OpenUtau so if it doesnt +then uhh it Definitely won't work on OpenUtau. +I can't guarantee it works on OpenUtau, if some OpenUtau wizard would like to +explain what a resampler needs to work on there pls :3 my wavtool wont work and +I have 0 idea why... -- 2.47.3