protected PicoEmulator() { InitializeLuaEngine(); memory = new MemoryModule(); memory.InitializeStates(); ppu = new PictureProcessingUnit(memory); apu = new AudioProcessingUnit(memory, 48000); buttons = new bool[(int)Buttons.UNDEFINED]; lastButtons = new bool[(int)Buttons.UNDEFINED]; // Random seed random = new System.Random(); // Register APIs RegisterAPIs(); }
public void FillBuffer(float[] data, int channels) { int samples = data.Length; if (channelSfxPointers[0] < 0) { return; } for (var i = 0; i < samples; i = i + channels) { channelSfxTime[0] += sampleDelta; double time = channelSfxTime[0] - channelSfxTime[0] % 1 / 22050d; data[i] = (float)(gain * (channelSfxNote[0].volume / 7d) * AudioProcessingUnit.Oscillate(channelSfxNote[0].waveform, time, channelSfxNote[0].hz)); if (channelSfxTime[0] > channelSfxNoteLength[0]) { StepNodeForChannel(0); } if (channels == 2) { data[i + 1] = data[i]; } } }