Playing simple sound effects with NSF

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Playing simple sound effects with NSF
by on (#68018)
Hey guys, I'm working on a pretty simple project and I want to play tones on the PULSE 1 channel when a button is pressed while also playing music on the other 3 channels (DMC is unused)

I made an NSF that only has music playing on the PULSE 2, TRIANGLE, and NOISE channels. Removed the header in a hex editor, and used some of NO-CARRIER's code to get it running in my rom. The music runs perfectly.

I was previously using a controller test and some code like this to play some notes on the PULSE 1 channel:

lda #$4F
sta $4002
lda #%10001000
sta $4003

The channel was enabled earlier in the code like this:

lda #%00001111
sta $4015
lda #%10011111
sta $4000

This code worked perfectly too.

But now that I've combined the NSF playing code and the button pressing code I get no output from my button presses that used to generate tones, the music is playing though.

Maybe the nsf file is disabling the square one channel on me or something? Any suggestions for how to simultaneously play sounds and NSF background music?

by on (#68019)
Which music engine are you using in the NSF?

by on (#68021)
Oh, sorry, forgot to even mention that!
I'm using the newest version of Famitracker.

by on (#68128)
It is probably undoing every write you do every frame. One way to get sound effects to play (this is a method someone once told me) is to find out where it buffers the values it writes to the apu and then overwriting that with your sound effects each frame. (giving your sound effect priority but otherwise the engine stil runs)