我正在尝试学习如何使用处理,因此正在尝试使用声音库。在运行https://processing.org/tutorials/sound/提供的前两个示例程序中的任何一个时,IDE 会响应以下错误:
此应用程序已请求运行时以不寻常的方式终止它。请联系应用程序的支持团队以获取更多信息。在抛出 'RtAudioError' what() 的实例后调用终止:RtApiWasapi::getDeviceInfo:无法检索设备混合格式。无法运行草图(目标 VM 无法初始化)。有关更多信息,请阅读 revisions.txt 和 Help ? 故障排除。
此外,每当我尝试使用这个库运行草图时,连同那个错误,windows 说
Java(TM) Platform SE 二进制文件已停止工作 Windows 正在收集有关该问题的更多信息。这也许会花几分钟...
你能帮我解决这个问题吗?我正在使用 Windows Vista 计算机。这是第二个示例代码:
/**
* Processing Sound Library, Example 2
*
* This sketch shows how to use envelopes and oscillators.
* Envelopes describe to course of amplitude over time.
* The Sound library provides an ASR envelope which stands for
* attack, sustain, release.
*
* .________
* . ---
* . ---
* . ---
* A S R
*/
import processing.sound.*;
// Oscillator and envelope
TriOsc triOsc;
Env env;
// Times and levels for the ASR envelope
float attackTime = 0.001;
float sustainTime = 0.004;
float sustainLevel = 0.2;
float releaseTime = 0.2;
// This is an octave in MIDI notes.
int[] midiSequence = {
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72
};
// Set the duration between the notes
int duration = 200;
// Set the note trigger
int trigger = 0;
// An index to count up the notes
int note = 0;
void setup() {
size(640, 360);
background(255);
// Create triangle wave and envelope
triOsc = new TriOsc(this);
env = new Env(this);
}
void draw() {
// If value of trigger is equal to the computer clock and if not all
// notes have been played yet, the next note gets triggered.
if ((millis() > trigger) && (note<midiSequence.length)) {
// midiToFreq transforms the MIDI value into a frequency in Hz which we use
//to control the triangle oscillator with an amplitute of 0.8
triOsc.play(midiToFreq(midiSequence[note]), 0.8);
// The envelope gets triggered with the oscillator as input and the times and
// levels we defined earlier
env.play(triOsc, attackTime, sustainTime, sustainLevel, releaseTime);
// Create the new trigger according to predefined durations and speed
trigger = millis() + duration;
// Advance by one note in the midiSequence;
note++;
// Loop the sequence
if (note == 12) {
note = 0;
}
}
}
// This function calculates the respective frequency of a MIDI note
float midiToFreq(int note) {
return (pow(2, ((note-69)/12.0)))*440;
}