我已经写出了这些公式,我认为它们应该能够成功地生成适当的波形。我如何将它与 java 声音库集成来为每个声音库创建测试音?
import java.lang.Math;
public class SoundWaves
{
int WAV_MULTI = 25;
int amplitude;
double frequency;
int time;
double sineWave;
double sawWave;
double squareWave;
SoundWave ( int a, int f, int t)
{
}
double makeSineWave ( int a, int f, int t)
{
sineWave = a * Math.sin(2*PI*f*t); //passing amplitude frequency and time
return sineWave;
}
double makeSawTooth (int a, int f, int t)
{
for ( int i = 1; i < WAV_MULTI; i++)
{
sawWave = sawWave + (Math.sin((2*PI*f*(i*t)/i);
}
return sawWave;
}
double makeSquareWave (int a, int f, int t)
{
for ( int i = 1; i < WAV_MULTI; i++)
{
if ( i%2 != 0 )
squareWave = squareWave + (Math.sin((2*PI*f* (i*t)/i);
}
return squareWave;
}
}