atprocess — 2009-12-28 18:06:21

salut tout le monde

voilà j'aimerai charger une liste avec différents sons wav et les faire lire par le player au choix (du moins c'est l'idée de départ dans mon sketch);
j'ai cru comprendre que je peux le faire comme pour une liste d'images;
j'ai essayé ça (sachant que c'est la première que j'essaye de faire un array):

import ddf.minim.*;


Minim minim;
AudioPlayer player;

[s]minim[] sounds = new Minim[6]; 

//et ça s'arrête à ce niveau, logique. 
es ce que minim[] est un genre de liste ou bien il faut en créer une autre? comment faire? 

void setup() {
  minim = new Minim(this);
  
  for(int i=0; i<6; i++)
  {
  sounds[i] = loadFile("test44_0" + i + ".wav");
  }
  player.play();
}
void draw() {
  background(0);
}
void stop() {
  player.close();
  minim.stop();
  
  super.stop();
}

merci

matthieu — 2009-12-29 14:20:05

J'ai un peu retravailler ton code, il y avait une mauvaise création du tableau et les lignes avec le player est inutile.
De plus, je pense qu'on ne peut créer qu'une instance de Minim par sketch.

import ddf.minim.*;

Minim minim;
AudioPlayer[] sounds = new AudioPlayer[6];

void setup() {
  minim = new Minim(this); 
  for(int i=0; i<6; i++){
  sounds[i] = minim.loadFile("test44_0" + i + ".wav");
  }
}
void draw() {
  background(0);
}
void stop() {
  minim.stop(); 
  super.stop();
}

J'espère t'avoir été utile.

atprocess — 2009-12-30 16:40:45

salut tout le monde
j'ai eu la réponse à la question posée, je comprends maintenant ce qu'il fallait faire pour définir une liste dans minim. merci matthieu :)

j'ai testé la réécriture (en enlevant le 0 du nom_fichier) ...le sketch s'arrête pendant la compil avec cette erreur:
unexpected token : void

processing.app.debug.RunnerException: unexpected token: void
    at processing.app.Sketch.preprocess(Sketch.java:1369)
    at processing.app.Sketch.preprocess(Sketch.java:1194)
    at processing.app.Sketch.build(Sketch.java:1480)
    at processing.app.Sketch.compile(Sketch.java:1174)
    at processing.app.Editor.handleRun(Editor.java:1644)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:318)
    at java.awt.Component.processMouseEvent(Component.java:6260)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2475)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
processing.app.debug.RunnerException: unexpected token: void
    at processing.app.Sketch.preprocess(Sketch.java:1369)
    at processing.app.Sketch.preprocess(Sketch.java:1194)
    at processing.app.Sketch.build(Sketch.java:1480)
    at processing.app.Sketch.compile(Sketch.java:1174)
    at processing.app.Editor.handleRun(Editor.java:1644)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:318)
    at java.awt.Component.processMouseEvent(Component.java:6260)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2475)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


je ne sais pas trop quoi faire. il s'agit pour moi d'intégrer cette liste dans un sketch plus grand (qui lit et enregistre en même temps, d'ailleurs je compte faire aussi une liste pour les enregistrements)...


++