Source Academy Modules
    Preparing search index...

    Function record_for

    • Records a sound of a given duration. Returns a Sound promise.

      How the function behaves in detail:

      1. record_for is called.
      2. The function waits for the given buffer duration.
      3. The recording signal is played.
      4. Recording begins when the recording signal finishes.
      5. The recording signal plays to signal the end after the given duration.

      Parameters

      • duration: number

        duration in seconds

      • buffer: number

        pause before recording, in seconds

      Returns SoundPromise

      init_record();
      const promise = record_for(2, 0.5); // begin recording after 0.5s for 2s
      const sound = promise(); // retrieve the recorded sound
      play(sound); // and do whatever with it