<!-- Page: https://rustic-game-engine.pages.dev/docs/api/audio/game-start-hot-mic -->

# Game.startHotMic()

[Audio](https://rustic-game-engine.pages.dev/markdown/api/audio.md)

## Compatibility

**Supported languages:** C, C++, C#, Python, JavaScript, Lua 5.4, Luau, Java, PHP and HTML/inline JavaScript (binding spellings and return shapes differ).

Native devices and microphone input require Windows. Game-output recording and the mixer can run headlessly. Other operating systems do not supply the Windows native device backend.

The signature below is the shared reference notation; language examples show the actual binding syntax. Question marks mark optional arguments and explicit defaults are shown where recorded. Do not copy reference notation as a typed declaration.

See [Feature status and compatibility](https://rustic-game-engine.pages.dev/markdown/reference/compatibility.md) for API 1.0/1.1 and per-method restrictions. Engine release tags and Docs v0.1 are independent versions.

## Signature

`Game.startHotMic()`

## Setup and usage

Available in every supported gameplay language. Create an Object Component script in `scripts/`, attach it to an enabled scene object, and press **Play**. Start capture in Start or another callback. Native SDKs use their own member syntax; Lua uses colons. Microphone input requires Windows and OS microphone access. Recording captures audio, not video.

## Parameters

This call has no arguments.

## Return and timing

Returns a script-owned hot mic handle capturing the Windows default input device. Read local interleaved PCM chunks during Update for audio processing or your own relay code. Automatic network transport and speaker monitoring are not provided.

## Language examples

Choose one snippet at a time and place it inside your language's Start/on_start callback. These are independent examples; each creates its own handles or builders. Follow [Gameplay language bindings](https://rustic-game-engine.pages.dev/markdown/guides/gameplay-actions/language-bindings.md) for imports and callback registration. Python must import the modules used in its snippet from rustic; C# uses using static Rustic; Java examples belong inside a Rustic subclass; PHP callbacks declare global $rustic. HTML snippets go inside an inline script in a ui/ HTML asset.

Use an anchored Part for transform and effect examples, an unanchored collidable Part for forces, and a perspective camera named Camera for camera examples. Create Target for follow examples. Audio examples require assets/music.ogg in the Play snapshot. Replace scene paths with those listed by Game.scene.List(). Animation playback and sequence-animation examples require the Reveal fixture on the [Animation page](https://rustic-game-engine.pages.dev/markdown/api/animation.md); marker callbacks also require its Halfway marker. Run clock controls separately; a paused clock cannot advance a timer.

C callback examples use these file-scope functions before on_start:

```c
static void on_done(void) { rustic.log("info", "done"); }
static void on_sample(RusticValue value) { (void)value; rustic.log("info", "sample received"); }
static void on_event(const RusticValue *args, size_t count) {
    (void)args; (void)count; rustic.log("info", "event received");
}
```

Run inside Start or another callback. Retain the handle across callbacks to record a longer session. Hot microphone input requires Windows; capture samples are interleaved PCM. Native SDKs show their equivalent method syntax. Lua also retains the rustic.game and handle-specific stop aliases. See APIs in every language for setup and platform limits.

### Lua 5.4

```lua
local capture = Game.startHotMic()
```

### JavaScript

```javascript
const capture = Game.startHotMic();
```

### Python

```python
capture = Game.startHotMic()
```

### C++

```cpp
auto capture = Game.startHotMic();
```

### C#

```csharp
var capture = Game.startHotMic();
```

### Luau

```lua
local capture = Game.startHotMic()
```

### C

```c
RusticCaptureHandle capture = Game.startHotMic();
```

### Java

```java
var capture = Game.startHotMic();
```

### PHP

```php
global $Game;
$capture = $Game->startHotMic();
```

### HTML / inline JS

```javascript
const capture = Game.startHotMic();
```

## Complete Lua lifecycle example

```lua
local mic
return {
  Start = function() mic = rustic.game:startHotMic() end,
  Update = function()
    local packet = mic:read()
    -- Use packet.samples, packet.sampleRate and packet.channels.
    local peak = 0
    for _, sample in ipairs(packet.samples) do
      peak = math.max(peak, math.abs(sample))
    end
  end,
  OnStop = function() mic:stopHotMic(); mic:unload() end
}
```

## Capture limits and troubleshooting

- Capture handles belong to their script. Destroying the owner, ending Play or successful reload closes devices, finalizes files and releases handles. Read retained data in OnStop before cleanup.
- Each script may retain at most four capture handles; call `:unload()` after use. Recordings retain at most 64 MiB of PCM, including recordings written to files (about 175 seconds of stereo game audio). Exceeding the limit stops capture and read/stop report an error.
- Hot mic queues at most two seconds of input. Read regularly, using multiple reads if needed. `droppedSamples` reports lost input. Microphone samples are finite floats in `[-1, 1]`; channel count and rate come from the device.
- Default F32, I16 and U16 microphone formats are supported. Missing devices, denied access, unsupported formats, startup timeouts and disconnection raise errors. Catch expected failures with `pcall`.
- A recording destination must be a new `.wav` file in an existing writable directory. Game mixer recording also works headlessly.

See [the recording and hot mic guide](https://rustic-game-engine.pages.dev/markdown/guides/api-languages.md) for full setup and examples.

## Related APIs

- [Audio.get_output_devices()](https://rustic-game-engine.pages.dev/markdown/api/audio/get-output-devices.md)
- [Audio.get_input_devices()](https://rustic-game-engine.pages.dev/markdown/api/audio/get-input-devices.md)
- [Audio.set_output_device()](https://rustic-game-engine.pages.dev/markdown/api/audio/set-output-device.md)
- [Audio.set_input_device()](https://rustic-game-engine.pages.dev/markdown/api/audio/set-input-device.md)
- [Audio.load()](https://rustic-game-engine.pages.dev/markdown/api/audio/load.md)

[All audio APIs](https://rustic-game-engine.pages.dev/markdown/api/audio.md)
