使用 ALSA API 演奏视唱音符?
我正在使用 Alsa API,我想知道我应该使用哪些参数传递给函数 snd_pcm_writei 简单地播放视唱法音节/音符(AG / do re mi fa sol la si do)。
谢谢
I'm playing with the Alsa API and I wonder which parameters I should pass to the function snd_pcm_writei to simply play the solfège syllables/notes (A-G / do re mi fa sol la si do).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实想使用该函数来执行此操作,请在缓冲区中生成波形。三角波听起来可能不会太糟糕,并且生成起来应该足够简单。
基数“la”(A) 为 440Hz,即每秒 440 个您选择的波形周期。
对于高于/低于该基频的每个半音,可以通过乘/除 2^(1/12) (
1.05946309
) 来获得其他音符。您需要知道输出设备的设置频率(这可能是另一个 ALSA 函数的参数)。如果设备频率为 44100 Hz,并且您想要播放基音“la”,则波形的每个周期应占用 44100 / 440 或大约 100 个样本。还要注意样本宽度和设备配置的通道数。说明:一个八度中有 12 个半音,一个八度正好是频率的一半(低音)或两倍(高音)。一旦将 12 倍乘以 2^(1/12),就等于乘以了 2,因此每个半色调比前一个半色调高出 2^(1/12) 倍。
If you really want to do it with that function, generate a waveform in a buffer. A triangle-shaped wave may not sound too awful and should be simple enough to generate.
The base "la" (A) is 440Hz, that is, 440 cycles of the waveform of your choice per second.
The other notes can be obtained by multiplying/dividing by 2^(1/12) (
1.05946309
) for each half tone above/below this base frequency. You will need to know at what frequency the output device is set up (that's probably an argument to another ALSA function). If the device frequency is, say, 44100 Hz, and you want to play the base "la", each period of your waveform should occupy 44100 / 440 or about 100 samples. Pay attention to the sample width and the number of channels the device is configured for, too.Explanation: there are 12 half tones in an octave, and an octave is exactly half (lower pitched) or double (higher pitched) the frequency. Once you have multiplied 12 times by 2^(1/12), you have multiplied by 2, so each half-tone is at a factor of 2^(1/12) above the previous one.
听起来你想要 midi,而不是 ALSA。 ALSA 处理采样音频(例如从 CD、wav、mp3 等导出的数字波形)。它不是一个声音合成程序。
Sounds like you want midi, not ALSA. ALSA deals with sampled audio (e.g. digital waveforms derived from a CD, wav, mp3, etc). It is not a sound synthesis program.