title: Instantiating a SoundFile object within a class in Processing
body: <p>I am attempting to create an instance of the <a href="https://processing.org/reference/libraries/sound/SoundFile.html" rel="nofollow noreferrer">SoundFile</a> type inside of another class in Processing (the latest version, 3.0a10). I can easily play a sound that is defined outside of a class, as follows:</p>
  <pre><code>import processing.sound.*;
  
  SoundFile clickSound;
  
  void setup() {
    size(600, 600);
    clickSound = new SoundFile(this, &quot;bike-passing-by.wav&quot;);
  }
  
  void draw() {
    clickSound.play();
  }
  </code></pre>
  <p>However, I run into trouble when I attempt to create a SoundFile instance from inside a class. A simplified example of this would be:</p>
  <pre><code>import processing.sound.*;
  
  SomeSound fx;
  
  void setup() {
    size(600, 600);
    fx = new SomeSound();
  }
  
  void draw() {
    fx.play();
  }
  
  class SomeSound {
    SoundFile clickSound;
  
    SomeSound() {
      clickSound = new SoundFile(this, &quot;bike-passing-by.wav&quot;);
    }
  
    void play() {
      clickSound.play();
    }
  
  }
  </code></pre>
  <p>The error I receive is that <code>&quot;The constructor SoundFile(soundTest.SomeSound, String) is undefined&quot;</code>. In the Processing reference for SoundFile, it states that the constructor is defined as<code> SoundFile(parent, path)</code>. The parent parameter is supposed to be <code>PApplet: typically use &quot;this&quot;</code>.</p>
  <p>I therefore tried a number of options to replace this line:
  <code>clickSound = new SoundFile(this, &quot;bike-passing-by.wav&quot;);</code></p>
  <p>I tried replacing <code>this</code> with <code>super</code>:
  <code>clickSound = new SoundFile(super, &quot;bike-passing-by.wav&quot;);</code></p>
  <p>and <code>PApplet</code>:
  <code>clickSound = new SoundFile(PApplet, &quot;bike-passing-by.wav&quot;);</code></p>
  <p>but only manage to produce different errors. Any advice on how to fix this would be greatly appreciated.</p>