【发布时间】:2018-02-15 11:48:56
【问题描述】:
我正在尝试在 Processing IDE (3.1.2) 中创建一个程序,该程序将具有背景音频。这是到目前为止的代码;
import processing.sound.*;
SoundFile file;
String audioName = "CantinaSong.mp3";
String path;
Star[] stars = new Star [1500];
void setup() {
size(1000, 1000);
for (int i = 0; i<stars.length;i++){
stars [i] = new Star();
}
}
void draw() {
path = sketchPath (audioName);
file = new SoundFile(this, path);
file.play();
background (0);
translate(width/2, height/2);
for (int i = 0; i< stars.length;i++){
stars [i].update();
stars [i].show();
}
}
文件音频文件与Sketch在同一目录下,但是当我尝试运行程序时出现以下错误;
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (0x20474343), pid=5212, tid=0x0000000000001264
#
# JRE version: Java(TM) SE Runtime Environment (8.0_102-b14) (build 1.8.0_102-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [KERNELBASE.dll+0x1a06d]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\jrr7e\AppData\Local\Temp\\hs_err_pid5212.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting
我已经在多个操作系统上对此进行了测试,并且仍然在同一个核心转储中运行。 我在网上看到很多人有这个问题,但还没有解决方案。
有没有办法阻止核心转储在处理中发生? 提前感谢您的帮助。
。 . . . . . . 如果有人对它的视觉部分感兴趣,这也是 Star 类。
class Star {
float x;
float y;
float z;
float px;
float py;
Star(){
x = random(-width, width);
y = random (-height, height);
z = random(width);
}
void update(){
z -= 100;
if (z < 1){
x = random(-width, width);
y = random (-height, height);
z = width;
px=x;
py=y;
}
}
void show(){
fill(255);
noStroke();
float sx = map (x/z, 0, 1, 0, width);
float sy = map (y/z, 0, 1, 0, height);
float r = map(z, 0, width, 16, 0);
ellipse(sx,sy,r,r);
stroke(255);
line(px,py,sx,sy);
px = x;
py = y;
}
}
(注意:部分代码是从 The Coding Train 借来的)
编辑; 根据 Kevin Workman 的建议,这里是有问题的代码段的 MCVE,对之前的代码进行了一些编辑。
import processing.sound.*;
SoundFile file;
void setup() {
file = new SoundFile(this, "CantinaSong.mp3");
file.play();
}
这里也是声音音频库的链接。 https://processing.org/reference/libraries/sound/SoundFile.html
【问题讨论】:
-
我忘了说;问题代码基于处理基金会的处理声音库。如果有人有替代的音频库,那也很棒。
-
如果您尝试不同的声音文件会发生什么?您尝试使用的声音文件是否异常短或长?如果您尝试使用不同的计算机会发生什么?您的 MCVE 看起来应该可以工作了。
标签: javascript java processing