Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Utilities.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014, The Cinder Project
3 
4  This code is intended to be used with the Cinder C++ library, http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22  */
23 
24 #pragma once
25 
26 #include "cinder/audio/Buffer.h"
27 #include "cinder/CinderMath.h"
28 
29 #include <string>
30 
31 namespace cinder { namespace audio {
32 
34 float linearToDecibel( float gainLinear );
36 void linearToDecibel( float *array, size_t length );
38 float decibelToLinear( float gainDecibels );
40 void decibelToLinear( float *array, size_t length );
41 
45 float freqToMidi( float freq );
47 float midiToFreq( float midi );
48 
50 bool thresholdBuffer( const Buffer &buffer, float threshold, size_t *recordFrame = nullptr );
51 
52 } } // namespace cinder::audio
float midiToFreq(float midi)
Scale midi from MIDI note values to frequency (hertz). Adapted from Pure Data's mtof function...
Definition: Utilities.cpp:68
float freqToMidi(float freq)
Scale freq from frequency (hertz) to MIDI note values, so as one can refer to pitches using the equal...
Definition: Utilities.cpp:60
bool thresholdBuffer(const Buffer &buffer, float threshold, size_t *recordFrame=nullptr)
Checks if the absolute value of any sample in buffer is over threshold. Optionally provide recordFram...
Definition: Utilities.cpp:74
GLuint buffer
Definition: GLee.h:2065
GLuint GLsizei GLsizei * length
Definition: GLee.h:2313
float linearToDecibel(float gainLinear)
Scale gainLinear from linear (0-1) to decibel (0-100) scale.
Definition: Utilities.cpp:32
float decibelToLinear(float gainDecibels)
Scale gainLinear from decibel (0-100) to linear (0-1) scale.
Definition: Utilities.cpp:46
BufferT< float > Buffer
Definition: Buffer.h:285
void threshold(SurfaceT< T > *surface, T value, const Area &area)
Thresholds surface setting any values below value to zero and any values above to unity inside the Ar...
Definition: Threshold.cpp:100