这只是为了补充已经提供和接受的答案(我给出了一个加1)。
您可以使用波子来替代在半样本/半合成的飞行类中运行三角函数。 我也可以使用一个正弦波表, 上面有6个独立的光标指向它, 用于调频合成, 并以这种方式复制了几个 Yamaha DX7 补丁 。 但这一切都是通过 javax. sound. samped. samped 完成的。 一旦建立软合成, 您可能想要用底栖图书馆类来控制它 。
以单正弦波的浮点数来显示 1K 阵列。
If you "play" the wave table by incrementing and looping through it and extracting each array member in turn (to write to the sound card via a SourceDataLine), you will get a pitch directly related to your sample rate. For 44100 samples per second, the 1024-member array will cycle 44100/1024 = 43.066... times in to fill that "second" with data (a very low pitch--roughly 43 Hz). If you skip every second table member, the pitch is twice that, etc. To get the pitch 440, one needs to find the correct "increment" to use to step through the wave table array, which can be found:
incr = (size of waveTable * desired pitch) / sample rate
For example
(1024 * 440 ) / 44100 gives an increment of: 10.21678...
Thus, if the first value from the waveTable is at array location 0, the second value to be used would be in between locations 10 and 11. To get a value that lies in between two array locations, use linear interpolation.
我使用这个方法, 使用 Javax. sound. smound. samped library, 用于此链接中的“ spenmin ” 。 显示了一个键盘, 但是您可以在鼠标移动到键盘上时很容易听到/ 看见微子控制 。
http://www.hexara.com/VSL/JInemin.htm" rel=“no follow'>http://www.hexara.com/VSL/JInemin.htm
在上面,鼠标位置(通过鼠标移动听力器)被用于通过此函数计算想要的音轨 :
return Math.pow(2, ((mouseX + tuningLoc) / (octaveWidth)));
此处的八维值是覆盖八维值的像素数。