Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
306 lines (270 sloc) 14.3 KB
This is an NSF player program for Windows, and also a Winamp plugin. The original version of this program was written by Brezza and is still available at
To use as a Winamp plugin, simply copy the contents of the plugins folder to your Winamp plugins folder.
Full source code is available at:
If you have any questions, comments, or find any bugs, please send them to me.
Brad Smith
nsfplay AT
NSFPlay Keyboard controls
Z > Prev
X > Play
C > Pause
V > Stop
B > Next
Command line arguments
NSFPlay [filename]
> Open and begin playing NSF file.
NFSPlay [nsf_filename] [wav_filename] [track] [milliseconds]
> Create WAV file from command line (cuts off after milliseconds are reached, or loop detection).
Configuration files
The default configuration file is in_yansf.ini, found in the plugins folder.
Global options:
RATE: samplerate
NCH: 1-2 number of channels
BPS: 16 bits per sample (don't change this)
MASK: bitfield channel mask (1 bit mutes channel)
PLAY_TIME: (ms) default play time
FADE_TIME: (ms) fade out time
STOP_SEC: (s) seconds of silence before auto stop
LOOP_NUM: (#) loops to allow before stopping
AUTO_STOP: 1=automatically stop after silence
DETECT_TIME: (ms) loop detection comparison buffer
DETECT_INT: (ms) jitter allowed between time comparisons in loop detection
LPF: 0-400 lowpass filter strength (0=off, 112=default, 400=full)
HPF: 0-256 highpass filter strength (256=off, 164=default, 0=full)
TITLE_FORMAT: title string format (see below), default: %L (%n/%e) %T - %A
DETECT_ALT: 1=use alternate loop detection algorithm
VSYNC_ADJUST: 1=ignore NSF frame length setting
MULT_SPEED: clock multiplier (256 = no multiplier)
COMP_LIMIT: 0-100 compressor limit
COMP_THRESHOLD: 0-100 compressor threshold
COMP_VELOCITY: 0-100 compressor velocity
NTSC_BASECYCLES: NTSC master clock speed
PAL_BASECYCLES: PAL master clock speed
DENDY_BASECYCLES: DENDY master clock speed
REGION: 0=auto, 1/2=prefer NTSC/PAL, 3/4/5=force NTSC/PAL/DENDY
VRC7_PATCH: 0-7 patch set for VRC7 (see below)
MASTER_VOLUME: 0-255 master volume
NSFE_PLAYLIST: 1=use playlist data from NSFe when found
MASK_INIT: 1=clear channel mask on play
INFO_DELAY: (ms) latency delay for keyboard view
INFO_FREQ: (Hz) keyboard view update frequency
GRAPHIC_MODE: 1=display graphical waveforms for FDS/N163
FREQ_MODE: 1=display Hz in keyboard view, 0=display hexadecimal pitch register
LAST_PRESET: name of the last sound preset used
LOG_CPU: log CPU writes to file (0=off, 1=sound only, 2=all writes, 3=all r/w, 4 bank and RAM writes)
LOG_CPU_FILE: filename of CPU write log
TITLE_FORMAT text replacement:
%F/%f > filename
%P/%p > path
%T/%t > NSF title
%A/%a > NSF artist
%C/%c > NSF copyright
%L/%l > NSFe song title
%N > song number, 2-digit hex with leading zero
%n > song number, 3-digit decimal with leading zeroes
%S > NSF starting song, 2-digit hex with leading zero
%s > NSF starting song, 3-digit decimal with leading zeroes
%E > NSF song count, 2-digit hex with leading zero
%e > NSF song count, 3-digit decimal with leading zeroes
Device options:
Devices (XXX) are: APU1, APU2, 5B, MMC5, N163, VRC6, VRC7, FDS
XXX_VOLUME: 0-255 device volume
XXX_QUALITY: 0-3 oversampling control
XXX_FILTER: 0-400 lowpass filter (0=off, 400=full)
XXX_MUTE: 1/0 mute channel yes/no
XXX_THRESHOLD: 0-100 compressor threshold (100=off)
APU1_OPTION0: unmute on reset
APU1_OPTION1: phase reset
APU1_OPTION2: nonlinear mixing
APU1_OPTION3: famiclone swapped duty (1<->2)
APU2_OPTION0: enable $4011 writes
APU2_OPTION1: enable periodic noise
APU2_OPTION2: unmute on reset
APU2_OPTION3: anti clicking (suppresses $4011 pop without disabling its nonlinear mix)
APU2_OPTION4: nonlinear mixer
APU2_OPTION5: randomize noise on reset
APU2_OPTION6: mute triangle on pitch 0 (prevents high frequency aliasing)
FDS_OPTION0: (Hz) lowpass filter cutoff frequency (0=off, 2000=default)
FDS_OPTION1: reset "phase" on $4085 write (works around timing issue in Bio Miracle Bokutte Upa)
FDS_OPTION2: write protect $8000-DFFF (for some multi-expansion NSFs)
MMC5_OPTION0: nonlinear mixing
MMC5_OPTION1: phase reset
N163_OPTION0: serial multiplexing (more accurate sound for 6+ channels)
Channel options:
There are 29 channels, as appear vertically in the channel mixer, numbered (XX) from 00 to 28.
CHANNEL_XX_PAN: 0-255 panning (0=left, 255=right, 128=centre)
CHANNEL_XX_VOL: 0-128 volume
CHANNEL_XX_COL: hex string for keyboard view colour (exactly six characters, no leading space)
5B_ENVELOPE_COL: keyboard colour for 5B envelope
5B_NOISE_COL: keyboard colour for 5B noise
VRC7 patch sets: (VRC7_PATCH)
0 - VRC7 set by rainwarrior 8/01/2012 (used by Famitracker 0.4.0)
1 - VRC7 set by quietust 1/18/2004 (used by Famitracker 0.3.6)
2 - VRC7 set by Mitsutaka Okazaki 6/24/2001 (used by Famitracker 0.3.5 and prior)
3 - VRC7 set by Mitsutaka Okazaki 4/10/2004
4 - VRC7 set by kevtris 11/15/1999 (second set in vrcvii.txt)
5 - VRC7 set by kevtris 11/14/1999 (first set in vrcvii.txt)
6 - YM2413 set by Mitsutaka Okazaki 4/10/2004
7 - YMF281B set by Chabin 4/10/2004
NSFPlug supports Winamp M3U playlists in the same style as NEZplug.
The playlist is a text file with one track per line in the form:
filename - relative path to NSF file
song - track number from the NSF (track 1 is the first track)
title - title of the track
time - h:m:s length of the track
loop - h:m:s loop length, h:m:s- loop start time, - no loop, 0 no loop
fade - h:m:s fade time
loopcount - number of times to loop, 0 default
NSFPlay 2.4 beta ?? - ??? (unofficial build)
- Fixed incorrect bytes per second in stereo WAV output.
- Fixed NSFe track title display when using playlist.
- Fixed crash issue with 1MB NSF files. (Bank counting was incorrect.)
- Default NTSC speed changed from 16640 to 16639. (Slightly more accurate to hardware.)
- More bits of precision on fade-out, creates smoother fade.
- 48000Hz is the new default samplerate.
- Fixed keyboard view wave string bias on N163/FDS.
- Fixed frequency rounding for triangle/noise/DMC in keyboard display.
- Fixed intermittent crash with Winamp starting up with NSF in playlist.
- Fixed FDS mod table bit-mask and wavetable read address. (Minor.)
- Fixed broken playback rate for rates < 28 Hz.
- NSFe RATE chunk implemented.
- NSFe regn chunk implemented, including full Dendy support.
- NSFe mixe chunk implemented.
- NSF2 partial support for metadata (as NSFe chunks).
- Drag and drop will now acknowledge a failed load with a pop-up alert.
NSFPlay 2.3 - 7/19/2013
- All illegal 6502 opcodes are now emulated.
- Audio emulation is now driven by CPU clock cycles, increases timing accuracy.
- FDS emulation completely rewritten for better accuracy.
- N163 emulation completely rewritten for better accuracy.
- APU frame sequencer now correctly driven by $4017, supports 4 and 5 step modes, immediate reset, and IRQ flag.
- MMC5 frame sequencer now independant of APU frame sequencer.
- Time dilation now slows frame sequencer along with CPU rate.
- Replaced PREFER_PAL setting with REGION, containing more options including Dendy support.
- Swapped duty option for APU1.
- More effective implementation of DMC anti-click option.
- Removed useless "frequency limiter" APU option.
- Added optional mute for ultrasonic triangle.
- Fixed broken oversampling filter.
- Adjusted device volumes to match more careful measurements, all centred at 128 now.
- Better small icon.
- Thinner DPCM address display, does not get truncated.
- Using # instead of + for note names.
- Cosmetic fixes in settings dialog.
- Keyboard frequency display correction for APU/MMC5/VRC6 (were off by 1).
- Keyboard envelope display now shows L for loop.
- N163 waveform display now hides waveform when track is muted with a wave length >= 128.
- Expanded infobox info for NSFe.
- Fixed improper loading of UI DLL, prevents crash in same folder as Famitracker.
- UI DLL now reports version, preventing potential problems if mismatched.
- LOG_CPU option for dumping register writes to file.
- Fixed song wrap where NSFs do not start on song 1.
- Source code cleanup: removing unrelated Z80 emulation code.
NSFPlay 2.2 - 8/31/2012
Audio Emulation:
- Unmute on reset now sets $4015 to $0F instead of $1F.
- PAL noise frequency $1 now 8 instead of incorrectly 7.
- New VRC7 patch set, option to select alternative patch sets via VRC7_PATCH.
- 5B polarity inverted, envelope adjusted, volume tweak.
- MMC5 polarity inverted, length counter runs at double speed, highest 8 frequencies are not muted.
- VRC6 $9003 register implemented (controls halt and frequency multiplier)
- VRC6 polarity inverted, phase reset now functions properly.
- FDS now uses NSF header $76/$77 to set up $6000-7FFF memory range.
- FDS $4087 bit 7 now mutes modulator.
- Enable periodic noise option fixed. (Forced perodic noise by accident.)
- Fixed improper $4015 read implementation (should return length counter status), also DPCM IRQ was not initialized.
- Default focus in keyboard window now the track list (to prevent accidental mouse scroll time expansion).
- Fixed Winamp visualizer timing inaccuracy, changed default keyboard delay/freq.
- Inverted VRC7 volume display in keyboard view.
- NSFe support.
- Added NSFe extension block 'text', contains null terminated string of any length (NSF text).
- Removed broken ENABLE_DCF config option. HPF=256 now correctly disables HPF.
- Rewrote LPF and HPF, should have a more usable range of options now.
- Removed XXX_FR/XXX_FC options, now XXX_FILTER works like LPF for each device.
- Memory R/W access is now exclusive to the first device that accepts it; prevents FDS multi-expansion write conflicts.
- Title string will automatically remove whitespace at its beginning or end.
- Fixed single instance bug, was failing to open new NSF file when chosen from explorer.
- Fixed conflicts between keyboard commands and other dialogs.
- Removed tag menu from info page. Does not appear to apply to NSFs.
- Fixed incorrect PAL pitch when QUALITY=0.
NSFPlay 2.1 - 3/27/2012
Audio Output:
- Fixed race condition in audio buffering; stand alone NSFPlay would occasionally get stuck stuttering.
- Produces stereo output, channel mixer dialog for panning and per-channel volume control.
- Fixed PCM playback speed; CPU execution was counting requested clocks, not clocks executed.
- Fixed accuracy of seek times.
- Loop detection now accounts for all audio registers, not just a subset of 2A03 and N163.
- N163 wavelength is actually 6-bit, not 3. Now allows sample length up to 256.
- Fixed FDS volume/sweep envelope caps. (Direct register writes can make them louder.)
- Fixed FDS modulation bias calculation and wrapping.
- Set default volume for VRC7 and FDS a little lower (to match expected levels).
- MMC5 PCM support (for both read and write mode).
- Added phase reset option to MMC5.
- MMC5 was missing length counter and audio register reads; rewrote to conform with APU.
- Adjusted phases for APU/MMC5 square channels to match NesDev's description.
- APU/DMC/MMC5 rewrite of envelope/length/sweep behaviour to use a frame sequencer instead of independent timers.
- Option to randomize noise on reset (on by default).
- Options cleanup, removed unused/deprecated options from .ini file.
- Using global LPF by default instead of on each device (saves CPU, same result).
- Keyboard view channel colour is now customizable in .ini file (CHANNEL_XX_COL).
Keyboard view:
- Fixed crash due to keyboard OnTimer being allowed before Reset() is executed by the PlayThread.
- Double buffering keyboard view to remove flicker.
- Different colours for different expansions in keyboard view.
- Fixed sound lag after seek.
- FME-7 now named 5B, N106 now named N163.
- DPCM now named DMC in keyboard view.
- Fixed 5B volume display (E now correctly indicates envelope, volume is now correct value).
- 5B now displays envelope and noise.
- VRC6 saw volume now displays accumulator register.
- Corrected VRC6 saw pitch in keyboard view.
- Fixed trailing lines on N163 waveform display.
- DMC volume display no longer flipped (is now $4011 register value).
- DMC now shows sample frequency rather than byte frequency.
- Triangle and noise were not showing muting due to length counter of 0.
- Noise now has frequency display (either rate of random samples, or tonal frequency for periodic noise).
- Removed feature that extends the life of key dots beyond the frame the channel is active (frequency can change when key is silent, esp. VRC6 squares, which visibly jump to the wrong pitch)
- Save WAV button on NSFPlay.
- Command line WAV output for batch processing.
- Added extra NSF header information to "misc" text box, initial banks, load/init/play addresses, etc.
- Fixed thread-safety issue for configuration (was accessed liberally from many threads).
- Removed legacy code for windows versions older than XP.
- CPU trace define in nes_cpu.cpp for debugging.
NSFPlay 2.0 - 2/22/2012
- Restructured sln/vcproj files, and rebuilt for VS9.
- All intermediate files go into common Debug/Release directories.
- Renamed wa2nsf project to in_yansf to match name of the plugin.
- Fixed improperly set WAVEFORMATEX header in libemuwa2 (allows execution on windows Vista/7).
- Corrected pitch of noise channel.
- Updated VRC7 default patch set.
- Added PAL support and pal flags indicator (PREFER_PAL=1 to prefer PAL for dual mode).
- Added about box for determining build version.
- Fixed some menu items in English dialogs.
- Fixed some initial config settings.
- Fixed crash when using playlist menu options with no loaded NSF.
NSFPlay - 12/09/2006
- Written by Brezza >
end of document