feat: add neutral avatar video call MVP in Android 0.6.0
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import com.gorios.lanvoice.audio.PcmActivityTimeline
|
||||
import com.gorios.lanvoice.audio.PlaybackHead
|
||||
|
||||
fun publicTone(samples: Int, value: Int = 2000) = ByteArray(samples * 2).also {
|
||||
for (i in 0 until samples) { it[i*2] = value.toByte(); it[i*2+1] = (value shr 8).toByte() }
|
||||
}
|
||||
fun checkActivityTimeline() {
|
||||
val head = PlaybackHead()
|
||||
check(head.read(0xfffffff0.toInt()) == 0xfffffff0L)
|
||||
check(head.read(32) == 0x1_0000_0020L)
|
||||
head.reset(); check(head.read(0) == 0L)
|
||||
val activity = PcmActivityTimeline()
|
||||
activity.append(publicTone(300)); activity.append(publicTone(660)) // a cross-chunk 20ms window
|
||||
check(!activity.sample(0,960,0)) // writing and queueing do not open mouth
|
||||
check(!activity.sample(480,0,5)) // beyond accepted partial write never consumes activity
|
||||
check(activity.sample(480,480,10))
|
||||
check(activity.sample(960,960,20))
|
||||
check(activity.sample(960,960,139))
|
||||
check(!activity.sample(960,960,140)) // actual native underrun, TTS need not be ended
|
||||
activity.append(ByteArray(48_000/5*2))
|
||||
check(!activity.sample(10_560,10_560,240)) // 200ms silence closes
|
||||
activity.append(publicTone(960))
|
||||
check(activity.sample(11_520,11_520,260))
|
||||
activity.reset(); check(!activity.sample(0,0,270))
|
||||
activity.append(publicTone(100)) // final partial analysis window is playable immediately
|
||||
check(activity.sample(100,100,280))
|
||||
activity.reset(); activity.append(publicTone(960,100))
|
||||
check(!activity.sample(960,960,300)) // low noise under RMS and peak thresholds
|
||||
activity.reset()
|
||||
repeat(2000) { activity.append(publicTone(960)); check(activity.sample((it+1)*960L,(it+1)*960L,400+it*20L)) }
|
||||
check(activity.retainedWindows == 0) // continuous long playback prunes consumed metadata
|
||||
val bounded = PcmActivityTimeline(maxWindows=2)
|
||||
bounded.append(publicTone(1920))
|
||||
check(runCatching { bounded.append(publicTone(960)) }.isFailure)
|
||||
println("PASS: production PCM RMS/peak cross-block/partial/tail, no activity until playback head, silence/120ms underrun/resume/reset, u32 wrap and bounded/pruned metadata")
|
||||
}
|
||||
Reference in New Issue
Block a user