Skip to content

Instantly share code, notes, and snippets.

View azyobuzin's full-sized avatar

Takuya Sakurai azyobuzin

View GitHub Profile
@azyobuzin
azyobuzin / EstimatePitch.cs
Created January 18, 2018 10:38
A SMARTER WAY TO FIND PITCH の C# 実装
using MathNet.Numerics;
using MathNet.Numerics.IntegralTransforms;
static float? EstimatePitch(int sampleRate, float[] samples)
{
// SDF
// 1. zero pad
var sdf = new Complex32[samples.Length * 2];
for (var i = 0; i < samples.Length; i++)
sdf[i] = new Complex32(samples[i], 0f);
@azyobuzin
azyobuzin / index.html
Created December 17, 2017 05:47
AnalyzerInsecta でやりたかったデザイン(未完成)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>プロジェクト名</title>
<style>
body {
margin: 0;
padding: 0;
}
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace HatenaBlogDownloader
{
# 生成したファイルの出力先ディレクトリ
OUTPUT_DIR = 'output'
# 学習データとして使う音色
INSTS_FOR_TRAINING = [
# Piano
1, 3, 5, 7, 8,
# Chromatic Percussion
9, 11, 13, 15,
# Organ
import copy
import typing
def sign(x: typing.Union[int, float, 'Decimal1000']) -> int:
"""x の符号が正なら 1 、負なら -1 、そうでないなら 0 を返す"""
if isinstance(x, Decimal1000):
return x.sign()
if x < 0: return -1
if x > 0: return 1
using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
using Grpc.Core.Logging;
namespace GrpcMemoryTest
{
class Program
{
private const string Host = "localhost";
#include <array>
#include <cassert>
#include <fstream>
#include <iostream>
#include <numeric>
#include <random>
#include <ppl.h>
struct integer_info {
int value;
using System;
using System.Runtime.CompilerServices;
namespace GCTest
{
class Program
{
static unsafe void Main(string[] args)
{
ref var refElm = ref AllocateArray();
public static int GetDistance(ArraySegment<byte> bs1, ArraySegment<byte> bs2)
{
if (bs1.Count != bs2.Count) throw new ArgumentException("bs1 と b2 の長さが違います。");
var count = bs1.Count;
var distance = 0;
var i = 0;
if (Vector.IsHardwareAccelerated)
{
public static byte[] ComputeHashQuickParallel5<TPixel>(int bits, IImageBase<TPixel> image, ArrayPool<ulong> arrayPool)
where TPixel : struct, IPixel<TPixel>
{
//if (bits % 4 != 0) throw new ArgumentException();
//if (image.Width % bits != 0 || image.Height % bits != 0) throw new ArgumentException();
ulong[] blocks = null, medians = null;
try
{