reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofSoundUtils.h
Go to the documentation of this file.
1/*
2 * ofSoundUtils.h
3 *
4 * Created on: 30/07/2012
5 * Author: arturo
6 */
7
8#ifndef OFSOUNDUTILS_H_
9#define OFSOUNDUTILS_H_
10
11#include "ofMath.h"
12#include "ofSoundBuffer.h"
13#include <glm/gtc/constants.hpp>
14#include "glm/common.hpp"
15
16inline void ofStereoVolumes(float volume, float pan, float & left, float & right){
17 pan = ofClamp(pan, -1, 1);
18 // calculates left/right volumes from pan-value (constant panning law)
19 // see: Curtis Roads: Computer Music Tutorial p 460
20 // thanks to jasch
21
22 float angle = pan * glm::quarter_pi<float>(); // in radians from -45. to +45.
23 float cosAngle = cos(angle);
24 float sinAngle = sin(angle);
25
26
27 left = (cosAngle - sinAngle) * glm::one_over_root_two<float>() * volume; // multiplied by sqrt(2)/2
28 right = (cosAngle + sinAngle) * glm::one_over_root_two<float>() * volume; // multiplied by sqrt(2)/2
29}
30
31#endif /* OFSOUNDUTILS_H_ */
float ofClamp(float value, float min, float max)
Clamp a value between min and max.
Definition ofMath.cpp:120
void ofStereoVolumes(float volume, float pan, float &left, float &right)
Definition ofSoundUtils.h:16