dtchat-headless gains --call, --audio-in FILE and --audio-out FILE: it exchanges media-key on the ready link, calls the peer, answers an incoming ring (it is a test peer, so the answer is automatic), and pumps the call from its loop: a 20 ms frame from the raw s16le 48 kHz file is encoded and sent while in the call, received frames are decoded into the output file, and call/audio events go to stdout. tests/p2p-audio.sh starts two instances (A listens and records, B connects, calls and plays tests/tone.py's 2 s 440 Hz tone), waits for both in-call, for 100 received frames, prints the CPU time of both, quits them and has tests/tone-check.py verify the recording (length within 25 percent, RMS > 500, zero crossings within 15 percent). Standalone run: A 45475, both in-call, recording 2.00 s / RMS 6339 / 441 Hz, all ok. Wired into the harness as DtChat/p2p-audio (42 entries). In-tree build pending: a foreign make userland holds the lock.
25 lines
576 B
Python
Executable File
25 lines
576 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""tests/tone.py -- write a sine tone as raw s16le mono 48 kHz.
|
|
|
|
usage: tone.py FILE SECONDS [HZ]
|
|
"""
|
|
import math
|
|
import struct
|
|
import sys
|
|
|
|
|
|
def main():
|
|
path = sys.argv[1]
|
|
seconds = float(sys.argv[2]) if len(sys.argv) > 2 else 2.0
|
|
hz = float(sys.argv[3]) if len(sys.argv) > 3 else 440.0
|
|
rate = 48000
|
|
n = int(seconds * rate)
|
|
with open(path, "wb") as f:
|
|
for i in range(n):
|
|
v = int(math.sin(2.0 * math.pi * hz * i / rate) * 9000)
|
|
f.write(struct.pack("<h", v))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|