<|start_filename|>scripts/update-collection.js<|end_filename|>
'use strict';

const { spawn } = require('child_process');
const fs = require('fs').promises;
const glob = require('glob');

const filenames = glob.sync('./packages/piece-*');
const packageNames = filenames.map(
  filename => `@generative-music/${filename.replace('./packages/', '')}`
);

const collectionPackage = require('../packages/pieces-alex-bainter/package.json');

const missingDeps = packageNames.filter(
  packageName => !collectionPackage.dependencies[packageName]
);

if (missingDeps.length > 0) {
  spawn(
    'npm',
    ['i', '--prefix', './packages/pieces-alex-bainter'].concat(
      missingDeps.map(packageName => packageName)
    ),
    { stdio: 'inherit' }
  );
}

const esmFileContent = packageNames
  .map((packageName, i) => `import piece${i + 1} from '${packageName}';`)
  .concat([
    '',
    `export default [\n${packageNames
      .map((_, i) => `  piece${i + 1}`)
      .join(',\n')}\n];`,
    '',
    `export const byId = {\n${packageNames
      .map(
        (packageName, i) =>
          `  ['${packageName.replace(
            '@generative-music/piece-',
            ''
          )}']: piece${i + 1}`
      )
      .join(',\n')}\n};`,
  ])
  .join('\n');

const cjsFileContent = [
  "'use strict;'",
  '',
  `${packageNames
    .map((packageName, i) => `var piece${i + 1} = require('${packageName}')`)
    .join(';\n')}`,
  `module.exports = [\n${packageNames
    .map((_, i) => `  piece${i + 1}`)
    .join(',\n')}\n];
  module.exports.byId = {\n${packageNames
    .map(
      (packageName, i) =>
        `  ['${packageName.replace(
          '@generative-music/piece-',
          ''
        )}']: piece${i + 1}`
    )
    .join(',\n')}\n};`,
].join('\n');

fs.mkdir('./packages/pieces-alex-bainter/dist/', { recursive: true })
  .then(() =>
    fs.writeFile('./packages/pieces-alex-bainter/dist/esm.js', esmFileContent)
  )
  .then(() => {
    console.log('Generated pieces-alex-bainter/esm.js');
  })
  .then(() =>
    fs.writeFile('./packages/pieces-alex-bainter/dist/cjs.js', cjsFileContent)
  )
  .then(() => {
    console.log('Generated pieces-alex-bainter/cjs.js');
  });


<|start_filename|>normalize/max-db.js<|end_filename|>
const maxDb = {
  '420hz-gamma-waves-for-big-brain': -13.037062241593176,
  'a-viable-system': -18.966781795589707,
  'above-the-rain': -11.945108808955528,
  'agua-ravine': -22.49385185755913,
  aisatsana: -18.84936581577051,
  'animalia-chordata': -1.0589405756176382,
  apoapsis: -18.49516764463367,
  'at-sunrise': -17.31487596848369,
  awash: -21.34132730262214,
  'beneath-waves': -4.591739069405696,
  bhairav: -20.80314640218473,
  buttafingers: -30.008004681335827,
  'day-dream': -21.618390464588096,
  didgeridoobeats: -17.402007826334426,
  'documentary-films': -20.231967987165213,
  drones: -11.167360917766928,
  'drones-2': -18.971545257193917,
  'eno-machine': -23.488555707122035,
  enough: -15.137936538243952,
  'expand-collapse': -23.652104420485536,
  'eyes-closed': -19.851525798633496,
  homage: -11.976863441353307,
  impact: -23.2081666433715,
  'last-transit': -15.205361617242662,
  lemniscate: -21.128597720932408,
  'little-bells': -32.488032132649934,
  lullaby: -18.364920705859657,
  meditation: -17.189332445879057,
  moment: -14.534187187200713,
  nakaii: -24.277058697633464,
  neuroplasticity: -17.147977435239575,
  'no-refrain': -21.817613914968575,
  'observable-streams': -13.629744765318572,
  otherness: -16.980589325538293,
  'oxalis-1': -23.867709931938702,
  peace: -18.793113730225755,
  pinwheels: -32.0686333981302,
  'pulse-code-modulation': -17.651336141153596,
  remembering: -16.462956534379792,
  'return-to-form': -21.23646910043256,
  ritual: -22.037362325749108,
  sevenths: -25.044286078895098,
  soundtrack: -15.781714675708503,
  'spring-again': -18.330016596986706,
  stratospheric: -12.912933263641573,
  'stream-of-consciousness': -10.467206503219906,
  substrate: -15.371666794844055,
  'timbral-oscillations': -13.95496057871605,
  townsend: -10.185136171588383,
  transmission: -18.474678413522447,
  trees: -13.311707096556006,
  uun: -19.77385828872845,
  'western-medicine': -7.594611388092294,
  yesterday: -12.551059345505264,
  zed: -9.561673127286754,
};


<|start_filename|>packages/utilities/package.json<|end_filename|>
{
  "name": "@generative-music/utilities",
  "version": "5.0.1",
  "description": "A collection of common utilities for Web Audio API generative music systems",
  "main": "dist/cjs.js",
  "module": "dist/esm.js",
  "files": [
    "dist/esm.js"
  ],
  "scripts": {
    "test": "karma start",
    "test:watch": "karma start --no-single-run",
    "preversion": "npm test"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/generative-music/pieces-alex-bainter.git"
  },
  "author": "<NAME> <<EMAIL>> (https://alexbainter.com)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/generative-music/pieces-alex-bainter/issues"
  },
  "homepage": "https://github.com/generative-music/pieces-alex-bainter#readme",
  "publishConfig": {
    "access": "public"
  },
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.12.1",
    "@rollup/plugin-commonjs": "^11.0.2",
    "@rollup/plugin-node-resolve": "^7.1.1",
    "chai": "^4.2.0",
    "eslint": "^6.8.0",
    "eslint-config-metalex9": "^0.4.0",
    "karma": "^4.4.1",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^3.1.0",
    "karma-mocha": "^1.3.0",
    "karma-rollup-preprocessor": "^7.0.3",
    "mocha": "^7.1.0",
    "rollup": "^2.0.2",
    "tone": "^14.7.58"
  },
  "peerDependencies": {
    "tone": "^14.7.39"
  },
  "dependencies": {
    "@babel/runtime": "^7.12.5"
  },
  "unpkg": "dist/umd.min.js"
}
