From df6a6da42388785789365fd5cd0b59369c69e475 Mon Sep 17 00:00:00 2001 From: HiveBeats <38073817+HiveBeats@users.noreply.github.com> Date: Mon, 31 Oct 2022 09:58:49 +0400 Subject: [PATCH] feat: sinewaveshaper --- SoundGen/Fx.fs | 3 +++ SoundGen/Program.fs | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SoundGen/Fx.fs b/SoundGen/Fx.fs index bddbaea..aed3846 100644 --- a/SoundGen/Fx.fs +++ b/SoundGen/Fx.fs @@ -9,6 +9,9 @@ type Saturator = { Gain: float } let saturate (param: Saturator, x: float) = tanh (param.Gain * x) +let sineWaveShape x = + x + 2.8 * sin (2. * x) + // // let process(effects:Effect list, sound:float seq) = // let mutable output = sound diff --git a/SoundGen/Program.fs b/SoundGen/Program.fs index c046707..892aec9 100644 --- a/SoundGen/Program.fs +++ b/SoundGen/Program.fs @@ -1,8 +1,8 @@ - -open System.IO +open System.IO open SoundGen open PCMWave open Fx +open SoundGen.Fx open Synth let song = @@ -54,6 +54,9 @@ let writeToFile (ms: MemoryStream) = ms.WriteTo(fs) -song |> createWAV |> writeToFile - - +song +|> Seq.map (fun x -> + let x1 = sineWaveShape x + saturate ({ Gain = 1.0 }, x1)) +|> createWAV +|> writeToFile