http, pcspeaker driver

Former-commit-id: a3ad38695e8c1e1040a6a3f4b8470217e8a98489
Former-commit-id: cd3809edcae7b26e7b3d846dab17f1f63761f30f
This commit is contained in:
Song Minjae
2016-09-29 23:04:04 +09:00
parent 793bca4b55
commit 1b4aca320f
35 changed files with 678 additions and 385 deletions

View File

@@ -318,7 +318,7 @@ open class SimpleTextTerminal(
* @param duration: milliseconds
* @param freg: Frequency (float)
*/
override fun emitTone(duration: Int, freq: Float) {
override fun emitTone(duration: Int, freq: Double) {
// println("!! Beep playing row $beepCursor, d ${Math.min(duration, maxDuration)} f $freq")
host.clearBeepQueue()
host.enqueueBeep(duration, freq)
@@ -328,19 +328,19 @@ open class SimpleTextTerminal(
override fun bell(pattern: String) {
host.clearBeepQueue()
val freq: Float =
val freq: Double =
if (host.luaJ_globals["computer"]["bellpitch"].isnil())
1000f
1000.0
else
host.luaJ_globals["computer"]["bellpitch"].checkdouble().toFloat()
host.luaJ_globals["computer"]["bellpitch"].checkdouble()
for (c in pattern) {
when (c) {
'.' -> { host.enqueueBeep(80, freq); host.enqueueBeep(50, 0f) }
'-' -> { host.enqueueBeep(200, freq); host.enqueueBeep(50, 0f) }
'=' -> { host.enqueueBeep(500, freq); host.enqueueBeep(50, 0f) }
' ' -> { host.enqueueBeep(200, 0f) }
',' -> { host.enqueueBeep(50, 0f) }
'.' -> { host.enqueueBeep(80, freq); host.enqueueBeep(50, 0.0) }
'-' -> { host.enqueueBeep(200, freq); host.enqueueBeep(50, 0.0) }
'=' -> { host.enqueueBeep(500, freq); host.enqueueBeep(50, 0.0) }
' ' -> { host.enqueueBeep(200, 0.0) }
',' -> { host.enqueueBeep(50, 0.0) }
else -> throw IllegalArgumentException("Unacceptable pattern: $c (from '$pattern')")
}
}