int PcmSetPitch(int chan, int pitch) { if (chan > 0x47) { return(1); } if (pitch < -8192 || pitch > 8191) { return(3); } chan -= 0x40; TownsAudio_PcmChannel p = _pcmChan[chan]; uint pts = 0x4000; if (pitch < 0) { pts = (uint)((0x20000000 / (-pitch + 0x2001)) >> 2); } else if (pitch > 0) { pts = (uint)((((pitch + 0x2001) << 16) / 0x2000) >> 2); } p.SetPitch(pts); return(0); }
int PcmKeyOn(int chan, int note, int velo) { if (chan < 0x40 || chan > 0x47) { return(1); } if (((note & 0x80) != 0) || ((velo & 0x80) != 0)) { return(3); } chan -= 0x40; byte noteT = (byte)note; TownsAudio_PcmChannel p = _pcmChan[chan]; if (p._reserved || p._keyPressed) { return(2); } TownsAudio_WaveTable w; int res = p.InitInstrument(ref noteT, _waveTables, _numWaveTables, out w); if (res != 0) { return(res); } p.LoadData(w); p.KeyOn(noteT, (byte)velo, w); return(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); }
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; }