Skip to main content

Stream buffering and event triggering for unbalanced frame sizes.

Project description


Stream buffering and event triggering for unbalanced frame sizes.

Use Case

Audio Processing

You want to stream audio from a microphone and extract a set of independent features as well as writing audio to file. Each of these feature extractors have a different audio chunk size required.

Instead of manually handling the buffer sizes, you can use this class and it will handle it for you.


import ocycle

# some data to generate
SOME_DATA = 'asdfghjkl;'

# how full should the buffer be before emitting data

# a data consumer
def processor(size):
    # this is called when the buffer reaches/exceeds size.
    def callback(buff, t0):
        value = buff.getvalue()
        assert len(value) >= CONSUME_SIZE
        print('Emitting:', t0, value)

    return ocycle.BufferEmit(callback, size)

proc = processor(CONSUME_SIZE)

# a generator then writes to the buffer.
# once it is full enough it will call
while True:
    print('Writing to buffer:', SOME_DATA)

Project details

Release history Release notifications

Download files

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

Files for ocycle, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size ocycle-0.0.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page