Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port audio engine to kotlin #112

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions module/audio/src/main/java/org/openbase/jul/audio/AudioData.java

This file was deleted.

15 changes: 15 additions & 0 deletions module/audio/src/main/java/org/openbase/jul/audio/AudioData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.openbase.jul.audio

import javax.sound.sampled.AudioFormat

/**
*
* @author [Divine Threepwood](mailto:[email protected])
*/
interface AudioData : AudioSource {
val data: ByteArray

val format: AudioFormat

val dataLength: Long
}

This file was deleted.

44 changes: 44 additions & 0 deletions module/audio/src/main/java/org/openbase/jul/audio/AudioDataImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.openbase.jul.audio

import org.openbase.jul.exception.CouldNotPerformException
import java.io.File
import javax.sound.sampled.AudioFormat
import javax.sound.sampled.AudioSystem

/**
*
* @author [Divine Threepwood](mailto:[email protected])
*/
class AudioDataImpl : AudioData {
override val data: ByteArray
override val format: AudioFormat
override val dataLength: Long

constructor(data: ByteArray, format: AudioFormat, dataLength: Long) {
this.data = data
this.format = format
this.dataLength = dataLength
}

constructor(soundFile: File) {
if (!soundFile.exists()) {
throw CouldNotPerformException("AudioFile is missing!")
}

AudioSystem.getAudioInputStream(soundFile).use { ais ->
this.dataLength = ais.frameLength
this.format = ais.format
this.data = ByteArray(ais.frameLength.toInt() * format.frameSize)
val buf = ByteArray(AudioPlayer.BUFSIZE)
var i = 0
while (i < data.size) {
var r = ais.read(buf, 0, AudioPlayer.BUFSIZE)
if (i + r >= data.size) {
r = data.size - i
}
System.arraycopy(buf, 0, data, i, r)
i += AudioPlayer.BUFSIZE
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.openbase.jul.audio

import java.io.File

/**
*
* @author [Divine Threepwood](mailto:[email protected])
*/
interface AudioFileHolder : AudioSource {
val file: File
}
149 changes: 0 additions & 149 deletions module/audio/src/main/java/org/openbase/jul/audio/AudioPlayer.java

This file was deleted.

Loading
Loading