TachyAudio
Precise sound timing for Python experiments.
TachyAudio lets you play sounds, record audio, and decide exactly when a sound should start. It was created for TachyPy and for experiments where a few milliseconds can change the meaning of a result. You can also use it on its own in any Python project.
Why TachyAudio exists
Playing a sound is easy. Starting it at a precise, repeatable time—while Python is also drawing stimuli, reading responses, or preparing the next trial—is harder.
TachyAudio lets you prepare a sound in advance and give it a start time. Its compiled audio engine then handles playback using the sound device's clock. Python does not need to wake up at the instant the sound begins.
That gives you:
- Precise timing: schedule sounds for a particular moment, including while Python is busy doing other work.
- Reliable sequences: queue up to 32 sounds, place them back to back, or let them overlap. Overlapping sounds are mixed automatically.
- Visible failures: a sound whose scheduled start can no longer be met is reported as a failure, so you can identify an invalid trial.
- Playback and recording: use a simple function for one sound, or keep a stream open for a whole experiment.
- Straightforward installation: macOS, Linux, and Windows support, with no separate PortAudio installation. The core package has no Python dependencies.
How precise is it?
TachyAudio is built for exceptionally consistent sound timing. In the documented Linux tests, scheduled starts landed within one audio sample on the device's clock: less than 21 microseconds at 48 kHz, or 6 microseconds at 192 kHz.
A separate recording test through a USB wireless headset measured start-time variation of 69 microseconds, compared with 3.4 milliseconds through the ordinary system audio path—about 50 times less variation on that setup.
The sample-placement figures are device-clock estimates; the headset result was measured from recorded sound. Device choice, connection, and workload affect the results. See the measurements and test conditions for the details, including tests under heavy CPU load.
Install
python -m pip install tachyaudio
Supports Python 3.10–3.14 on macOS, Linux, and Windows. NumPy arrays work too, but NumPy is optional: the examples below use Python's built-in tools.
Play your first sound
This creates a quiet, quarter-second tone and plays it through the default output.
import math
from array import array
import tachyaudio as ta
sample_rate = 48000
frequency = 440
seconds = 0.25
tone = array("f", (
0.05 * math.sin(2 * math.pi * frequency * i / sample_rate)
for i in range(round(sample_rate * seconds))
))
ta.play(tone, sample_rate=sample_rate, channels=1)
ta.play() waits for playback to finish and releases the device. For precisely
scheduled starts, use ScheduledOutputStream below.
Audio buffers contain 32-bit floating-point samples, normally between -1 and
1. channels=1 means mono; stereo buffers contain alternating left and right
samples. Set sample_rate to the rate of your audio.
Core classes
| Class | Use it to… |
|---|---|
ScheduledOutputStream |
Play sounds at chosen start times, with timing handled by the audio engine. The main choice for timing-sensitive experiments. |
OutputStream |
Keep an output open and supply audio as your program runs. |
InputStream |
Record from a microphone or another input. |
DuplexStream |
Play and record through one shared stream. |
DeviceInfo describes an available audio device. ScheduledTiming gives the
estimated timing of a scheduled sound. StreamStats reports playback/capture
counts and buffering problems. Configuration and full-duplex results also have
named types: StreamConfig, DuplexStreamConfig, and DuplexStreamStats.
Schedule two sounds
This example reuses tone and sample_rate from the first example. The two
sounds start half a second apart, without Python needing to run at either start.
On macOS and Windows, device_id=None selects the default output. On
Linux, choose a free hardware output from ta.list_alsa_outputs() and put
its device_id in the example. Scheduled Linux playback needs that device to
be available for exclusive use.
import time
# On Linux, replace None with an id from ta.list_alsa_outputs().
device_id = None
with ta.ScheduledOutputStream(
sample_rate=sample_rate,
channels=1,
device_id=device_id,
) as audio:
start = time.monotonic() + audio.lead_time + 0.1
first = audio.schedule(tone, when=start)
second = audio.schedule(tone, when=start + 0.5)
timing = audio.wait(stimulus=first, timeout=3)
audio.wait(stimulus=second, timeout=3)
print(f"Estimated first-start error: {timing.predicted_error_seconds * 1e6:.1f} µs")
lead_time is the advance notice the device needs. Schedule ahead of that
limit; keep the stream open across trials to avoid repeatedly opening the device.
Use audio.cancel(stimulus) to cancel a queued sound, or audio.cancel() for all
queued sounds. Samples already sent to the device cannot be recalled.
For scheduled playback, the device must support your sample rate. On Windows,
use the output's current sample rate, commonly 48 kHz, and leave latency unset.
Platform setup: macOS,
Linux, Windows.
Record one second
import tachyaudio as ta
with ta.InputStream(sample_rate=48000, channels=1) as microphone:
recording = microphone.read_exactly(48000, timeout=3)
print(f"Recorded {len(recording) // 4} mono samples")
read_exactly() waits for the requested number of samples. For a live input
loop, read(frame_count) returns whatever audio is available, up to that amount.
Keep playback running
Reuse tone from the first example to send multiple buffers through one output.
with ta.OutputStream(sample_rate=sample_rate, channels=1) as audio:
audio.write_all(tone, timeout=3)
audio.write_all(tone, timeout=3)
if not audio.drain(timeout=3):
raise TimeoutError("Playback did not finish in time")
write_all() waits until the whole buffer has been accepted. drain() waits
for queued audio to finish. This is useful for continuous playback; use
ScheduledOutputStream when the start times themselves matter.
Play and record together
This also reuses tone and sample_rate from the first example.
with ta.DuplexStream(
sample_rate=sample_rate,
input_channels=1,
output_channels=1,
) as audio:
audio.write_all(tone, timeout=3)
recording = audio.read_exactly(len(tone), timeout=3)
Choose a device
import tachyaudio as ta
for device in ta.list_devices():
print(device.id, device.name, device.kind.value, device.default_sample_rate)
Pass an output or input id as device_id to the corresponding stream. A
DuplexStream accepts separate input_device_id and output_device_id values.
For Linux scheduled output, use ta.list_alsa_outputs() instead.
Go further
- Play a WAV file, including an optional live level meter.
- Capture and inspect microphone levels.
- Schedule sounds and inspect timing.
- Find low-latency settings for your machine.
- Validate physical onset with a wired loopback.
- Public API stability and testing.
TachyAudio is the audio engine behind TachyPy, which combines sound with visual stimuli and response handling for experiments.
Metadata
Release files for tachyaudio 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tachyaudio-1.0.0.tar.gz | 764.7 kB | Without provenance | Details for tachyaudio-1.0.0.tar.gz |
Built distributions (wheels)
Total release size: 19.5 MB
Release files / tachyaudio-1.0.0.tar.gz
| Download URL | tachyaudio-1.0.0.tar.gz |
|---|---|
| Size | 764.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d39639366927a14313cbbf08bc4a7c5f8283b1f1b7947f8788d340e16ebf4c16
|
|
BLAKE2b-256 checksum How to use checksums |
fcc0e37667777179ec9017c146dcd6514c824e6da71d27fbb3fb5d649697eef7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp314-cp314-win_amd64.whl
| Download URL | tachyaudio-1.0.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 810.5 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0baeaceb07c778e4313d8adc71dc0f848b9c7c9b4c315ca28147a99013ed3c6f
|
|
BLAKE2b-256 checksum How to use checksums |
10a666f043451eea3ff4f5437ee1b399fcb91d2b0fda72749c283d4acd6075f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
94bcf6393c6563733aa563028e68cc5585ff520dea5fd0512c5e890fdcb4bbc1
|
|
BLAKE2b-256 checksum How to use checksums |
8c324f8881b5aaa9e7c59f67cefde21d05a6b853e80ea2cc89b8983423c63998
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | tachyaudio-1.0.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 739.9 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e5d6888967b540adaba6bfdb142fc50a33994336c4aacf867bce181cce92a3ab
|
|
BLAKE2b-256 checksum How to use checksums |
5a6e4eb8be62c77651af32450e3c1c2538571c1844c0a8e965fc8e18616961fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp314-cp314-macosx_10_15_x86_64.whl |
|---|---|
| Size | 740.0 kB |
| Tags | CPython 3.14 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
6a0a9712d5546d3ab58a90d02c7ec63cea56f5010b61f1d140033cd0c41df5e2
|
|
BLAKE2b-256 checksum How to use checksums |
012144764a2d2cfafb584548cc7589b491ebacc00c689482fddb3f5a01cc28ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp313-cp313-win_amd64.whl
| Download URL | tachyaudio-1.0.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 811.1 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4b599a86f2fa20aacaeda1b7b38c96e82d8b1deb53ba05a327aa0c953823b66c
|
|
BLAKE2b-256 checksum How to use checksums |
08897ae3055e58f4de04c2e122c829418257cc1da42cccc53b9e2554e6f15d46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d2717795cae481402b2509633872a7bcdaf587ede6fb76ec77b0da16dc02f433
|
|
BLAKE2b-256 checksum How to use checksums |
8f9c764faefe4bd261d11cd61062c86db1571c76ee3cb2cfb489064c78b8dea0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | tachyaudio-1.0.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 739.9 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ec229e25dec67a5b2fede50fda5d4323cb2be51cf3c5814bffd2e2c394b78cb8
|
|
BLAKE2b-256 checksum How to use checksums |
965359197ba4ef99a7c7af8acbaa2795b6c62c1d0b703ecef2c6be422aeb5655
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 740.0 kB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
3691af2edcdc97abf33dc8e76830f55dee191933ec62b96ff85dc6606fcb9a54
|
|
BLAKE2b-256 checksum How to use checksums |
ddcdcb38910bbf4a75f1b52ea3ff7c7190c4daeae49aa9026f8a635e391ddce7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp312-cp312-win_amd64.whl
| Download URL | tachyaudio-1.0.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 811.1 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a86d8598452a7e0b237152171d04782aeef3c66a4d2251c62b4159217243448a
|
|
BLAKE2b-256 checksum How to use checksums |
3e93c68f3754a7c632569a65ac9bab8dc57c2711475d44d7673614d4001206b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9ee08dbac8c0556d05b6b76fe4f3582855ace1c155badcf4e5176bbb0d3b87d1
|
|
BLAKE2b-256 checksum How to use checksums |
d964b06a3eae4687b09745c50cf7dc152bd526d46a6a3dd507542390c59bbac5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | tachyaudio-1.0.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 739.9 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8ae448fe831c6913912a29daa39f7358dbe46fc33568a171f1e8c1e2e910fca3
|
|
BLAKE2b-256 checksum How to use checksums |
1abc844c454d4e1a845e4b0a12e19ca558436151500bdb99002adfa38e69b3c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 740.0 kB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
18f1d3de290dcb5ca2020ca37b480252d6a7460ddf5b4bb6339bccad4de5d28a
|
|
BLAKE2b-256 checksum How to use checksums |
488a7072f9f1f47320ce1818a671ec3889a9318067826cd5ee14db77053bae06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp311-cp311-win_amd64.whl
| Download URL | tachyaudio-1.0.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 811.1 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7a90dc645f38f6c9d8cdaea280bc8efcda90c4b8af2bddbd25052543f64321e6
|
|
BLAKE2b-256 checksum How to use checksums |
79f7464654523214d0c0e08378c6130c3d3c3f0d491b07382bc52e85df64dd0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
81e90cfc976aeeeae8a69ff500cdd9b8f1dfe586bc00da14bd698cad14037174
|
|
BLAKE2b-256 checksum How to use checksums |
3f72a7353ce5e7d3350ebd537c64fd41ac050928edeebb28e6644d77ecd7e6ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | tachyaudio-1.0.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 739.7 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1c3b64e196c51258017000602ca305b7b4c39e6499f06fa59518f523ba0389b1
|
|
BLAKE2b-256 checksum How to use checksums |
b15fc82a9615d576c103215cf48c95ed8d26dfdfe44ae0b5e80eb09ccf5ecc53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 739.7 kB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
5a86dbf47d0b7389332f2e2051927ca80e3f4c100db5f86cc1cd8155c6cbe433
|
|
BLAKE2b-256 checksum How to use checksums |
da188a2c17c3262edf74c153eb7eace4bf755fe27ca73f6fdc60246f5f10d1d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp310-cp310-win_amd64.whl
| Download URL | tachyaudio-1.0.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 811.1 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5c928a34f05a65a43dc140b2c0b38e56eff71e6ed09abefc4276c5244f70b26d
|
|
BLAKE2b-256 checksum How to use checksums |
07e078b7fa483ae112c601acf7ede94fceeee2f5074765cb59ddc391e5b58966
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3ddfd58005fafc45e1fa715929ff223d0c026b719ba74636c84febad9536a054
|
|
BLAKE2b-256 checksum How to use checksums |
f21fe9db8a5101494c233a1a243749740a4e52c86bad5611e1301a9ded690feb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | tachyaudio-1.0.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 739.7 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2de46791cd5f0d03918d31090615d83d66c8bf5d1aacc7e70c9fff5622974245
|
|
BLAKE2b-256 checksum How to use checksums |
bb0924964f91d1cb352edc6b877c7e65f0a50c1c6311860257d8bd4008f33876
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / tachyaudio-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | tachyaudio-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 739.7 kB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
f0e8efa2a2dbdc6bae0dc43bf56966f923f9a5c9d9991f4b9d319dd4d3cfaf5f
|
|
BLAKE2b-256 checksum How to use checksums |
c8d342f325acc3ace5a52cb2039f0e7bbb99a12b8f946573697318851f4deb12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for tachyaudio 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.