<commit_before>package de.sciss.fscape

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import de.sciss.file._
import de.sciss.fscape.gui.SimpleGUI
import de.sciss.numbers
import de.sciss.synth.io.AudioFileSpec

import scala.concurrent.ExecutionContext
import scala.swing.Swing

object NormalizeTest extends App {
  val fIn   = userHome / "Documents" / "projects" / "Unlike" / "audio_work" / "mentasm-e8646341-63dcf8a8.aif"
  val fIn2  = userHome / "Music" / "work" / "B20h22m33s19mar2016.wav"
  val fOut  = userHome / "Music" / "work" / "_killme.aif"

  import graph._
  import numbers.Implicits._

  // stream.showStreamLog = true

  lazy val gOLD = Graph {
    val trig  = Impulse(1.0/44100)
    val in    = DiskIn(file = fIn, numChannels = 1)
    Poll(in = in, trig = trig, label = "test")
  }

  lazy val gFORK2 = Graph {
    def mkIn() = DiskIn(file = fIn, numChannels = 1)

    val in        = mkIn()
    val max       = RunningMax(in.abs) // .last
    val trig  = Impulse(1.0/44100)
    in /* max */     . poll(trig, "max [Lin]")
    in /* max */.ampdb.poll(trig, "max [dB ]")
  }

  lazy val gFORK = Graph {
    val in    = DC(-33.0)
    val trig  = Impulse(1.0/44100)
    in     .poll(trig, "[Lin]")
    in .abs.poll(trig, "[Abs]")
  }

  lazy val gConst = Graph {
    val trig = 1 // Impulse(1.0/44100)
    Poll(in = (-0.0940551906824112: GE).abs.ampdb, trig = trig, label = "max")
  }

  lazy val g = Graph {
    def mkIn() = ChannelProxy(DiskIn(file = fIn2, numChannels = 2), 0)

    val in        = mkIn()
    val max       = RunningMax(in.abs) // .last
    max.ampdb.poll(1.0/44100, "max [dB]")
    val headroom  = -0.2.dbamp
    val gain      = max.reciprocal * headroom
    val buf       = mkIn() // BufferAll(in)
    val sig       = buf * gain
    DiskOut(file = fOut, spec = AudioFileSpec(numChannels = 1, sampleRate = 44100), in = sig)
  }

  lazy val gX = Graph {
    def mkIn() = DiskIn(file = fIn, numChannels = 1)

    val in        = mkIn()<commit_msg>problem related to disk-in length (1048576 which is multiple of bufSize 1024)<commit_after>package de.sciss.fscape

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import de.sciss.file._
import de.sciss.fscape.gui.SimpleGUI
import de.sciss.numbers
import de.sciss.synth.io.AudioFileSpec

import scala.concurrent.ExecutionContext
import scala.swing.Swing

object NormalizeTest extends App {
  val fIn   = userHome / "Documents" / "projects" / "Unlike" / "audio_work" / "mentasm-e8646341-63dcf8a8.aif"
  val fIn2  = userHome / "Music" / "work" / "B20h22m33s19mar2016/.wav"
  val fIn3  = userHome / "Music" / "work" / "_killme1.wav"
  val fOut  = userHome / "Music" / "work" / "_killme.aif"

  import graph._
  import numbers.Implicits._

  // stream.showStreamLog = true

  lazy val gOLD = Graph {
    val trig  = Impulse(1.0/44100)
    val in    = DiskIn(file = fIn, numChannels = 1)
    Poll(in = in, trig = trig, label = "test")
  }

  lazy val gFORK2 = Graph {
    def mkIn() = DiskIn(file = fIn, numChannels = 1)

    val in        = mkIn()
    val max       = RunningMax(in.abs) // .last
    val trig  = Impulse(1.0/44100)
    in /* max */     . poll(trig, "max [Lin]")
    in /* max */.ampdb.poll(trig, "max [dB ]")
  }

  lazy val gFORK = Graph {
    val in    = DC(-33.0)
    val trig  = Impulse(1.0/44100)
    in     .poll(trig, "[Lin]")
    in .abs.poll(trig, "[Abs]")
  }

  lazy val gConst = Graph {
    val trig = 1 // Impulse(1.0/44100)
    Poll(in = (-0.0940551906824112: GE).abs.ampdb, trig = trig, label = "max")
  }

  lazy val g = Graph {
//    def mkIn() = ChannelProxy(DiskIn(file = fIn2, numChannels = 2), 0)
//    def mkIn() = DiskIn(file = fIn, numChannels = 1)
    def mkIn() = DiskIn(file = fIn3, numChannels = 1)

    val in        = mkIn()
    val max       = RunningMax(in.abs).last
    max.ampdb.poll(0, "max [dB]")
    val headroom  = -0.2.dbamp
    val gain      = max.reciprocal * headroom
    val buf       = mkIn() // BufferAll(in)
    val sig       = buf * gain
    DiskOut(file = fOut, spec = AudioFileSpec(numChannels = 1, sampleRate = 44100), in = sig)
  }

  lazy val gX = Graph {
    def mkIn() = DiskIn(file = fIn, numChannels = 1)

    val in        = mkIn()
{'fraction_non_alphanumeric': 0.14068801897983393, 'fraction_numerical': 0.04744958481613286, 'mean_word_length': 2.4699588477366254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6608105', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1610, 'n_words': 399}