Grapher package

Core module

class timeside.core.grapher.DisplayAnalyzer(width=1024, height=256, bg_color=(0, 0, 0), color_scheme='default')[source]

Bases: timeside.core.grapher.Grapher

image from analyzer result This is an Abstract base class

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

post_process()[source]

Post-Process data after processign the input frames with process()

Processors such as analyzers will produce Results during the Post-Process

process(frames, eod=False)[source]

Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.

Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.

Warning: it is required to call setup() before this method.

class timeside.core.grapher.Grapher(width=1024, height=256, bg_color=None, color_scheme='default')[source]

Bases: timeside.core.processor.Processor

Generic abstract class for the graphers

draw_anti_aliased_pixels(x, y1, y2, color)[source]

vertical anti-aliasing at y1 and y2

draw_peaks(x, peaks, line_color)[source]

Draw 2 peaks at x

draw_peaks_inverted(x, peaks, line_color)[source]

Draw 2 inverted peaks at x

render(output=None)[source]

Return a PIL Image object visually representing all of the data passed by repeatedly calling process() and write the image to the output if specified

class timeside.core.grapher.Spectrum(fft_size, samplerate, blocksize, totalframes, lower, higher, window_function=None)[source]

Bases: object

FFT based frequency analysis of audio frames.

process(frames, eod, spec_range=120.0)[source]

Returns a tuple containing the spectral centroid and the spectrum (dB scales) of the input audio frames. FFT window sizes are adatable to the input frame size.

Graphers

Waveform

class timeside.plugins.grapher.waveform_simple.Waveform(width=1024, height=256, bg_color=(255, 255, 255), color_scheme='default')[source]

Bases: timeside.core.grapher.Grapher

Simple monochrome waveform image.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

post_process(output=None)[source]

Post-Process data after processign the input frames with process()

Processors such as analyzers will produce Results during the Post-Process

process(frames, eod=False)[source]

Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.

Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.

Warning: it is required to call setup() before this method.

setup(channels=None, samplerate=None, blocksize=None, totalframes=None)[source]

Allocate internal resources and reset state, so that this processor is ready for a new run.

The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.

WaveformCentroid

class timeside.plugins.grapher.waveform_centroid.WaveformCentroid(width=1024, height=256, bg_color=(0, 0, 0), color_scheme='default')[source]

Bases: timeside.plugins.grapher.waveform_simple.Waveform

Waveform where peaks are colored relatively to the spectral centroids of each frame buffer.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

process(frames, eod=False)[source]

Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.

Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.

Warning: it is required to call setup() before this method.

setup(channels=None, samplerate=None, blocksize=None, totalframes=None)[source]

Allocate internal resources and reset state, so that this processor is ready for a new run.

The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.

WaveformTransparent

class timeside.plugins.grapher.waveform_centroid.WaveformCentroid(width=1024, height=256, bg_color=(0, 0, 0), color_scheme='default')[source]

Bases: timeside.plugins.grapher.waveform_simple.Waveform

Waveform where peaks are colored relatively to the spectral centroids of each frame buffer.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

process(frames, eod=False)[source]

Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.

Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.

Warning: it is required to call setup() before this method.

setup(channels=None, samplerate=None, blocksize=None, totalframes=None)[source]

Allocate internal resources and reset state, so that this processor is ready for a new run.

The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.

WaveformContour

class timeside.plugins.grapher.waveform_contour.WaveformContourBlack(width=1024, height=256, bg_color=(0, 0, 0), color_scheme='default')[source]

Bases: timeside.plugins.grapher.waveform_simple.Waveform

Black amplitude contour waveform.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

process(frames, eod=False)[source]

Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.

Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.

Warning: it is required to call setup() before this method.

setup(channels=None, samplerate=None, blocksize=None, totalframes=None)[source]

Allocate internal resources and reset state, so that this processor is ready for a new run.

The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.

class timeside.plugins.grapher.waveform_contour.WaveformContourWhite(width=1024, height=256, bg_color=(255, 255, 255), color_scheme='default')[source]

Bases: timeside.plugins.grapher.waveform_contour.WaveformContourBlack

an white amplitude contour wavform.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

SpectrogramLog

class timeside.plugins.grapher.spectrogram_log.SpectrogramLog(width=1024, height=256, bg_color=(0, 0, 0), color_scheme='default')[source]

Bases: timeside.core.grapher.Grapher

Logarithmic scaled spectrogram (level vs. frequency vs. time).

Adds pixels iteratively thanks to the adapter providing fixed size frame buffers.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

post_process()[source]

Apply last 2D transforms

process(frames, eod=False)[source]

Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.

Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.

Warning: it is required to call setup() before this method.

set_scale()[source]

generate the lookup which translates y-coordinate to fft-bin

setup(channels=None, samplerate=None, blocksize=None, totalframes=None)[source]

Allocate internal resources and reset state, so that this processor is ready for a new run.

The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.

SpectrogramLin

class timeside.plugins.grapher.spectrogram_lin.SpectrogramLinear(width=1024, height=256, bg_color=(0, 0, 0), color_scheme='default')[source]

Bases: timeside.plugins.grapher.spectrogram_log.SpectrogramLog

Linear scaled spectrogram (level vs. frequency vs. time).

Adds pixels iteratively thanks to the adapter providing fixed size frame buffers.

Create a new grapher. width and height are generally in pixels but could be something else for eg. svg rendering, etc..

static id()[source]

Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…

static name()[source]

Return the graph name, such as “Waveform”, “Spectral view”, etc..

set_scale()[source]

generate the lookup which translates y-coordinate to fft-bin

setup(channels=None, samplerate=None, blocksize=None, totalframes=None)[source]

Allocate internal resources and reset state, so that this processor is ready for a new run.

The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.