Source Academy Modules
    Preparing search index...

    Function record

    • Records a sound until the returned stop function is called. Takes a buffer duration (in seconds) as argument, and returns a nullary stop. A call to the stop function returns a Sound promise.

      How the function behaves in detail:

      1. record 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. Recording stops when the returned stop function is called.

      Parameters

      • buffer: number

        pause before recording, in seconds

      Returns () => SoundPromise

      init_record();
      const stop = record(0.5); // record after 0.5 seconds.
      const promise = stop(); // stop recording and get sound promoie
      const sound = promise(); // retrieve the recorded sound
      play(sound); // and do whatever with it