Skip to content

Instantly share code, notes, and snippets.

@fukuroder
fukuroder / wasapi_capture.fs
Last active January 5, 2024 17:54
WASAPI capture in F#
open System.Runtime.InteropServices
open NAudio.CoreAudioApi
module NativeMethods =
[<DllImport("api-ms-win-core-synch-l1-2-0.dll")>]
extern System.IntPtr CreateEvent(System.IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, System.IntPtr lpName)
[<DllImport("api-ms-win-core-handle-l1-1-0.dll")>]
extern bool CloseHandle(System.IntPtr hObject)
@fukuroder
fukuroder / sfft.py
Last active May 10, 2021 12:57
decimation in time split-radix FFT
import numpy as np
def sfft(x):
n = len(x)
if n==1:
return x
elif n==2:
return np.r_[x[0]+x[1], x[0]-x[1]]
else:
w = np.exp(-2j*np.pi/n*np.arange(n//4))
w3 = np.exp(-2j*np.pi/n*3*np.arange(n//4))
@fukuroder
fukuroder / wasapi_capture_and_render.cpp
Last active March 9, 2024 02:14
WASAPIでcaptureしてそのままrenderするサンプル
/*
* wasapi_capture_and_render.cpp
*
* Created by fukuroda (https://github.com/fukuroder)
*/
// STL
#include <iostream>
#include <vector>
@fukuroder
fukuroder / biquad.dsp
Last active September 2, 2017 01:16
faustでBiQuadフィルタの練習
cutoff = hslider("[0]cutoff", 200, 20, 2000, 0.1);
resonance = hslider("[1]resonance", 0.707, 0.707, 20, 0.01);
low = hslider("[2]low", 1.0, 0.0, 1.0, 0.01);
band = hslider("[3]band", 1.0, 0.0, 1.0, 0.01);
high = hslider("[4]high", 1.0, 0.0, 1.0, 0.01);
pi = 3.141592;
s = tan( cutoff * pi / 44100.0 );
t = s / resonance;
u = s*s + t + 1.0;
a0 = (low*s*s + band*t + high)/u;
@fukuroder
fukuroder / mnist_train1.prototxt
Last active January 29, 2017 16:41
Caffeのカスタムレイヤーの練習
name: "mnist_train1"
layer {
name: "mnist"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
@fukuroder
fukuroder / mnist_save_png.py
Last active April 6, 2022 09:20
Save MNIST data as PNG.
import os
import cv2
import numpy as np
train_image = 'train-images-idx3-ubyte'
train_label = 'train-labels-idx1-ubyte'
test_image = 't10k-images-idx3-ubyte'
test_label = 't10k-labels-idx1-ubyte'
for f in [train_image, train_label, test_image, test_label]:
\begin{eqnarray}
A_{2k} &=& \sum_{j=0}^{N/2-1} (a_j + a_{N/2+j}) W_{N/2}^{jk} \\
A_{2k+1} &=& \sum_{j=0}^{N/2-1} ( a_j - a_{N/2+j}) W_N^j W_{N/2}^{jk}
\end{eqnarray}
PKG core
PKG alsa
PKG yojson
#include "../JuceLibraryCode/JuceHeader.h"
std::vector<uint32> Encrypt(const std::string& text, const std::string& key)
{
// create Blowfish
BlowFish bf(key.data(), key.length());
// encrypt
std::vector<uint32> result;
auto p = text.begin();
#include "../JuceLibraryCode/JuceHeader.h"
int main()
{
DynamicObject* obj1 = new DynamicObject();
obj1->setProperty("b", Array<var>{1, 2, 3, 4});
DynamicObject* obj2 = new DynamicObject();
obj2->setProperty("c", Array<var>{6, 7, 8, 9});
DynamicObject* obj3 = new DynamicObject();
obj3->setProperty("a", Array<var>{obj1, obj2});