title: Reversing a sound with Processing and Minim
body: <p>I need to make a program in Processing that reverses a loaded <em>.mp3</em> file, avoiding already implemented abstract functions (for example, a <code>Minim</code> function that reverses a given sound, though I still haven't found such). I've tried many ways by now and it still doesn't play. </p>
  
  <p>My last approach uses the <code>Minim.loadFileIntoBuffer()</code> function to get a <code>float[]</code> and then I reverse the buffer using Processing's <code>reverse()</code> function. I then create an <code>AudioSample</code> with the same <code>float</code> array and the original file's format. I then proceed to play the sample using <code>trigger()</code>. </p>
  
  <p>Here's a snippet:</p>
  
  <pre><code>Minim minim;
  AudioPlayer songPlayer;
  MultiChannelBuffer song;
  AudioSample reversedSong;
  float[] reversedBuffer, mixBuffer;
  
  void setup() {
    size(512, 200);
    minim = new Minim(this);
  
    songPlayer = minim.loadFile("sound.mp3");
  
    // loadFileIntoBuffer changes the MultiChannelBuffer's parameters to
    // match the file's, so init values doesn't really matter
    song = new MultiChannelBuffer(10, 3);
    minim.loadFileIntoBuffer("sound.mp3", song);
  
    mixBuffer = songPlayer.mix.toArray();
    reversedBuffer = reverse(mixBuffer);
  
   reversedSong = minim.createSample(reversedBuffer, songPlayer.getFormat());
   reversedSong.trigger();
  } 
  </code></pre>
  
  <p>I've also tried some different solutions. Namely importing directly the file into a <code>AudioSample</code>. The problem with most ways I've already used, I believe, is that I can only access an <code>AudioBuffer</code>, <em>i.e.</em> a part of the whole sound. Thus, I cannot reverse it all.</p>
  
  <p>Do you know any way of doing this?</p>