Skip to main content

No project description provided

Project description

https://travis-ci.org/tgarc/pastream.svg?branch=master https://ci.appveyor.com/api/projects/status/wk52r5jy9ri7dsi9/branch/master?svg=true

pastream - Portaudio Streams for Python

pastream builds on top of portaudio and the excellent sounddevice python bindings to provide some more advanced functionality right out of the box. Note that in addition to the pastream library, pastream includes a command line interface for playing and recording audio files.

Features

GIL-less Audio Callbacks

Having the portaudio callback implemented in C means audio interrupts can be serviced quickly and reliably without ever needing to acquire the Python Global Interpreter Lock (GIL). This is crucial when working with libraries like Pillow which may greedily grab and hold the GIL subsequently causing audio overruns/underruns.

Input Stream iterators

Efficiently retrieve live audio capture data through an iterable. As simple as:

import pastream as ps
for chunk in ps.chunks():
    # do stuff with chunked audio

See pastream.chunks and pastream.*Stream.chunks method.

Expanded State Machine

Adds the ability to differentiate whether a stream has been aborted or completed successfully even after the stream has finished.

Reader/Writer Threads

pastream simplifies the process of implementing stream reader and writer threads to manipulate and/or generate data in the background while leaving the main thread free for higher level management tasks.

Dependencies

cffi

sounddevice (depends on PortAudio)

soundfile (depends on libsndfile)

(Optional) numpy

Installation

For linux platforms a recent version of the PortAudio and libsndfile C libraries are required. (For Windows and OSX, the sounddevice and soundfile packages include prebuilt versions for you). You can either install the latest available from your package manager (e.g. apt-get install libportaudio2 libsndfile for debian/raspbian) or install the latest stable build from the package website (Recommended); see links in Dependencies.

pastream is now available on PyPI. Installation is as easy as:

$ pip install pastream

Building From Source

To compile from source under unix platforms, libffi is required. (For Windows, this is already included with cffi). libffi is available through most package managers (e.g., yum install libffi-devel, apt-get install libffi-dev, brew install libffi). More information on installing libffi is available here.

Building Source

If doing a fresh checkout:

$ git clone --recursive http://github.com/tgarc/pastream

If you already have a checkout:

$ git submodule update --init

Then do a pip install from your working copy:

$ pip install <path/to/checkout>

Examples

Record to file:

import pastream as ps

with ps.SoundFileInputStream('recording.wav', device='my-device'):
    stream.start()
    stream.wait()

Grab (real) frequency transformed live audio stream with 50% overlap:

import pastream as ps, numpy as np

chunksize = 1024
window = np.hanning(chunksize)
for l, x_l in ps.chunks(chunksize, overlap=chunksize//2, channels=1):
    X_l = np.fft.rfft(x_l) * window

See also the included examples under pastream/examples.

Command Line Interface

Once installed, the pastream application should be callable from your command line. If you’re familiar with sox you’ll notice that some of the command line syntax is quite similar. Here are a few examples to help get you started.

Display the help file:

$ pastream -h

List available audio devices:

$ pastream -l

Simultaneous play and record from the default audio device:

$ pastream input.wav output.wav

Record only:

$ pastream null output.wav

Pipe input from sox using the AU format:

$ sox -n -t au - synth sine 440 | pastream - output.wav

Play a RAW file:

$ pastream null -c1 -r48k -e=pcm_16 output.raw

Record 10 seconds of audio at 48kHz:

$ pastream null output.wav -r48k -n=$(( 48000 * 10 ))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pastream-0.0.4rc2.tar.gz (40.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pastream-0.0.4rc2-cp36-cp36m-manylinux1_x86_64.whl (43.5 kB view details)

Uploaded CPython 3.6m

pastream-0.0.4rc2-cp36-cp36m-manylinux1_i686.whl (41.2 kB view details)

Uploaded CPython 3.6m

pastream-0.0.4rc2-cp36-cp36m-macosx_10_6_intel.whl (34.5 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

pastream-0.0.4rc2-cp35-cp35m-manylinux1_x86_64.whl (43.5 kB view details)

Uploaded CPython 3.5m

pastream-0.0.4rc2-cp35-cp35m-manylinux1_i686.whl (41.2 kB view details)

Uploaded CPython 3.5m

pastream-0.0.4rc2-cp35-cp35m-macosx_10_6_intel.whl (34.5 kB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

pastream-0.0.4rc2-cp34-cp34m-manylinux1_x86_64.whl (43.5 kB view details)

Uploaded CPython 3.4m

pastream-0.0.4rc2-cp34-cp34m-manylinux1_i686.whl (41.2 kB view details)

Uploaded CPython 3.4m

pastream-0.0.4rc2-cp34-cp34m-macosx_10_6_intel.whl (34.5 kB view details)

Uploaded CPython 3.4mmacOS 10.6+ Intel (x86-64, i386)

pastream-0.0.4rc2-cp27-cp27m-macosx_10_6_intel.whl (34.0 kB view details)

Uploaded CPython 2.7mmacOS 10.6+ Intel (x86-64, i386)

File details

Details for the file pastream-0.0.4rc2.tar.gz.

File metadata

  • Download URL: pastream-0.0.4rc2.tar.gz
  • Upload date:
  • Size: 40.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pastream-0.0.4rc2.tar.gz
Algorithm Hash digest
SHA256 3b810aed3e972579e6e311ecb8f03199523b652191cb8e9481a7c8097f72fe75
MD5 72f3be251976c65e63686ec8fd9f1010
BLAKE2b-256 5a5e123f9d61e6497648810c5c7e379a1c00d6600bbad0231bfd5f459f626961

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0d76c8bed26ef8c05551a95d11b22807bb0abcca1e29c5f0bb26897641b035c0
MD5 1d590e4c406e54438a1aa93a3ea22a77
BLAKE2b-256 d0efdc55b683dc904714ceb4484920998cea35385039b57bd03556f6b9bd7813

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 f2168bf29031d62527e48915543084f9ba318b01ace6b3fb80dadc80d762f1ed
MD5 bada23d8d081c5fa37165eb192c08a75
BLAKE2b-256 e3e8184f2e9de571a78783658c5a8905c302cf9085300df4d761a60b71cbe41c

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 fef3d30bf67fb2caa0fca67277ac1891ae81a0f2a56b8eda5c9bbc470aa1e9cf
MD5 fc6d1665ae4cc9983811047c46870007
BLAKE2b-256 0decf618efe3bbfd7869c8f71c94ff3b2c8e2f9dddb32b17adb1ce3915a81a7b

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 948e03f24633d119a2a5f5812183bdfe28c41e910ba5b472a2a71d94117b3a9f
MD5 02d9dc542e42a860775f346d8f7fb222
BLAKE2b-256 c8042ae947bbe706fa1caec5b4904a2928abfdf63e731e0905606d5ad49fae71

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ae956294e5d988088fbdaf9999359131a2db7b9b3ea97a581ebfc7b1a1fc13e6
MD5 b2bc50398c83aab5810690413d0703bd
BLAKE2b-256 273e3edf1cd30b4d860f145eb58c33f63bfeb9a2763585f05273b620d4eb7e0d

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a106137df7de2d1d06dc4f9d8f4a35eb90a7678c3f3c4d427058870cb1ba0606
MD5 41899191c0281dfcf76bf587f508cbfb
BLAKE2b-256 f3579b6e6a50c9e9c8db5b41c790a886306262b5588441d6c7b482ef0c4bc1ae

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0fca53495532e1ffad9d3cd655c8713bab96bb37f5a5cde7eaef57bd01d05afb
MD5 6e69f87bf7afa0866b63b81c1ffaeccd
BLAKE2b-256 9c3c7888e9a4ae65ec0c3b08c275185849ccfed4c6bb7afc0b4c7b18efc3fa07

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 860fee732842831fa983d4603f749d95154a9b37e5b0202e33bffc7818c00668
MD5 97b53abb8cc338845cdc1c9223b14b2b
BLAKE2b-256 8940ddda8b42404ae5de1f83f4210a4c5b0fdbe38f49857dcd4b6c5da8118ff2

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 e0abbb12c6feb969ca9816b4dd783ce77046e7b4a635f8c778176acff05715f9
MD5 429bbb7b79a183ab4bf80a061a824e5e
BLAKE2b-256 a1d2c5f242c60405d2577db75683ac103c4694a79b005d6f01b2d18c22fa112c

See more details on using hashes here.

File details

Details for the file pastream-0.0.4rc2-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pastream-0.0.4rc2-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 4e32826486de16e4939e06e0be7015f27164d4a0b3138668ed765a2c6178d2ee
MD5 82061754083e19c71e2cddb75b745a30
BLAKE2b-256 1726eb08a52ad4cd6b7cdc84bb65f6a4ab56d9b6d2b66dac58034c4a2ccb2be1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page