We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › minim audioSnippet and array asignment problem
Page Index Toggle Pages: 1
minim audioSnippet and array asignment problem (Read 1603 times)
minim audioSnippet and array asignment problem
May 21st, 2010, 1:19pm
 
Hello, i've run into a problem that i can't solve myslelf.
When i'm using:
Code:

       private Minim minim;
private AudioSnippet sample;

public void setup() {
size(CANVAS_WIDTH,CANVAS_HEIGHT, JAVA2D);
background(BG_COLOR);
smooth();

this.minim = new Minim(this);
this.sample = minim.loadSnippet("04.wav");
       }

everything works fine. The problem is i want to use an array of AudioSnippets. Im trying like that:
Code:

       private Minim minim;
private AudioSnippet samples[];

public void setup() {
size(CANVAS_WIDTH,CANVAS_HEIGHT, JAVA2D);
background(BG_COLOR);
smooth();

this.minim = new Minim(this);
this.samples[0] = minim.loadSnippet("04.wav");
      }

I get the NullPointerException. What am i doing wrong?

Worked it aroudn using:
Code:
private ArrayList <AudioSnippet> snippets_list = new ArrayList<AudioSnippet>(); 



I still don't know why the previous one didnt work. ??
Re: minim audioSnippet and array asignment problem
Reply #1 - May 21st, 2010, 1:59pm
 
You also need to 'new' your simple array.
Re: minim audioSnippet and array asignment problem
Reply #2 - May 23rd, 2010, 12:28am
 
private AudioSnippet[] samples = new AudioSnippet[howeverManyYouWant];

Page Index Toggle Pages: 1