13
0

apply a fade in & out to captured audio clip data, before writing to disk

This policy may need revising later.
This commit is contained in:
Paul Davis 2024-10-10 10:56:24 -06:00
parent 87ab0a9e0f
commit 6193535a31

View File

@ -36,6 +36,7 @@
#include "temporal/tempo.h" #include "temporal/tempo.h"
#include "ardour/amp.h"
#include "ardour/async_midi_port.h" #include "ardour/async_midi_port.h"
#include "ardour/audio_track.h" #include "ardour/audio_track.h"
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
@ -1912,12 +1913,22 @@ AudioTrigger::captured (SlotArmInfo& ai, BufferSet&)
data.clear (); data.clear ();
for (auto & s : ai.audio_buf) {
data.push_back (s);
}
data.length = ai.audio_buf.length; data.length = ai.audio_buf.length;
data.capacity = ai.audio_buf.capacity; data.capacity = ai.audio_buf.capacity;
/* This AudioBuffer does not own any data, it is just a shell to make
using Amp::apply_gain() possible.
*/
AudioBuffer buf (0);
const samplecnt_t fade_duration = std::min (_box.session().sample_rate()/4, data.length/2);
for (auto & s : ai.audio_buf) {
data.push_back (s);
buf.set_data (s, data.length);
Amp::apply_gain (buf, _box.session().sample_rate(), fade_duration, 0., 1., 0);
Amp::apply_gain (buf, _box.session().sample_rate(), fade_duration, 1., 0., data.length - fade_duration);
}
ai.audio_buf.clear (); /* data now owned by us, not SlotArmInfo */ ai.audio_buf.clear (); /* data now owned by us, not SlotArmInfo */
/* follow length will get set when we build the region, and /* follow length will get set when we build the region, and