'How to watermark a wave file with NAudio?
My application outputs wave files and I have the requirement to implement watermarking. By this I mean taking another wave file containing, say, 4 seconds of someone saying "This file is copyrighted material" and overlay this into the original file every 30 seconds.
I have tried many things but none quite works. I can pad the watermark to 30 seconds using OffsetSampleProvider
and mix this with MixingSampleProvider
, but that would only mix in one copy.
LoopStream
is a WaveStream
, not an ISampleProvider
, and even if I could do the conversion, I think this would mix forever, because the LoopStream
would never stop returning data.
This seems like a fairly basic use case, but I cannot figure out how to do it!
Solution 1:[1]
You're not too far off. You can turn a LoopStream
into an ISampleProvider
with the ToSampleProvider
extension method, and then you can use the Take
extension method to limit the duration of the looped stream to match the duration of the file you're mixing it with.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mark Heath |