Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
        static void LoadInstrument(Adlib0 adlib, int channel, Cmf.Instrument instrument)
        {
            var optbl = new int[] { 0, 1, 2, 8, 9, 10, 16, 17, 18 };

            adlib.Poke(0x20 + optbl[channel], instrument.iModChar);
            adlib.Poke(0x23 + optbl[channel], instrument.iCarChar);
            adlib.Poke(0x40 + optbl[channel], instrument.iModScale);
            adlib.Poke(0x43 + optbl[channel], instrument.iCarScale);
            adlib.Poke(0x60 + optbl[channel], instrument.iModAttack);
            adlib.Poke(0x63 + optbl[channel], instrument.iCarAttack);
            adlib.Poke(0x80 + optbl[channel], instrument.iModSustain);
            adlib.Poke(0x83 + optbl[channel], instrument.iCarSustain);
            adlib.Poke(0xE0 + optbl[channel], instrument.iModWaveSel);
            adlib.Poke(0xE3 + optbl[channel], instrument.iCarWaveSel);
            adlib.Poke(0xC0 + channel, instrument.iFeedback);
        }
Exemplo n.º 3
0
        static void LoadRhythm(Adlib0 adlib, int cmfChannel, Cmf.Instrument instrument)
        {
            int i, j;

            switch (cmfChannel)
            {
            case 11:     // bassdrum
                i = 16;
                j = 19;
                adlib.Poke(0x20 + i, instrument.iModChar);
                adlib.Poke(0x40 + i, instrument.iModScale);
                adlib.Poke(0x60 + i, instrument.iModAttack);
                adlib.Poke(0x80 + i, instrument.iModSustain);
                adlib.Poke(0xE0 + i, instrument.iModWaveSel);
                adlib.Poke(0x20 + j, instrument.iCarChar);
                adlib.Poke(0x40 + j, instrument.iCarScale);
                adlib.Poke(0x60 + j, instrument.iCarAttack);
                adlib.Poke(0x80 + j, instrument.iCarSustain);
                adlib.Poke(0xE0 + j, instrument.iCarWaveSel);
                adlib.Poke(0xC0 + 6, instrument.iFeedback);

                break;

            case 12:     // snare
                i = 20;
                adlib.Poke(0x20 + i, instrument.iModChar);
                adlib.Poke(0x40 + i, instrument.iModScale);
                adlib.Poke(0x60 + i, instrument.iModAttack);
                adlib.Poke(0x80 + i, instrument.iModSustain);
                adlib.Poke(0xE0 + i, instrument.iModWaveSel);
                adlib.Poke(0xC0 + 7, instrument.iFeedback);
                break;

            case 13:     // tom
                i = 18;
                adlib.Poke(0x20 + i, instrument.iModChar);
                adlib.Poke(0x40 + i, instrument.iModScale);
                adlib.Poke(0x60 + i, instrument.iModAttack);
                adlib.Poke(0x80 + i, instrument.iModSustain);
                adlib.Poke(0xE0 + i, instrument.iModWaveSel);
                adlib.Poke(0xC0 + 8, instrument.iFeedback);
                break;

            case 14:     // cymbal
                i = 21;
                adlib.Poke(0x20 + i, instrument.iModChar);
                adlib.Poke(0x40 + i, instrument.iModScale);
                adlib.Poke(0x60 + i, instrument.iModAttack);
                adlib.Poke(0x80 + i, instrument.iModSustain);
                adlib.Poke(0xE0 + i, instrument.iModWaveSel);
                adlib.Poke(0xC0 + 8, instrument.iFeedback);
                break;

            case 15:     // hihat
                i = 17;
                adlib.Poke(0x20 + i, instrument.iModChar);
                adlib.Poke(0x40 + i, instrument.iModScale);
                adlib.Poke(0x60 + i, instrument.iModAttack);
                adlib.Poke(0x80 + i, instrument.iModSustain);
                adlib.Poke(0xE0 + i, instrument.iModWaveSel);
                adlib.Poke(0xC0 + 7, instrument.iFeedback);
                break;
            }
        }