All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.korlibs.audio.sound.node.AudioDataNode.kt Maven / Gradle / Ivy

The newest version!
package korlibs.audio.sound.node

import korlibs.audio.sound.*

// @TODO: Enable this later
internal class AudioDataNode(
    val data: AudioSamples,
) : AudioNode {
    var pos = 0

    override fun generate(out: AudioData): Int {
        val available = data.totalSamples - pos
        val copy = minOf(available, out.totalSamples)

        for (ch in 0 until out.channels) {
            val samples = out.samples[ch]
            for (n in 0 until copy) {
                samples[n] = data[ch][pos + n]
            }
        }
        pos += copy
        return copy
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy