diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-10-10 18:59:13 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-10-10 18:59:13 +0400 |
commit | 9cabc57a62e8db17edd09839d7ae200239fb3618 (patch) | |
tree | b4c7e8637fa0b37cb79100217f09dc8fd723acfd /intern/audaspace | |
parent | 21a755b4f50413e7c1404896b0d78e599bad9c65 (diff) |
Sequencer audio waveform drawing fix, now assured to be within the strip bounds.
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index d5c3e368e28..af053df9c50 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -1094,9 +1094,11 @@ int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length, int samples_pe specs.specs = reader->getSpecs(); int len; float samplejump = specs.rate / samples_per_second; - float min, max, power; + float min, max, power, overallmax; bool eos; + overallmax = 0; + for(int i = 0; i < length; i++) { len = floor(samplejump * (i+1)) - floor(samplejump * i); @@ -1121,6 +1123,11 @@ int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length, int samples_pe buffer[i * 3 + 1] = max; buffer[i * 3 + 2] = sqrt(power) / len; + if(overallmax < max) + overallmax = max; + if(overallmax < -min) + overallmax = -min; + if(eos) { length = i; @@ -1128,6 +1135,14 @@ int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length, int samples_pe } } + if(overallmax > 1.0f) + { + for(int i = 0; i < length * 3; i++) + { + buffer[i] /= overallmax; + } + } + return length; } |