Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Speaker output DC blocking #275
The Apple speaker code correctly drives the soundcard at +32767/-32768 for its two states, leaving the sound card with a large DC offset. I've noticed this cause loud clicks when my system is busy and AppleWin underruns its audio, as well as clicks when I change volume on the soundcard, both due to the DC offset. I guess my card is DC coupled. Recently I also noticed my connected Yamaha amp does not like the DC offset (eg: affects sound playing in Winamp).
How about for sampled sounds?
There is a remainder buffer which is used to store the remaining (up to) 23 samples at 1MHz which contribute to the next 44.1kHz sample. (NB. 23.191 x 44.1kHz = 1.023MHz.) When there's a speaker toggle, then this is likely to occur somewhere in this remainder buffer, and the next 44.1kHz sample will be the average of these 23 values.
Some question relating to this remainder buffer:
Anyway, given all the above, I think this patch is fine.
Hi Tom, thanks for the detailed analysis. Right after the initial pull
Line 468 - filling sound buffer from the sample mean
My idea was to let the speaker state go into the averaging in their raw
The filter does include a clamp ie:
Your analysis seems right, and there could be a click/transient when PWM
I'll do some A-B testing with the likes of Music Construction Set and
On 19/05/2015 7:13 AM, TomCh wrote:
FYI, one positive difference with this patch vs the latest release of AppleWin 188.8.131.52, is that with the current release you get a click when stopping at a Visual Studio debugger breakpoint (and another click on a restart). But with the patch there's silence.
EG. Break to the AppleSoft prompt and wait 1 sec to let the filter accumulate to 0x7FFF (ie. so that the DirectSound ring-buffer is just outputting 0x0000's).
Hi, I've made a recording of AppleWin 184.108.40.206 which I downloaded
The recording here has the older AppleWin version first followed by the
In my view the original version sounds less alias-y and when the first
There's a lot more DC offset in the waveform than I expected.
I'm guessing the DC filter is operating near the limit and the onset of
I can think of two workarounds:
I'm keen to give 1) a try, interested what you think of the samples.
On 20/05/2015 6:16 AM, TomCh wrote:
Just pushed a much better DC filter implementation using the attenuator
On 20/05/2015 6:16 AM, TomCh wrote:
Yep I'm still here for any questions on it.
As I last checked in, the most recent implementation where it "fades to
On 12/09/2016 12:49 PM, Michaelangel007 wrote:
From this link: What is "DC-coupled"?...
In terms of analog circuitry, electronics that are DC–coupled have their components connected directly together without any coupling capacitors. As capacitors tend to remove certain frequencies, coupling the circuitry without capacitors in-line allows the full spectrum of sound frequencies to pass through unfettered. This can be advantageous as many capacitors severely limit the passage of low frequencies, resulting in poor low-frequency response. Manufacturers such as Solid State Logic often use DC-coupled circuitry for this reason. As capacitors wear out over time, many devices will experience a decline in performance. By building equipment without capacitors in the circuit, a manufacturer ensures that will have the same frequency response and essentially sound the same years after its initial purchase. To illustrate this point, we’ll use a SSL DC-coupled XL 9000 K console as an example. Since no capacitors that can fail are in the signal path, channel 1 will sound the same as channel 32 (or any other channel, for that matter) year in and year out. DC-coupled equipment maintains a linear-phase relationship across all channels, further illustrating the advantage of this method of creating circuits. DC-coupled circuitry also tends to be utilized in audiophile and high-end recording equipment, as it tends to provide the “purest” sound.
Capacitors, of course, still play a large role in the construction of electronic equipment. In applications where DC voltage may damage the circuit, capacitors are placed in the signal path as a means of protecting transistors from being burned up by the DC current. Capacitors essentially condition the incoming signal by rejecting unwanted DC voltage. DC voltage is also typically undesirable in audio signals as it can cause distortion later in the signal path.
Back when I wrote this, I'm pretty sure I issued an updated pull. request
The initial version of my Applewin code DID use an accumulator to
My latest AppleWin commit has a much simpler approach - an attenuator.
When the Apple is silent for a period (second?), an attenuator applied
This means absolutely no impact on PWM.
Hope this version made it into the release, have not had time to check
On 23/10/2016 4:21 AM, TomCh wrote:
Thanks. I also appreciate the effort you put into AppleWin.
I don't wish to spam, but the 10 part video/blog series (so far) where
On 28/10/2016 8:05 PM, TomCh wrote: