Skip to content

Instantly share code, notes, and snippets.

View iizukak's full-sized avatar
🙆‍♂️

Kentaro Iizuka iizukak

🙆‍♂️
View GitHub Profile
@AZiCoDec
AZiCoDec / synthesis.cpp
Created December 18, 2010 22:05
Minimal code for callback function on SDL audio
#include <SDL/SDL.h>
#include <stdio.h>
using namespace std;
void func_callback(void *unused, Uint8 *stream, int len) {
for (int i=0;i<len;i++) {
stream[i] = i;
}
@theconektd
theconektd / github.css
Created April 30, 2012 02:11
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@julialang-jenkins
julialang-jenkins / output.txt
Created December 22, 2014 00:33
test (yomichi)
elapsed time: 0.004406706 seconds (245648 bytes allocated)
elapsed time: 0.003491785 seconds (231920 bytes allocated)
@983
983 / frag.glsl
Created November 14, 2015 09:39
hsv rgb conversion glsl shader
// because http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl is often down
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
/**
* 正弦波を出力する。引数でバッファサイズを指定
* (※SDLのドキュメントでは AudioSpec::samples はサンプル数って書いて
* るけど、実際はバッファサイズだと思う)
*
* メインスレッドで音を溜めてコールバックで出力する方式
* スレッド間のデータのやりとりに boost::lockfree::spsc_queue を使用
*/
#include <string>
@superzazu
superzazu / sdl2_sinewave.c
Created May 29, 2019 07:24
Playing a sine wave with the SDL2
#include <stdio.h>
#include <SDL.h>
int main(void) {
SDL_Init(SDL_INIT_AUDIO);
// the representation of our audio device in SDL:
SDL_AudioDeviceID audio_device;
// opening an audio device: