Page 1 of 1

Non-linear mixing applies after playback stops

Posted: Fri Aug 28, 2015 10:45 am
by HertzDevil
Input the following pattern on launching FamiTracker, with instrument 00 blank:

Code: Select all

     # : Pulse 1      : Pulse 2
ROW 00 : C-3 00 . ... : ... .. . ...
ROW 01 : ... .. . ... : ... .. . ...
ROW 02 : ... .. . ... : ... .. . ...
ROW 03 : ... .. . ... : ... .. . ...
ROW 04 : ... .. . ... : E-3 00 . V02
ROW 05 : ... .. . ... : ... .. . ...
ROW 06 : ... .. . ... : ... .. . ...
ROW 07 : ... .. . ... : ... .. . ...
Play the pattern and stop when both pulse channels are playing, then play from the beginning again. There is a 50% chance that Pulse 1 will be attenuated by about 6 dB, and a click will be heard instantly as Pulse 1 is about to make sound. This happens because the volume level of Pulse 2 is not reset to the zero level when playback stops; the mixer still thinks that Pulse 2 is held at the output level before stopping, and for a square wave the output stays at the maximum half of the time. The pulse channels only access the mixer when there is output, whereas the first few rows of Pulse 2 do not contain notes at all, which explains why Pulse 1 will sound as though the other channel is outputting at 100% duty (i.e. maximum volume all the time) until the E-3 note plays. Using V00 and V03 instead of V02 causes Pulse 1 to be attenuated 12.5% and 75% of the time, verifying the action of this bug.

This serious bug means that, in the worst case as in this pattern, a pulse channel can become only half as loud while another channel is not playing. It occurs on 0.4.6 stable and 0.5.0 beta 5, however I am able to recreate this bug in 0.2.2, so it probably has never been reported since the creation of the playback code.

EDIT: It seems this can be fixed by simply telling the 2A03 channels to set the output to the zero level in the respective Reset() method. It might be good to do the same to expansion chips too.

Re: Non-linear mixing applies after playback stops

Posted: Tue Sep 01, 2015 10:04 pm
by za909
I've noticed a similar trend with N163 channels, but there I could recreate this simply by testing my instruments in normal mode and not actually laying down notes. Sometimes there's a peculiar low-pass filter-like effect on the note.

Re: Non-linear mixing applies after playback stops

Posted: Sun Sep 06, 2015 3:33 pm
by Dr. Merio
za909 wrote:Sometimes there's a peculiar low-pass filter-like effect on the note.

I have noticed this a lot when creating, and playing N163 songs, so I'm very interested in knowing what causes this.

Re: Non-linear mixing applies after playback stops

Posted: Sun Sep 06, 2015 5:24 pm
by HertzDevil
This I believe fixes it:

Code: Select all

void CN163::EndFrame()
{
   for (int i = 0; i < 8; ++i) {
      m_pChannels[i]->EndFrame();
      if (i != m_iActiveChan)      // // //
         m_pChannels[i]->ResetCounter();
   }

   m_iGlobalTime = 0;
}

void CN163Chan::ResetCounter() { m_iCounter = 0; }
I am still not quite sure what causes it after CN163Chan::Reset() is called. It depends on the current multiplexer state rather than the volume level.