error when adding sound

edited June 2017 in Library Questions

hi, i got this error when i added the sound file stuff and i get this error: RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (hw:0,3), Device or resource busy.

terminate called after throwing an instance of 'std::runtime_error' what(): RtApi::openStream: a non-NULL output StreamParameters structure cannot have an nChannels value less than one. Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help → Troubleshooting.

I don't know what is means so please help

this is the code:

import processing.sound.*;
SoundFile file;




void setup() {
  size(800, 600);
  //fullScreen(1);
  keysIn = new ArrayList <Character>();

  myball = new Ball();

  player1 = new Player();
  player2 = new Player();

  player1.PlayerY = height / 2;
  player2.PlayerY = height / 2;

  player1.points = 0;
  player2.points = 0;

  file = new SoundFile(this, "song.mp3"); // the song IS called song.mp3
  file.play();
}

void draw() {
  background(0);
  println(keysIn);

  myball.run();

  myball.bounce(player1.PlayerY, player2.PlayerY);


  player1.playerNo = 1;
  player1.run();

  player2.playerNo = 2;
  player2.run();

  player1.Decpoints(myball.ballX);
  player2.Decpoints(myball.ballX);

  textSize(100);
  text(player1.points, 40, 100);
  text(player2.points, 40, 700);
}

void keyTyped() {
  if (!keysIn.contains(key)) {
    keysIn.add(key);
  }
}

void keyReleased() {
  if (keysIn.contains(key)) {
    keysIn.remove(new Character(key));
  }
}

if you want me to post the rest of the code (and 2 other tabs) please say so

PS: it worked before i added the sound file PPS: im in processing 3

Answers

  • Could you make your code readable? Before exporting hit ctrl+t in processing, then after pasting in the forum highlight your code and hit ctrl+o.

    "Device or resource busy" might signify the device can only be used by one program at a time.

  • edited April 2016
    ArrayList<Character> keysIn; 
    Ball myball;
    Player player1;
    Player player2;
    boolean startOverPoint = true;
    
    import processing.sound.*;
    SoundFile file;
    
    
    
    
    void setup() {
      size(800, 600);
      //fullScreen(1);
      keysIn = new ArrayList <Character>();
    
      myball = new Ball();
    
      player1 = new Player();
      player2 = new Player();
    
      player1.PlayerY = height / 2;
      player2.PlayerY = height / 2;
    
      player1.points = 0;
      player2.points = 0;
    
      file = new SoundFile(this,"song.mp3");
      file.play();
    }
    

    im only using this sketch when the error happened and its not in the other 2 tabs

  • Having a similar problem. Did you find a solution?

  • @kmvtxx What error do you get? Also, please open a new post and add a cross-reference to this post.

    Kf

Sign In or Register to comment.