🎶

foobar2000 Display Script集

2021/10/28に公開約2,200字

更新日:2021/10/28

INITIAL KEYをBeatport形式に正規化する

Ebみたいなのを5dに正規化する。

$replace($replace($replace($replace($if(%INITIAL KEY%,%INITIAL KEY%,%INITIALKEY%),maj,M,min,m),1A,1d,1B,1m,2A,2d,2B,2m,3A,3d,3B,3m,4A,4d,4B,4m,5A,5d,5B,5m,6A,6d,6B,6m,7A,7d,7B,7m,8A,8d,8B,8m,9A,9d,9B,9m,10A,10d,10B,10m,11A,11d,11B,11m,12A,12d,12B,12m),BM,1d,Abm,1m,G#m,1m,F#M,2d,GbM,2d,Ebm,2m,D#m,2m,DbM,3d,C#M,3d,Bbm,3m,A#m,3m,AbM,4d,G#M,4d,Fm,4m,EbM,5d,D#M,5d,Cm,5m,BbM,6d,A#M,6d,Gm,6m,FM,7d,Dm,7m,CM,8d,Am,8m,GM,9d,Em,9m,DM,10d,Bm,10m,AM,11d,F#m,11m,Gbm,11m,EM,12d,Dbm,12m,C#m,12m),F#,2d,Gb,2d,Db,3d,C#,3d,Ab,4d,G#,4d,Eb,5d,D#,5d,Bb,6d,A#,6d,D,10d,A,11d,E,12d,B,1d,F,7d,C,8d,G,9d)

生成スクリプトはこちら。

const keymap = [
  'B',
  'F#',
  'Db',
  'Ab',
  'Eb',
  'Bb',
  'F',
  'C',
  'G',
  'D',
  'A',
  'E',
];

const getNextChar = (character, index = 1) => {
  if (character === 'A' && index === -1) {
    return 'G';
  }
  if (character === 'G' && index === 1) {
    return 'A';
  }
  return String.fromCharCode(character.charCodeAt(0) + index);
};

const keys = keymap.map((v) => {
  const keylist = [v];
  if (v.length !== 1) {
    if (v[1] === '#') {
      keylist.push(`${getNextChar(v[0])}b`);
    } else {
      keylist.push(`${getNextChar(v[0], -1)}#`);
    }
  }
  return keylist;
});

const majminKeys = keys.map((v, i, l) => [v, l[(i + 3) % l.length]]);

const replacelist = majminKeys
  .map((v, i) => {
    const [key, minor] = v;
    const a = [
      ...key.map((v) => {
        return `${v}M,${i + 1}d`;
      }),
      ...minor.map((v) => {
        return `${v}m,${i + 1}m`;
      }),
    ];
    return a.join(',');
  })
  .join(',');

const replacelist2 = majminKeys
  .flatMap((v, i) => {
    const [key] = v;
    return key.map((v) => {
      return `${v},${i + 1}d`;
    });
  })
  .sort((a, b) => b.length - a.length)
  .join(',');

const numtodm = majminKeys
  .map((_, i) => {
    return `${i + 1}A,${i + 1}d,${i + 1}B,${i + 1}m`;
  })
  .join(',');

console.log(
  `$replace($replace($replace($replace($if(%INITIAL KEY%,%INITIAL KEY%,%INITIALKEY%),maj,M,min,m),${numtodm}),${replacelist}),${replacelist2})`
);

Ratingを星で表示する

$repeat(★,$meta(rating))$repeat(☆,$sub(5,$meta(rating)))

Discussion

ログインするとコメントできます