Skip to content

Commit 0c5beaf

Browse files
author
mars
committed
updated volts/octave class
1 parent eedeaab commit 0c5beaf

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

LibSource/VoltsPerOctave.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
#include <stdint.h>
66

77
VoltsPerOctave::VoltsPerOctave() : tune(0.0) {
8-
int32_t volts_offset, volts_scalar;
8+
int32_t volts_offset = 0, volts_scalar = 0;
99
void* args[] = {
1010
(void*)"VO", (void*)&volts_offset,
1111
(void*)"VS", (void*)&volts_scalar
1212
};
13-
int ret = getProgramVector()->serviceCall(OWL_SERVICE_GET_PARAMETERS, args, 2);
13+
int ret = getProgramVector()->serviceCall(OWL_SERVICE_GET_PARAMETERS, args, 4);
1414
if(ret == OWL_SERVICE_OK){
1515
multiplier = (float)volts_scalar/INT32_MAX;
1616
offset = (float)volts_offset/INT32_MAX;
@@ -32,6 +32,10 @@ VoltsPerOctave::VoltsPerOctave(float o, float m)
3232
void VoltsPerOctave::getFrequency(FloatArray samples, FloatArray output){
3333
ASSERT(output.getSize() >= samples.getSize(), "Output buffer too short");
3434
// todo: block based implementation
35+
// samples.add(-offset, output);
36+
// samples.multiply(multiplier, output);
37+
// for(int i=0; i<samples.getSize(); ++i)
38+
// output[i] = voltsToHertz(output[i]);
3539
for(int i=0; i<samples.getSize(); ++i)
3640
output[i] = getFrequency(samples[i]);
3741
}

LibSource/VoltsPerOctave.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include "FloatArray.h"
55
#include "basicmaths.h"
66

7+
/*
8+
* Converts samples into volts and frequencies, following 1V/octave tuning.
9+
* Tuned to 440Hz. Change base note with setTune(float octave).
10+
*/
711
class VoltsPerOctave {
812
private:
913
float offset;
@@ -20,13 +24,13 @@ class VoltsPerOctave {
2024
float getFrequency(float sample){
2125
return voltsToHerz(sampleToVolts(sample)+tune);
2226
}
23-
void getFrequency(FloatArray samples, FloatArray output);
2427
float sampleToVolts(float sample){
2528
return (sample-offset) * multiplier;
2629
}
2730
float voltsToHerz(float volts){
2831
return 440.f * powf(2, volts);
2932
}
33+
void getFrequency(FloatArray samples, FloatArray output);
3034
};
3135

3236
#endif /* __VoltsPerOctave_hpp__ */

0 commit comments

Comments
 (0)