public PlayerCore(int sampleRate, Cmf cmfFile) { this.sampleRate = sampleRate; this.cmfFile = cmfFile; mr = new MidiReader(new MemoryStream(cmfFile.mididata)); adlib = new Adlib0(sampleRate, 2); for (int i = 0; i < channels.Length; ++i) { channels[i] = new Channel(); } }
private void init() { // read the midi data to determine the duration of the whole song: int totalTicks = 0; var mr = new MidiReader(new MemoryStream(cmf.mididata)); while (!mr.End) { totalTicks += mr.ReadEvent().delta; } SecTotal = (double)totalTicks / cmf.ticksPerSecond; destination.Open(destination.Info.defaultPeriod, 2, 44100, FormatType.Int16); pc = new PlayerCore(destination.SampleRate, cmf); thread = new Thread(AudioThread); thread.Start(); }