Пример #1
0
        int intf_loadSamples(uint dest, int size, byte[] src, int offset)
        {
            if (dest >= 65536 || size == 0 || size > 65536)
            {
                return(3);
            }
            if (size + dest > 65536)
            {
                return(5);
            }

            int dwIndex = _numWaveTables - 1;

            for (uint t = (uint)_waveTablesTotalDataSize; dwIndex != 0 && (dest < t); dwIndex--)
            {
                t -= (uint)_waveTables[dwIndex].size;
            }

            TownsAudio_WaveTable s = _waveTables[dwIndex];

            _waveTablesTotalDataSize -= s.size;
            s.size = size;
            s.ReadData(src, offset);
            _waveTablesTotalDataSize += s.size;

            return(0);
        }
Пример #2
0
        int intf_pcmPlayEffect(object[] args)
        {
            int chan       = (int)args[0];
            int note       = (int)args[1];
            int velo       = (int)args[2];
            var data       = (byte[])args[3];
            var dataOffset = (int)args[4];

            if (chan < 0x40 || chan > 0x47)
            {
                return(1);
            }

            if ((note & 0x80) != 0 || ((velo & 0x80) != 0))
            {
                return(3);
            }

            chan -= 0x40;

            if (!_pcmChan[chan]._reserved)
            {
                return(7);
            }

            if (_pcmChan[chan]._activeEffect)
            {
                return(2);
            }

            var w = new TownsAudio_WaveTable();

            w.ReadHeader(data, dataOffset);

            if (w.size < (w.loopStart + w.loopLen))
            {
                return(13);
            }

            if (w.size == 0)
            {
                return(6);
            }

            var p = _pcmChan[chan];

            p.LoadData(data, dataOffset + 32, w.size);
            p.KeyOn((byte)note, (byte)velo, w);

            return(0);
        }
Пример #3
0
        int intf_loadWaveTable(object[] args)
        {
            var data = (byte[])args[0];

            if (_numWaveTables > 127)
            {
                return(3);
            }

            TownsAudio_WaveTable w = new TownsAudio_WaveTable();

            w.ReadHeader(data, 0);
            if (w.size == 0)
            {
                return(6);
            }

            if (_waveTablesTotalDataSize + w.size > 65504)
            {
                return(5);
            }

            for (int i = 0; i < _numWaveTables; i++)
            {
                if (_waveTables[i].id == w.id)
                {
                    return(10);
                }
            }

            var s = _waveTables[_numWaveTables++];

            s.ReadHeader(data, 0);

            _waveTablesTotalDataSize += s.size;
            Callback(32, _waveTablesTotalDataSize, s.size, data, 32);

            return(0);
        }
Пример #4
0
        public override bool Init()
        {
            if (_ready)
            {
                return(true);
            }

            if (!base.Init())
            {
                return(false);
            }

            _fmSaveReg[0]   = new byte[256];
            _fmSaveReg[1]   = new byte[256];
            _fmInstruments  = new byte[128 * 48];
            _pcmInstruments = new byte[32][];
            _waveTables     = new TownsAudio_WaveTable[128];
            for (int i = 0; i < _waveTables.Length; i++)
            {
                _waveTables[i] = new TownsAudio_WaveTable();
            }
            _pcmChan = new TownsAudio_PcmChannel[8];
            for (int i = 0; i < _pcmChan.Length; i++)
            {
                _pcmChan[i] = new TownsAudio_PcmChannel();
            }

            _timer = 0;

            SetVolumeChannelMasks(-1, 0);

            _ready = true;
            Callback(0);

            return(true);
        }
Пример #5
0
        int intf_pcmPlayEffect(object[] args)
        {
            int chan = (int)args[0];
            int note = (int)args[1];
            int velo = (int)args[2];
            var data = (byte[])args[3];
            var dataOffset = (int)args[4];

            if (chan < 0x40 || chan > 0x47)
                return 1;

            if ((note & 0x80) != 0 || ((velo & 0x80) != 0))
                return 3;

            chan -= 0x40;

            if (!_pcmChan[chan]._reserved)
                return 7;

            if (_pcmChan[chan]._activeEffect)
                return 2;

            var w = new TownsAudio_WaveTable();
            w.ReadHeader(data, dataOffset);

            if (w.size < (w.loopStart + w.loopLen))
                return 13;

            if (w.size == 0)
                return 6;

            var p = _pcmChan[chan];

            p.LoadData(data, dataOffset + 32, w.size);
            p.KeyOn((byte)note, (byte)velo, w);

            return 0;
        }
Пример #6
0
        int intf_loadWaveTable(object[] args)
        {
            var data = (byte[])args[0];
            if (_numWaveTables > 127)
                return 3;

            TownsAudio_WaveTable w = new TownsAudio_WaveTable();
            w.ReadHeader(data, 0);
            if (w.size == 0)
                return 6;

            if (_waveTablesTotalDataSize + w.size > 65504)
                return 5;

            for (int i = 0; i < _numWaveTables; i++)
            {
                if (_waveTables[i].id == w.id)
                    return 10;
            }

            var s = _waveTables[_numWaveTables++];
            s.ReadHeader(data, 0);

            _waveTablesTotalDataSize += s.size;
            Callback(32, _waveTablesTotalDataSize, s.size, data, 32);

            return 0;
        }
Пример #7
0
        public override bool Init()
        {
            if (_ready)
                return true;

            if (!base.Init())
                return false;

            _fmSaveReg[0] = new byte[256];
            _fmSaveReg[1] = new byte[256];
            _fmInstruments = new byte[128 * 48];
            _pcmInstruments = new byte[32][];
            _waveTables = new TownsAudio_WaveTable[128];
            for (int i = 0; i < _waveTables.Length; i++)
            {
                _waveTables[i] = new TownsAudio_WaveTable();
            }
            _pcmChan = new TownsAudio_PcmChannel[8];
            for (int i = 0; i < _pcmChan.Length; i++)
            {
                _pcmChan[i] = new TownsAudio_PcmChannel();
            }

            _timer = 0;

            SetVolumeChannelMasks(-1, 0);

            _ready = true;
            Callback(0);

            return true;
        }