我录制了一根吉他弦演奏一个音符,然后获取每个和声的幅度,然后通过 prgram(android) 重新创建类似的声音,但声音听起来不像吉他。
public void setToHarmonies(int[] harmonies, int frequency){
int total = 0;
int size = harmonies.length;
for(int i=0; i<size; i++){
total+=harmonies[i];
}
for(int i=0; i<numSamples; i++){
samples[i] = 0;
}
float[] effHarm = new float[size];
double[][] hwaves = new double[size][numSamples];
for(int i=0; i<size; i++){
effHarm[i] = ((float)(harmonies[i]-.2)) / (float)total;
hwaves[i] = genSinWave(numSamples, frequency * i);
for(int e=0; e<numSamples; e++){
samples[e] += effHarm[i] * hwaves[i][e] * Math.exp((float)((float)e / (float)15000) * -1);
}
}
}
public double[] genSinWave(int size, int freq){
double[] samplesOut = new double[size];
float period = (float)sampleRate / (float)freq;
for(int i=0; i<samplesOut.length; i++){
samplesOut[i] = Math.sin(2 * i * Math.PI / period);
}
return samplesOut;
}
private static final int[] guitar = {699, 602, 465, 407, 544, 457, 443, 307, 283, 357, 342, 224};
在 Audacity 上绘制频谱图给了我负值,最小值为 -72.7,所以我从 72.7 中减去每个峰值的值,然后乘以 10 得到上述值。编程错了吗?和声内容/音色值是否错误?如果不对波形进行特定的起音和衰减修改,就没有办法让它听起来像吉他吗?感谢所有帮助。