diff options
| author | Comment <tim@gray.(none)> | 2013-03-28 20:30:36 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-03-28 20:30:36 +0000 |
| commit | 907174f130b4c2c74c6c9b2d9411b17affec2212 (patch) | |
| tree | 1ec8e4f259c7285cbb52cbf71b9bdc062416455e /rotord | |
| parent | 5c5e42a26df6bd5afa05750967352ffa15a67e29 (diff) | |
cracked audio sampling?
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/rotor.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 36cc6f3..2ab5734 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -643,7 +643,7 @@ void audio_thumbnailer::init(int _channels,int _bits,int _samples) { samples_per_column=samples/width; column=0; //point thumbnail bitmap out_sample=0; //sample in whole track - offset=(int)(pow(2.0,bits)/2.0); + offset=0x1<<(bits-1); //signed audio scale=1.0/offset; } int audio_thumbnailer::process_frame(uint8_t *_data,int samples_in_frame){ @@ -666,8 +666,10 @@ int audio_thumbnailer::process_frame(uint8_t *_data,int samples_in_frame){ } //convert from integer data format - i.e s16p - to audio signal in -1..1 range //don't know how many bytes we are dealing with necessarily? - double val=((double)(this_val-offset))*scale; - accum+=(val*val); + //double val=((double)(this_val-offset))*scale; + if (this_val>offset) this_val=-(this_val-(offset*2)); + double val=((double)this_val)*scale; + accum+=abs(val); //(val*val); samples++; } in_sample++; @@ -675,7 +677,7 @@ int audio_thumbnailer::process_frame(uint8_t *_data,int samples_in_frame){ out_sample++; } //get root-mean - double mean=pow(accum/samples,0.5); + double mean=accum/samples; //pow(accum/samples,0.5); int colheight=height*mean*0.5; int hh=height>>1; for (int i=0;i<height;i++) { |
