diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-03-25 17:11:25 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-03-25 17:11:25 +0000 |
| commit | 1cd4f29bbb6a1f79bc75ca345e28b0fd4a86f20d (patch) | |
| tree | aa76234b06a42cd77bfd8e01e30130e9de0a03c5 | |
| parent | 8c59a7a79622519e3895fa2d3262d7a0a97468fd (diff) | |
much progress with audio format
| -rwxr-xr-x | rotord/rotor.h | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index 651144c..e16520b 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -360,16 +360,39 @@ namespace Rotor { void init(int _channels,int _bits,int _samples) { base_audio_processor::init(_channels,_bits,_samples); samples_per_column=samples/width; - stored_data=new uint8_t[samples_per_column*channels*2]; + stored_data=new uint8_t[samples_per_column*channels*(bits>>3)]; + sample=0; } - bool process_frame(uint8_t *data,int samples){ - + bool process_frame(uint8_t *data,int samples_in_frame){ + //begin by processing remaining samples + //samples per column could be larger than a frame! (probably is) + //but all we are doing is averaging + int bytes=(bits>>3); + int stride=channels*bytes; + int next_sample=0; + uint64_t accum; + while (next_sample<samples_in_frame) { + while (sample<samples_in_column&&next_sample<samples_in_frame) { + //do the accumulation + for (int i=0;i<channels;i++) { + int this_val=0; + for (int j=0;j<bytes;j++) { + this_val+=data[(sample*stride)+(i*bytes)+j]<<j; + } + accum+=this_val*this_val; + next_sample++; + sample++; + } + } + } do; + + } do; return true; } uint8_t *data; uint8_t *stored_data; int height,width,samples_per_column; - int samples_left; + int sample; }; class Render_context: public Poco::Task { //Poco task object //manages a 'patchbay' |
