<commit_before>#!/usr/bin/env node
'use strict'

process.title = 'stratum'

const path = require('path')
const { paths, config, args } = require(path.join(__dirname, 'main.config.js'))

const stratum = require(path.join(paths.lib, 'stratum'))
const manager = require(path.join(paths.lib, 'animations-manager'))
const leap = require(path.join(paths.lib, 'leap'))

const animations = manager.stack([
  // 'debug',
  // manager.Separator,

  'cave',
  manager.Separator,
  'earth',
  manager.Separator,
  'rain',
  manager.Separator,
  'storm',
  manager.Separator,
  'wind'
])

stratum.raf(animations.update)
stratum.start()

stratum.server.on('newnode', () => {
  if (!animations.running) {
    animations.resume()
    args.timer && timer()
  }
})

function timer (ms = 0) {
  const leapTimeVisible = leap.timeVisible() || 0
  if (leapTimeVisible === 0 && ms > config.timer.minimumInterval) {
    ms = 1000
    if (Math.random() > 0.5) animations.next()
    else animations.previous()
  }

  setTimeout(() => timer(ms + 1000), 1000)
}

// -------------------------------------------------------------------------

require(path.join(paths.utils, 'dev-helper'))({
  viewer: args.with,
  onKeyPress: (str, key) => {
    if (args.keys) {
      if (key.name === 'left') return animations.previous()
      if (key.name === 'right') return animations.next()<commit_msg>[sound] Add init<commit_after>#!/usr/bin/env node
'use strict'

process.title = 'stratum'

const path = require('path')
const { paths, config, args } = require(path.join(__dirname, 'main.config.js'))

const stratum = require(path.join(paths.lib, 'stratum'))
const manager = require(path.join(paths.lib, 'animations-manager'))
const leap = require(path.join(paths.lib, 'leap'))
const sound = require(path.join(paths.lib, 'sound'))

const animations = manager.stack([
  // 'debug',
  // manager.Separator,

  'cave',
  manager.Separator,
  'earth',
  manager.Separator,
  'rain',
  manager.Separator,
  'storm',
  manager.Separator,
  'wind'
])

stratum.raf(animations.update)
stratum.start()

stratum.server.on('newnode', () => {
  if (!animations.running) {
    animations.resume()
    args.sound && initSound()
    args.timer && timer()
  }
})

function timer (ms = 0) {
  const leapTimeVisible = leap.timeVisible() || 0
  if (leapTimeVisible === 0 && ms > config.timer.minimumInterval) {
    ms = 1000
    if (Math.random() > 0.5) animations.next()
    else animations.previous()
  }

  setTimeout(() => timer(ms + 1000), 1000)
}

function initSound () {
  for (let i = 0; i <= 5; i++) {
    sound.send('/mix', [i, 0.1])
  }
  sound.send('/play', 1)
}

// -------------------------------------------------------------------------

require(path.join(paths.utils, 'dev-helper'))({
  viewer: args.with,
  onKeyPress: (str, key) => {
    if (args.keys) {
      if (key.name === 'left') return animations.previous()
      if (key.name === 'right') return animations.next()
{'fraction_non_alphanumeric': 0.225938566552901, 'fraction_numerical': 0.013310580204778157, 'mean_word_length': 2.987755102040816, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 13, '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': '1574950', 'n_tokens_mistral': 1028, 'n_tokens_neox': 976, 'n_words': 207}