diff options
author | Robin Gareus <robin@gareus.org> | 2016-12-27 18:20:02 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-12-27 18:20:02 +0100 |
commit | 54a79639df0a72afaf26ed914901688ecdac8ed4 (patch) | |
tree | 364cb613631cc41ab656b7ef2f0af86b3f65ddad /libs/ardour/sndfilesource.cc | |
parent | 5bada6d5332937fca4071edc8f2b2f8c093e9af8 (diff) |
Allow gain factor for audio sources.
In preparation for archiving files as .flac (fixed point),
normalized with gain factor.
Diffstat (limited to 'libs/ardour/sndfilesource.cc')
-rw-r--r-- | libs/ardour/sndfilesource.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 54b9a0135c..2e7df7f918 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -523,6 +523,11 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con sf_error_str (0, errbuf, sizeof (errbuf) - 1); error << string_compose(_("SndFileSource: @ %1 could not read %2 within %3 (%4) (len = %5, ret was %6)"), start, file_cnt, _name.val().substr (1), errbuf, _length, ret) << endl; } + if (_gain != 1.f) { + for (framecnt_t i = 0; i < ret; ++i) { + dst[i] *= _gain; + } + } return ret; } } @@ -537,9 +542,16 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con /* stride through the interleaved data */ - for (framecnt_t n = 0; n < nread; ++n) { - dst[n] = *ptr; - ptr += _info.channels; + if (_gain != 1.f) { + for (framecnt_t n = 0; n < nread; ++n) { + dst[n] = *ptr * _gain; + ptr += _info.channels; + } + } else { + for (framecnt_t n = 0; n < nread; ++n) { + dst[n] = *ptr; + ptr += _info.channels; + } } return nread; |