核心转储试图加载音频在处理IDE中



我正在尝试在处理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();
      }
    }

文件音频文件与草图在同一目录中,但是当我尝试运行程序时,我会收到以下错误;

    #
    # 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:Usersjrr7eAppDataLocalTemp\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

我已经在多个操作系统上测试了它,并且仍然跨过同一核心转储。我已经看到很多人在网上遇到问题,但是还没有解决方案。

是否有任何方法可以阻止核心转储在处理中发生?事先感谢您的任何帮助。

。。。。。。。如果有人对视觉部分感兴趣,这也是班级明星。

    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;
      }
    }

(注意:此代码中的一些是从编码火车上借来的(

编辑;遵循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

请记住,draw()功能称为每秒60次。然后在draw()函数中,您要这样做:

file = new SoundFile(this, path);
file.play();

这意味着您正在加载相同的文件并每秒播放60次。这当然是炸毁计算机的一种方法。

要解决问题,您需要修改代码,以便仅加载声音一次(这就是setup()函数的目的(,并且仅在应触发时播放它(也许也可以在setup()函数中不是每秒60次(。

如果您仍然遇到麻烦,请将您的问题范围缩小到MCVE,这样:

import processing.sound.*;
SoundFile file;
String audioName = "CantinaSong.mp3";
String path;
void draw() {
  path = sketchPath (audioName);
  file = new SoundFile(this, path);
  file.play();
}

最新更新