コード例 #1
0
ファイル: MidiDriver_TOWNS.cs プロジェクト: scemino/nscumm
        public MidiDriver_TOWNS(IMixer mixer)
        {
            _baseTempo = 10080;
            _rand = 1;

            // We set exteral mutex handling to true to avoid lockups in SCUMM which has its own mutex.
            _intf = new TownsAudioInterface(mixer, this, true);

            _channels = new TownsMidiInputChannel[32];
            for (int i = 0; i < 32; i++)
                _channels[i] = new TownsMidiInputChannel(this, i > 8 ? (i + 1) : i);

            _out = new TownsMidiOutputChannel[6];
            for (int i = 0; i < 6; i++)
            {
                _out[i] = new TownsMidiOutputChannel(this, i);
            }

            _chanState = new TownsMidiChanState[32];
            for (int i = 0; i < _chanState.Length; i++)
            {
                _chanState[i] = new TownsMidiChanState();
            }

            _operatorLevelTable = new byte[2048];
            for (int i = 0; i < 64; i++)
            {
                for (int ii = 0; ii < 32; ii++)
                    _operatorLevelTable[(i << 5) + ii] = (byte)(((i * (ii + 1)) >> 5) & 0xff);
            }
            for (int i = 0; i < 64; i++)
                _operatorLevelTable[i << 5] = 0;
        }
コード例 #2
0
        public override void Send(int b)
        {
            if (!_isOpen)
            {
                return;
            }

            int  param2 = ((b >> 16) & 0xFF);
            byte param1 = (byte)((b >> 8) & 0xFF);
            byte cmd    = (byte)(b & 0xF0);

            TownsMidiInputChannel c = _channels[b & 0x0F];

            switch (cmd)
            {
            case 0x80:
                c.NoteOff(param1);
                break;

            case 0x90:
                if (param2 != 0)
                {
                    c.NoteOn(param1, (byte)param2);
                }
                else
                {
                    c.NoteOff(param1);
                }
                break;

            case 0xB0:
                c.ControlChange(param1, (byte)param2);
                break;

            case 0xC0:
                c.ProgramChange(param1);
                break;

            case 0xE0:
                c.PitchBend((short)((param1 | (param2 << 7)) - 0x2000));
                break;

            case 0xF0:
                Debug.WriteLine("MidiDriver_TOWNS: Receiving SysEx command on a send() call");
                break;
            }
        }
コード例 #3
0
        public override MidiChannel AllocateChannel()
        {
            if (!_isOpen)
            {
                return(null);
            }

            for (int i = 0; i < 32; ++i)
            {
                TownsMidiInputChannel chan = _channels[i];
                if (chan.Allocate())
                {
                    return(chan);
                }
            }

            return(null);
        }
コード例 #4
0
        public MidiDriver_TOWNS(IMixer mixer)
        {
            _baseTempo = 10080;
            _rand      = 1;

            // We set exteral mutex handling to true to avoid lockups in SCUMM which has its own mutex.
            _intf = new TownsAudioInterface(mixer, this, true);

            _channels = new TownsMidiInputChannel[32];
            for (int i = 0; i < 32; i++)
            {
                _channels[i] = new TownsMidiInputChannel(this, i > 8 ? (i + 1) : i);
            }

            _out = new TownsMidiOutputChannel[6];
            for (int i = 0; i < 6; i++)
            {
                _out[i] = new TownsMidiOutputChannel(this, i);
            }

            _chanState = new TownsMidiChanState[32];
            for (int i = 0; i < _chanState.Length; i++)
            {
                _chanState[i] = new TownsMidiChanState();
            }

            _operatorLevelTable = new byte[2048];
            for (int i = 0; i < 64; i++)
            {
                for (int ii = 0; ii < 32; ii++)
                {
                    _operatorLevelTable[(i << 5) + ii] = (byte)(((i * (ii + 1)) >> 5) & 0xff);
                }
            }
            for (int i = 0; i < 64; i++)
            {
                _operatorLevelTable[i << 5] = 0;
            }
        }