Commit Graph

11 Commits

Author SHA1 Message Date
Se.Cherkasov
1e7a6a9e48 fix(apu): correct frame counter timing, add LP filter, mute aliased triangle
- Fix frame counter running at 2× speed: clock_frame_counter now skips
  odd CPU cycles (APU cycle = CPU/2), so envelope, sweep, and length
  counters tick at the correct rate. Fixes sweep-driven whistle in Megaman II.

- Switch audio sampling to per-CPU-cycle granularity in
  run_until_frame_complete_with_audio to eliminate square-wave harmonic
  aliasing caused by sampling only once per instruction.

- Add IIR one-pole low-pass filter (~14 kHz) to AudioMixer to smooth
  abrupt level transitions (crackling) introduced by correct envelope timing.

- Mute triangle channel when timer_period < 2 (≥27 kHz), which aliases
  into the audible range at 48 kHz. Real NES RC circuit removes these
  ultrasonics; emulator must suppress them explicitly.

- Update all APU bus tests to use correct (doubled) CPU cycle counts.
2026-03-14 17:35:35 +03:00
d2be893cfe fix: stabilize desktop audio playback
Some checks failed
CI / rust (push) Has been cancelled
2026-03-13 19:20:33 +03:00
f86e3c2284 docs: add audio output design spec and implementation plan 2026-03-13 16:21:30 +03:00
e113c53fb7 feat(desktop): replace audio stub with cpal backend and volume slider
- CpalAudioSink writes to SPSC ring buffer, cpal callback reads
- Graceful fallback to silent operation on audio device errors
- Volume slider (0-100%) in header bar with speaker icon
- Ring buffer cleared on ROM load and reset
2026-03-13 16:21:25 +03:00
bddc144c27 feat: add lock-free SPSC ring buffer for audio streaming
AtomicU32-based storage avoids unsafe while maintaining SPSC guarantees.
Capacity: 4096 samples (~85ms at 48kHz). Exported from crate root.
2026-03-13 16:21:19 +03:00
5895344f6f feat(mixer): 5-channel APU mixing with linear approximation formula 2026-03-13 16:09:50 +03:00
e63b5783bd feat(apu): add ChannelOutputs struct and channel_outputs() method 2026-03-13 16:08:55 +03:00
49568a582b feat(apu): clock pulse/triangle/noise timers and sequencers 2026-03-13 16:07:57 +03:00
cd0a99a813 feat(apu): add timer/sequencer/LFSR fields for channel output tracking 2026-03-13 16:06:37 +03:00
6f81eb4b08 chore: ignore local worktrees 2026-03-13 15:06:29 +03:00
bdf23de8db Initial commit: NES emulator with GTK4 desktop frontend
Some checks failed
CI / rust (push) Has been cancelled
Full NES emulation: CPU, PPU, APU, 47 mappers, iNES/NES 2.0 parsing.
GTK4 desktop client with HeaderBar, pixel-perfect Cairo rendering,
drag-and-drop ROM loading, and keyboard shortcuts.
187 tests covering core emulation, mappers, and runtime.
2026-03-13 11:48:45 +03:00