Generating sound on the fly

Description of the problem:
I would like to be able to do an experiment involving a lot of algorithmically generated sounds. In particular, I want white noise with tiny gaps. I want the duration of the gap to be generated on the fly. It seems to me that I have a few options:

  1. Upload mp3 files with every possible duration of gap for every sound.
  2. Find a way to use built-in psychopy sound tools to make the sounds.
  3. Generate the sounds on the fly using some kind of external wav editing module.

How would you recommend I go about this?

Thanks,
Jon

EDIT: I’d be happy to upload a ton of different sounds if the participant didn’t have to cache them all. Can I host sounds on another URL and pull them as needed?

Could you have a single white noise file which you stop and start in code to create the gaps ?

I’m concerned about timing. The gaps need to be shorter than the duration of a frame. I also need the white noise to be different every trial but repeatable from one run to the next.

One possibility would be to grab different chunks of a long white noise file, as long as I can be sure the timing is sound.