This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.media.AudioFormat | |
import android.media.AudioRecord | |
import android.media.MediaRecorder | |
import java.io.IOException | |
import java.io.InputStream | |
class AudioInputStream( | |
audioSource: Int = MediaRecorder.AudioSource.DEFAULT, | |
sampleRate: Int = 44100, | |
channelConfig: Int = AudioFormat.CHANNEL_IN_MONO, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.foundation.interaction.collectIsDraggedAsState | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.PaddingValues | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.LaunchedEffect | |
import androidx.compose.runtime.getValue | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.unit.dp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RingBuffer(val capacity: Int) { | |
private val storage = ByteArray(capacity) | |
/** | |
* Convenient version of [read]. | |
* This method allocates new array every time. Do not use this in heavy loop. | |
* | |
* @param startPosition Start position. Can be over than capacity. | |
* @param size Result data size. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.TypeEvaluator; | |
import android.graphics.Matrix; | |
public class MatrixEvaluator implements TypeEvaluator<Matrix> { | |
private Matrix evaluated = new Matrix(); | |
private float[] values = new float[9]; | |
private float[] startValues = new float[9]; | |
private float[] endValues = new float[9]; | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('ModalCenter', []).directive('modalDialog', function($window) { | |
return { | |
restrict: 'C', | |
link: function(scope, element, attrs) { | |
var win = $($window); | |
win.on('resize', modalCenter); | |
function modalCenter() { | |
element.css('margin-top', (win.height() - element.height()) * 0.5 + 'px'); | |
} | |
modalCenter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.SeekBar; | |
public class FloatSeekBar extends SeekBar { | |
private float max = 1.0f; | |
private float min = 0.0f; | |
public FloatSeekBar(Context context, AttributeSet attrs, int defStyle) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AudioTrack { | |
private val bufferSize: Int // some value depends on environment | |
private val writeBuffer = FloatArray(bufferSize / 4) // actual buffer to send to audio device | |
private var writeOffset = 0 // current offset to write next buffer | |
fun write(data: FloatArray, offset: Int, size: Int) { | |
val remainingWriteBufferSize = writeBuffer.size - writeOffset | |
if (remainingWriteBufferSize >= size) { | |
System.arraycopy(data, offset, writeBuffer, writeOffset, size) | |
writeOffset += size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<String, dynamic> deepMergeMap(Map<String, dynamic> a, Map<String, dynamic> b) { | |
b.forEach((k, v) { | |
if (!a.containsKey(k)) { | |
a[k] = v; | |
} else { | |
// TODO handle List type | |
if (a[k] is Map) { | |
deepMergeMap(a[k], b[k]); | |
} else { | |
a[k] = b[k]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.arch.lifecycle.LiveData | |
import android.content.Context | |
import android.hardware.Sensor | |
import android.hardware.SensorEvent | |
import android.hardware.SensorEventListener | |
import android.hardware.SensorManager | |
data class Orientation( | |
val azimuth: Float, | |
val pitch: Float, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.media.MediaPlayer; | |
import org.androidannotations.annotations.AfterViews; | |
import org.androidannotations.annotations.Bean; | |
import org.androidannotations.annotations.EActivity; | |
import org.androidannotations.annotations.ViewById; | |
import org.rajawali3d.view.SurfaceView; | |
import java.io.IOException; |
NewerOlder