feat: refactoring
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
module SoundGen.PCMWave
|
||||
|
||||
open Settings
|
||||
open System.IO
|
||||
|
||||
let private toInt16Sample sample = sample |> (*) 32767. |> int16
|
||||
|
||||
|
||||
let private pack (d: int16 []) =
|
||||
let private pack (d: int16[]) =
|
||||
let stream = new MemoryStream()
|
||||
|
||||
let writer =
|
||||
new BinaryWriter(stream, System.Text.Encoding.ASCII)
|
||||
let writer = new BinaryWriter(stream, System.Text.Encoding.ASCII)
|
||||
|
||||
let dataLength = Array.length d * 2
|
||||
|
||||
@@ -33,12 +33,11 @@ let private pack (d: int16 []) =
|
||||
writer.Write(System.Text.Encoding.ASCII.GetBytes("data"))
|
||||
writer.Write(dataLength)
|
||||
|
||||
let data: byte [] =
|
||||
Array.zeroCreate dataLength
|
||||
let data: byte[] = Array.zeroCreate dataLength
|
||||
|
||||
System.Buffer.BlockCopy(d, 0, data, 0, dataLength)
|
||||
writer.Write(data)
|
||||
stream
|
||||
|
||||
let createWAV(wave: float seq) =
|
||||
wave |> Seq.map (fun x -> x |> toInt16Sample) |> Seq.toArray |> pack
|
||||
|
||||
let createWAV (wave: float seq) =
|
||||
wave |> Seq.map (fun x -> x |> toInt16Sample) |> Seq.toArray |> pack
|
||||
|
||||
Reference in New Issue
Block a user