This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elapsed time: 0.004406706 seconds (245648 bytes allocated) | |
elapsed time: 0.003491785 seconds (231920 bytes allocated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 正弦波を出力する。引数でバッファサイズを指定 | |
* (※SDLのドキュメントでは AudioSpec::samples はサンプル数って書いて | |
* るけど、実際はバッファサイズだと思う) | |
* | |
* メインスレッドで音を溜めてコールバックで出力する方式 | |
* スレッド間のデータのやりとりに boost::lockfree::spsc_queue を使用 | |
*/ | |
#include <string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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: |