mirror of
https://github.com/ivabus/lonelyradio
synced 2024-11-23 16:45:10 +03:00
Clamp samples before encoding flac
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
parent
60791dc292
commit
80cef97ca2
1 changed files with 1 additions and 2 deletions
|
@ -32,13 +32,12 @@ pub fn encode(
|
||||||
#[cfg(feature = "flac")]
|
#[cfg(feature = "flac")]
|
||||||
{
|
{
|
||||||
use flacenc::{component::BitRepr, error::Verify, source::MemSource};
|
use flacenc::{component::BitRepr, error::Verify, source::MemSource};
|
||||||
|
|
||||||
let encoded = flacenc::encode_with_fixed_block_size(
|
let encoded = flacenc::encode_with_fixed_block_size(
|
||||||
&flacenc::config::Encoder::default().into_verified().unwrap(),
|
&flacenc::config::Encoder::default().into_verified().unwrap(),
|
||||||
MemSource::from_samples(
|
MemSource::from_samples(
|
||||||
&samples
|
&samples
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| (*x as f64 * 32768.0 * 256.0) as i32)
|
.map(|x| (x.clamp(-1.0, 1.0) as f64 * 32768.0 * 256.0) as i32)
|
||||||
.collect::<Vec<i32>>(),
|
.collect::<Vec<i32>>(),
|
||||||
channels as usize,
|
channels as usize,
|
||||||
24,
|
24,
|
||||||
|
|
Loading…
Reference in a new issue