2016-07-14 2 views
0

이상한 것. 처리가 계속되거나 처리 웹 사이트의 샘플 코드를 기반으로하는이 코드와 충돌이 발생합니다.처리 fft 충돌

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: RtApiCore::probeDeviceOpen: the device (2) does not support the requested channel count. Could not run the sketch (Target VM failed to initialize).

:

PC에 그것은 하나의 이 맥 그냥 지각이 분쇄 될 때까지 5 초 동안 다른 에서 작동하며 나에게 이것을 제공에 전혀 작동하지 않습니다

도서관이나 코드에 문제가 있다고 생각하십니까? 라이브러리에 문제가있는 경우이 같은 작업을 수행하는 데 가장 좋은 사운드 라이브러리를 추천 할 수 있습니까?

당신이 각도처럼 사용하고 X를 시작 값을 인쇄 할 경우

import processing.sound.*; 

FFT fft; 
AudioIn in; 
int bands = 512; 
float[] spectrum = new float[bands]; 

void setup() { 
    size(900, 600); 

    background(255); 

    // Create an Input stream which is routed into the Amplitude analyzer 
    fft = new FFT(this, bands); 
    in = new AudioIn(this, 0); 

    // start the Audio Input 
    in.start(); 

    // patch the AudioIn 
    fft.input(in); 
}  

void draw() { 
    background(255); 
    int midPointW = width/2; 
    int midPointH = height/2; 
    float angle = 1; 
    fft.analyze(spectrum); 
    //float radius = 200; 

    for(int i = 0; i < bands; i++){ 
    // create the actions for placing points on a circle 
    float radius = spectrum[i]*height*10; 
    //float radius = 10; 
    float endX = midPointW+sin(angle) * radius*10; 
    float endY = midPointH+cos(angle) * radius*10; 
    float startX = midPointW+sin(angle) * radius*5; 
    float startY = midPointH+cos(angle) * radius*5; 
    // The result of the FFT is normalized 
    // draw the line for frequency band i scaling it up by 5 to get more amplitude. 
    line(startX, startY, endX, endY); 
    angle = angle + angle; 
    println(endX, "" ,endY); 
// if(angle > 360){ 
//  angle = 0; 
// } 
    }  
} 
+0

당신이 묻고있는 것과 이것이 어떤 언어인지는 약간 불분명합니다. 그것은 C, C++ 및 Java의 요소를 가지고 있습니다. 코드가 무엇을하기로되어 있는지 구체적으로 설명해 주시겠습니까? 파일 기반 분석입니까? 'draw()'가 어떻게 불려지나요? 분석을 위해 어떤 API를 사용하고 있습니까? 관련 정보가 누락되었습니다. – user3078414

답변

1

을 :) 감사, Y는 것을 알 수 있습니다 :

  1. 시작/끝 X를, y 값은 NaN 될 (숫자 - 무효)
  2. 각도가 빠르게 Infinity 간다 (하지만 이상)
당신은 기하 급수적으로 당신은 아마하지 않으려는이 값을 증가하고

angle = angle + angle; 

: 주요 이슈의 0

하나는이 라인입니다. 또한, sin()cos()과 같은 삼각 함수는 각도가 아닌 라디안을 사용하므로 수치가 작아지는 경향이 있습니다. 당신은 나머지 연산자 (%) 또는 constrain() 기능을 사용하여 360도 또는 TWO_PI 라디안 값을 제한 할 수 있습니다

angle = (angle + 0.01) % TWO_PI; 

당신은 당신의 angle > 360 수표를 보여줍니다 것처럼 매우 가까웠다. 왜 당신이 그 주석을 남겼는지 잘 모르겠다.

다음은 팅겨과 코드 그리고 스케치는 5 분 이상 실행하지만 난 여전히 발생 스케치를 닫을 때 JVM은 OSX에 충돌

import processing.sound.*; 

FFT fft; 
AudioIn in; 
int bands = 512; 
float[] spectrum = new float[bands]; 

void setup() { 
    size(900, 600); 

    background(255); 

    // Create an Input stream which is routed into the Amplitude analyzer 
    fft = new FFT(this, bands); 
    in = new AudioIn(this, 0); 

    // start the Audio Input 
    in.start(); 

    // patch the AudioIn 
    fft.input(in); 
}  

void draw() { 
    background(255); 
    int midPointW = width/2; 
    int midPointH = height/2; 
    float angle = 1; 
    fft.analyze(spectrum); 
    //float radius = 200; 

    for (int i = 0; i < bands; i++) { 
    // create the actions for placing points on a circle 
    float radius = spectrum[i] * height * 10; 
    //float radius = 10; 
    float endX = midPointW + (sin(angle) * radius * 10); 
    float endY = midPointH + (cos(angle) * radius * 10); 
    float startX = midPointW + (sin(angle) * radius * 5); 
    float startY = midPointH + (cos(angle) * radius * 5); 
    // The result of the FFT is normalized 
    // draw the line for frequency band i scaling it up by 5 to get more amplitude. 
    line(startX, startY, endX, endY); 
    //angle = angle + angle; 
    angle = (angle + 0.01) % TWO_PI;//linearly increase the angle and constrain it to a 360 degrees (2 * PI) 
    } 
} 

void exit() { 
    in.stop();//try to cleanly stop the audio input 
    super.exit(); 
} 

코멘트. 필자는이 사운드 라이브러리를 많이 사용하지 않았으며 내부적으로 살펴 보지 않았지만 버그 일 수 있습니다.

여전히 문제가 발생하는 경우 실용적인 이유로 Contribution Manager를 통해 FFT 사운드 분석을 위해 다른 Processing 라이브러리를 설치하는 것이 좋습니다. 시각화

  • Beads
  • 에 도움이되는 몇 가지 좋은 linearlogarithmic 평균 기능을 제공합니다 - -

    1. Minim 구문처럼 풍부하지만 더 자바 기능 : 다음은 라이브러리의 몇 가지 있습니다.무료 도서도 있습니다 : Sonifying Processing

    두 라이브러리 모두 FFT 예제를 제공합니다.