元となる8bitのデータをxとし、上位4bitをa、下位4bitをbとします
//擬似コード
a = (x >> 4) & 0b1111;
b = x & 0b1111;
- 分割
input: x (16bit)
// 周波数(Hz)からMIDIノートナンバーへの変換 | |
// Wikipediaの[MIDI tuning standard](https://en.wikipedia.org/wiki/MIDI_tuning_standard)を参照 | |
// A=440Hzの場合 | |
int freqToMidi(float freq) | |
{ | |
int midinote = std::nearbyint(69.0 + 12.0 * log2(freq / 440.0)); | |
return midinote; | |
} |
import time | |
import threading | |
import argparse | |
from pythonosc import dispatcher | |
from pythonosc import osc_server | |
def oscprint(unused_addr, args, *values): | |
print("value size: ", len(values)) | |
for el in values: | |
print(el) |
import math | |
import sys | |
def computeTickWidth(range, mostDivision): | |
minInterval = range / mostDivision | |
magnitude = pow(10, math.floor(math.log10(minInterval))) | |
residual = minInterval / magnitude | |
if residual > 5: |
#include <string> | |
#include <chrono> | |
#include <sstream> | |
#include <iomanip> | |
std::string getTimeStamp() | |
{ | |
auto now = std::chrono::system_clock::now(); | |
auto now_c = std::chrono::system_clock::to_time_t(now); | |
std::stringstream ss; |
import cmath | |
import numpy as np | |
from scipy.fftpack import fft, ifft | |
import soundfile as sf | |
import matplotlib.pyplot as plt | |
FS = 48000 | |
N = 2 ** 16 | |
J = N // 4 | |
a = 2.0 * np.pi * J |
void MainContentComponent::exportWav(AudioSampleBuffer &bufferToWrite, String fileName) | |
{ | |
const double sampleRate = deviceManager.getCurrentAudioDevice()->getCurrentSampleRate();//現在のサンプルレートを取得 | |
const int numChannel = bufferToWrite.getNumChannels(); | |
const int bitDepth = 32;//32bitFloat | |
File file(File::getSpecialLocation(File::SpecialLocationType::userDesktopDirectory).getChildFile(fileName)); | |
file.deleteFile(); | |
ScopedPointer<FileOutputStream> fos(file.createOutputStream()); | |
WavAudioFormat wavFormat; | |
ScopedPointer<AudioFormatWriter> writer(wavFormat.createWriterFor(fos, sampleRate, numChannel, bitDepth, StringPairArray(), 0)); |