Пример #1
0
void music_start()
{
	int size;
	int r;

	cffat_init();
	cffat_load("3.MOD", modfile, sizeof(modfile), &size);
	cffat_done();

	r = mod_init(&mod_context, modfile, size);

	mod_fetch(&mod_context, sndbuf1, NSAMPLES);
	mod_fetch(&mod_context, sndbuf2, NSAMPLES);
	mod_fetch(&mod_context, sndbuf3, NSAMPLES);
	snd_play_refill(sndbuf1);
	snd_play_refill(sndbuf2);
	snd_play_refill(sndbuf3);
	snd_play_start(callback, NSAMPLES, NULL);
}
Пример #2
0
int main(int ac, char** av)
{
  file_context_t fc = FILE_STATIC_INITIALIZER;
  pcm_buf_t* pcm_buf = NULL;
  mod_context_t mc;

  if (file_open(&fc, ac > 1 ? av[1] : "../data/alban.mod") == -1)
    {
      printf("failed opening file\n");
      goto on_error;
    }

  if (mod_init(&mc, file_get_data(&fc), file_get_size(&fc)) == -1)
    {
      printf("failed mod_init\n");
      goto on_error;
    }

  pcm_alloc_buf(&pcm_buf, 48000);

  {
    FILE *f=fopen("output.raw","wb");
    unsigned int i;

    for (i = 0; i < 100; ++i)
      {
	mod_fetch(&mc, pcm_get_buf_data(pcm_buf), pcm_get_buf_count(pcm_buf));
#if 0	
	write(1, pcm_get_buf_data(pcm_buf), pcm_get_buf_size(pcm_buf));
#else
	fwrite(pcm_get_buf_data(pcm_buf),1,pcm_get_buf_size(pcm_buf),f);
#endif
      }
    fclose(f);
  }

 on_error:
  if (pcm_buf != NULL)
    pcm_free_buf(pcm_buf);

  file_close(&fc);

  return 0;
}
Пример #3
0
static void callback(short *buffer, void *user)
{
	mod_fetch(&mod_context, buffer, NSAMPLES);
	snd_play_refill(buffer);
}