--- /dev/null
+#include "colon3sampler.h"
+
+int change_wave_len(int16_t w[], int w_B, int16_t ow[], int co, int ow_B)
+{
+ int end_samples = (w_B/2) - co;
+ int i = 0;
+ if (w_B < ow_B) goto loop_co;
+ if (w_B > ow_B) goto cut_wave;
+ return 0;
+loop_co:
+ int co_i = 0;
+ for (i = 0; i < (ow_B/2-end_samples); i++) {
+ ow[i] = w[co_i++];
+ if (co_i == co) co_i = 0;
+ };
+ goto append_end;
+cut_wave:
+ if (end_samples >= (ow_B/2)) goto append_end;
+ for (i = 0; i < (ow_B/2-end_samples); i++) {
+ ow[i] = w[i];
+ };
+ goto append_end;
+append_end:
+
+ for (i = i; (i < end_samples) && (i < (ow_B/2)); i++) {
+ ow[i] = w[co++];
+ };
+ return 1;
+};
+
int change_pitch(int16_t wave[], int w_B, float pitch_multiplier,
int16_t out_wave[]); /* Give NULL for length */
int write_wave(char *out_filename, int16_t wave[], int w_B);
+int change_wave_len(int16_t wave[], int w_B, int16_t out_wave[], int consonant,
+ int out_len_B); /* out length in bytes*/
/* From other things */
printf("The pitch is %f Hz.\n", pitch_Hz);
change_pitch:
float pitch_mult = pitch_Hz/midi_to_hz(argv[3]);
+ pitch_mult = 2.0; /* testing */
printf("%f", pitch_mult);
int resampled_len = change_pitch(phoneme, ph_B, pitch_mult, NULL);
int16_t *resampled = malloc(resampled_len);
change_pitch(phoneme, ph_B, pitch_mult, resampled);
change_length:
/* tba */
+ int final_B = (int)ceil(ß(argv[7]) * 88.200); /* have to set
+ calculate
+ length on UI
+ frontend for
+ this to work
+ */
+ int16_t *final = malloc(final_B);
+ change_wave_len(resampled, resampled_len, final,
+ (int) ceil(cons_i/pitch_mult), final_B);
write_wave:
/* change what u write later */
- write_wave(argv[2], resampled, resampled_len);
+ write_wave(argv[2], final, final_B);
cleanup:
free(wave);
free(phoneme);