Refreshing a SoundFile


I’m playing around with the sound library of Processing to create a very basic synthesizer of sorts. My sketch right now displays a few draggable sliders, using which the user can define a waveform. When the “t” key is pressed, this then gets sampled and saved into a wave file. My issue is that, when I try to load this new version of “test.wav” into the program, it doesn’t seem to update the actual sound. When I restart the sketch, it loads up the latest iteration, so I know that the sampling works fine.

Things I have tried:

  • Deleting the old file before creating the new one

  • Stopping playback on all sound objects before replacing the file

  • soundObj.file = null for all of my sound objects before replacing the file

  • Completely erasing the array of my sound objects, and then re-initializing them

The only thing that kinda worked is when I created separate files (so “test1.wav” then “test2.wav” then “test3.wav”, etc.), but that’s a less than ideal solution since the user can then create infinite files in the folder, or if i want to avoid that, I will at some point have to loop back to the beginning.

Here’s my code (and an already created test.wav file in there to avoid errrors), sorry it isn’t the prettiest yet: