Cross Platform Microphone

Cross Platform Microphone is a user-friendly Unity asset providing versatile microphone support across all major platforms.

This documentation will guide you through the available functions, usage, and features of the Cross Platform Microphone asset.

Functions

The asset provides the following functions for interacting with the microphone:

Start Recording

public static AudioClip Start(string device, bool loop, int lengthSec, int frequency)

Begins the recording process.

  • device: The device to be recorded
  • loop: Indicates whether recording should loop or not
  • lengthSec: Length of the anticipated recording in seconds
  • frequency: Recording frequency in samples per second

Get Recording Position

public static int GetPosition(string device)

Obtains the current recording position of the device.

  • device: The device to get the recording position for

End Recording

public static void End(string device)

Stops the recording process for the specified device.

  • device: Device to finish recording

List Devices

public static string[] devices { get; private set; }

An array of available devices for selection.

Refresh Devices

public static void RefreshDevices(Action<string[]> Callback)

Refreshes the list of available devices and calls the provided callback function with the new list of devices.

public static void RefreshDevices()

A convenient shortcut for refreshing devices without providing a callback.

Check if Recording

public static bool IsRecording(string device)

Determines if a specific device is currently recording.

  • device: Device to verify the recording status for

Demo Scene

The “Record and Play” demo scene demonstrates how to use the Cross Platform Microphone asset interactively. The DemoMenu script provided in the demo scene implements the following user interface components:

  • Record button: Starts or stops recording the audio.
  • Play button: Plays the recorded audio.
  • Refresh Devices button: Refreshes the list of available devices.
  • Devices Dropdown: A list of audio input devices available for use.

Usage

  1. Press the Record button to start recording from the selected device. If the button is pressed again, the recording will stop.
  2. Press the Play button to play the recorded audio.
  3. To refresh the list of available devices, click the Refresh Devices button.


About us

We are a small company focused on building tools for game developers. Send us an email to careers@leastsquares.io if interested in working with us. For any other inquiries, feel free to contact us at hello@leastsquares.io or contact us on the discord





Sign up to our newsletter.

Want to receive news about discounts, new products and updates?