Skip to content

Instantly share code, notes, and snippets.

@takeutch-kemeco
Created April 11, 2014 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeutch-kemeco/10458132 to your computer and use it in GitHub Desktop.
Save takeutch-kemeco/10458132 to your computer and use it in GitHub Desktop.
pc9801-on.c
/* pc9801-on.c
* gcc -lasound -o pc9801-on{,.c}
*/
#include <alsa/asoundlib.h>
main()
{
snd_pcm_t *h;
snd_pcm_open(&h, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_ASYNC);
snd_pcm_set_params(h, SND_PCM_FORMAT_FLOAT, SND_PCM_ACCESS_RW_INTERLEAVED, 1, 44100, 1, 10000);
float w[2][0x4001], f = 0.2;
int i = 0x2000;
while (i--) {
if (!(i % (11025 / 480)))
f = -f;
w[0][i] = w[1][i*2] = w[1][i*2+1] = f;
}
snd_pcm_writei(h, w[0], 0x1500);
snd_pcm_writei(h, w[1], 0x1500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment