Open ChampionL opened 5 years ago
You can either duplicate and interpolate the values.
You can use audacity software for it or using sox command
No, best use ffmpeg.
Yeah, ffmpeg can be used
You can upsample it with https://github.com/dataandsignal/libhdsp this way:
hdsp_status_t hdsp_upsample_int16(int16_t *x, size_t x_len, int upsample_factor, int16_t *y, size_t y_len);
A more complete snippet may look like this:
#include "hdsp.h"
int main(int argc, char **argv) {
#define Fs_x 8000
#define f_x 200
#define Fs_y 48000
#define FRAME_LEN_MS 20
#define X_LEN_SAMPLES (FRAME_LEN_MS * Fs_x / 1000)
#define Y_LEN_SAMPLES (FRAME_LEN_MS * Fs_y / 1000)
#define UPSAMPLE_FACTOR (Fs_y / Fs_x)
int16_t x[X_LEN_SAMPLES] = {0};
int16_t y[Y_LEN_SAMPLES] = {0};
int i = 0;
while (i < X_LEN_SAMPLES) {
x[i] = 100 * sin((double)i * 2 * M_PI * f_x / Fs_x);
printf("%d\n",x[i]);
i = i + 1;
}
hdsp_test(HDSP_STATUS_OK == hdsp_upsample_int16(x, X_LEN_SAMPLES, UPSAMPLE_FACTOR, y, Y_LEN_SAMPLES), "It did not work\n");
i = 0;
while (i < X_LEN_SAMPLES)
{
int j = 0;
while (j < UPSAMPLE_FACTOR) {
if (j == 0) {
hdsp_test(y[UPSAMPLE_FACTOR * i + j] == x[i], "Wrong sample");
} else {
hdsp_test(y[UPSAMPLE_FACTOR * i + j] == 0, "Wrong zero");
}
j = j + 1;
}
i = i + 1;
}
return 0;
}
Here is an article I wrote about upsampling / downsampling and filtering using libhdsp (I am author of this lib):
https://dataandsignal.com/blog/static/audio_upsampling_downsampling_and_filtering_with_libhdsp/
And here I wrote a tool that integrates RNNoise, so you can just:
./hdsptool denoise <input file raw> <input file sample rate> <frame ptime ms>
https://github.com/dataandsignal/libhdsp/blob/master/test/hdsptool.c
now ,i have a 8k pcm, if i apply this project to my pcm,i need resample 8khz to 48khz,what method of sampling i clould apply and make no effect on noise reduction?