---
title: "encodeAudio"
sidebar_label: "encodeAudio"
description: "Kotlin binding reference: encodeAudio."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Io](index.md)/[encodeAudio](encodeAudio.md)

# encodeAudio

[common]\
fun [encodeAudio](encodeAudio.md)(samples: [Tensor](../Tensor/index.md), sampleRate: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)): [ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html)

Encode a waveform as a 16-bit PCM WAV payload. [samples](encodeAudio.md) is `[frames]` (mono) or `[frames, channels]` interleaved: a float tensor holds values in -1, 1 (a value outside clips), an Int16 tensor is written as is. [sampleRate](encodeAudio.md) is in Hz. [loadAudio](loadAudio.md) reads the payload back with the same layout.