Skip to content

Instantly share code, notes, and snippets.

View okaxaki's full-sized avatar

Mitsutaka Okazaki okaxaki

  • Tokyo, Japan
View GitHub Profile
@okaxaki
okaxaki / xlsx_knife.dart
Last active March 14, 2023 22:39
Stripper tool to remove all phonetic fields from Excel file
// MIT License
//
// Copyright (c) 2023 Mitsutaka Okazaki
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@okaxaki
okaxaki / mave.js
Last active August 25, 2022 09:22
Sample Rate Conversion by Moving Average
// サンプルレート変換: 移動平均フィルタの多段接続
const WaveFile = require("wavefile");
const fs = require("fs");
function upsample(samples, M, useZero) {
const result = [];
for (let i = 0; i < samples.length; i++) {
const d = samples[i];
for (let j = 0; j < M; j++) {
// MIT License
//
// Copyright (c) 2022 Mitsutaka Okazaki
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@okaxaki
okaxaki / ioslocaleidentifiers.csv
Last active February 19, 2022 05:28
All available language tags from NSLocale.availableLocaleIdentifiers (iOS 15)
localeIdentifier Description
af Afrikaans
af_NA Afrikaans (Namibia)
af_ZA Afrikaans (South Africa)
agq Aghem
agq_CM Aghem (Cameroon)
ain Ainu
ain_JP Ainu (Japan)
ak Akan
ak_GH Akan (Ghana)
@okaxaki
okaxaki / androidlocaleidentifiers.csv
Last active February 19, 2022 05:28
All available language tags from Locale.getAvailableLocales (API31)
LanguageTag Description
af Afrikaans
af-NA Afrikaans (Namibia)
af-ZA Afrikaans (South Africa)
agq Aghem
agq-CM Aghem (Cameroon)
ak Akan
ak-GH Akan (Ghana)
am Amharic
am-ET Amharic (Ethiopia)
@okaxaki
okaxaki / script-processor-test.html
Created March 20, 2021 15:29
Test for ScriptProcessor glitches on Chrome 89
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script>
const BUF_SIZE = 16384;
let context;
let scriptNode;
function play() {
scriptNode = context.createScriptProcessor(BUF_SIZE, 1, 1);
@okaxaki
okaxaki / sn76489_freq_comp.js
Created December 8, 2019 17:07
Generate wave file to compare sn76489 freq table.
const sega_table = [
0x0,
0x03ff, //, 01 109.346Hz A2 -10.329 cents
0x03c7, //, 02 115.678Hz A#2 -12.867 cents
0x0390, //, 03 122.654Hz B2 -11.489 cents
0x035d, //, 04 129.920Hz C3 -11.864 cents
0x032d, //, 05 137.590Hz C#3 -12.555 cents
0x02ff, //, 06 145.842Hz D3 -11.720 cents
0x02d4, //, 07 154.504Hz D#3 -11.836 cents
0x02ab, //, 08 163.779Hz E3 -10.911 cents
@okaxaki
okaxaki / adpcm-util.ts
Last active June 22, 2023 14:23
ADPCM to PCM (YM2608 / MSM6258)
const F = [57, 57, 57, 57, 77, 102, 128, 153];
function ensureInt16Array(pcm: Int16Array | Uint8Array): Int16Array {
if (pcm instanceof Uint8Array) {
const result = new Int16Array(pcm.length);
for (let i = 0; i < pcm.length; i++) {
result[i] = (pcm[i] - 128) * 256;
}
return result;
}
@okaxaki
okaxaki / rate_conv.c
Last active July 19, 2021 07:19
sampling rate converter using sinc interporation
/**
* Sampling rate converter using sinc interporation.
*
* This code was made with reference to http://blog-yama.a-quest.com/?eid=970185
*/
/* LW is truncate length of sinc(x) calculation.
* Lower LW is faster, higher LW results better quality.
* LW must be a non-zero positive even number, no upper limit.
* LW=16 or greater is recommended.
export type OPLLOperatorParam = {
am: number;
pm: number;
eg: number;
ml: number;
kr: number;
kl: number;
tl: number;
ar: number;
dr: number;