Skip to content
A utility addon for OpenFrameworks that manages and smooths streams of data
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
LICENSE
README.md

README.md

ofxDataStream

A utility addon for OpenFrameworks that manages and smooths streams of data

Copyright (C) 2015 [Paul Turowski] (http://paulturowski.com)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

This utility class was developed as part of the Being In Time project under the direction of Judith Shatin at the University of Virginia. This project was funded by an Arts in Action grant from the University of Virginia. More info: [http://judithshatin.com/being-in-time/] (http://judithshatin.com/being-in-time/)

Description

This addon is designed to simplify the management of various groups of data that each have an arbitrary number of streams. For example, it might be used with streams of incoming audio data, such as spectral bands, or control data, like Kinect skeleton data. The class supports different types of smoothing, clamping, normalization, and threshold detection.

Installation

Using ofxDataStream requires [OpenFrameworks] (http://www.openframeworks.cc/) to be installed. To use ofxDataStream, simply copy the class to your OpenFrameworks addons folder, or cd to your addons folder and use the following command:

git clone https://github.com/turowskipaul/ofxDataStream.git

Basic Usage Examples

declaring instances:

ofxDataStream amp;
vector<ofxDataStream> specAmps;

initializing slide smoothing:

amp.initSlide(60, 20); // slide up, slide down

initializing accumulator smoothing:

amp.initAccum(100); // size of history

initializing clamping and/or normalization

amp.setOutputRange(0.2, 0.8); // clamp min and max (default 0 and 1)
amp.setNormalized(true, 0.2, 0.8); // normalization, min, max, clamped (optional, default true)

set a threshold:

amp.setThresh(0.5);

get a threshold crossing:

amp.getTrigger(0); // index (optional)

update with incoming values:

amp.update(rawAmplitude, 0); // raw value, index (optional)
specAmps.update(spectralAmplitudes); // or update with a const vector ref
amp.incrUpdate(rawAmplitudeDiff); //increment current value and update

get a smoothed value (update updating):

amp.getValue(0); // index (optional)
amp.getValueN(0); // get normalized value (index optional)

detect "bonks" (onsets):

amp.setBonk(0.1, 0.1);  // min growth for onset, min decay

set growth/decay:

amp.setDecayGrow(true, 0.99); // a framerate-dependent steady decay/growth

get direction change time (sec) and depth:

// if the direction has changed and
// if the time of change is greater than 0.5 sec
// print the time between changes and amount of change

if (inputStreams[0].getDirectionTimeDiff() > 0.5 &&
        inputStreams[0].directionHasChanged()) {
        ofLogNotice() <<
        "inputStream1 " << inputStreams[0].getDirectionTimeDiff() <<
        " " << inputStreams[0].getDirectionValDiff();
    }

Development

Bug reports, suggestions, and further development are all welcome.

You can’t perform that action at this time.