main.cpp

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. main

#include <stdio.h>
#include "s98.h"
#include "mymixer.h"
#include "build.h"

const int samplerate = 44100;
const int opnfreq = 3993600;
const int opnafreq = opnfreq * 2;

int main(int argc, char** argv)
/* [<][>][^][v][top][bottom][index][help] */
{
  FM::OPNA fm;
  fprintf(stderr, "S98 player (build #%d)  by Zinnia.\n", buildno);
  if(!fm.Init(opnafreq, samplerate, 0)){
    return -1;
  }
  if(fm.LoadRhythmSample("/usr/local/share/fmgen/") == 0){
    fprintf(stderr, "warning: rhythm files not found in /usr/local/share/fmgen\n");
  }

  fm.Reset();
  fm.SetReg(0x29, 0x9f);

  OPNAWRAP opna(fm);
  opna.rate = samplerate;
  mymixer_factory factory;
  mymixer* mix = factory.Createmixer();
  if(mix->open(samplerate) < 0){ 
    fprintf(stderr, "mixer: open error.\n");
    return 1;
  }

  S98_opnareg opnareg(opna);
  S98_waitsync waitsync(opna, mix);
  S98 s98(opnareg, waitsync);

  if(argc < 2) return -1;
  if(s98.Open(argv[1])<0){
    fprintf(stderr, "%s: open error.\n", argv[1]);
    return -1;
  }
  s98.Dump();
  int ret;
  while(1){
    ret = s98.NextData();
    if(ret == -1){
      fprintf(stderr, "input error.\n");
      break;
    } else if (ret == 1){
      printf("Loop\n");
      if(!s98.Loop()) break;
      printf("End\n");
    }
  }
  mix->Sync();
  mix->close();
  return 0;
}

/* [<][>][^][v][top][bottom][index][help] */