樹莓派聲音︰ PWM

人們追求『原音重現』,

高傳真

高傳真英語:High fidelity,簡稱hi-fi)是家庭音響愛好者使用的術語,總體上要求音響系統在額定輸出功率下具有足夠高的信噪比 ,波形與輸入信號相比失真足夠低,並具有範圍足夠寬且在範圍內沒有明顯起伏的頻率響應。這一概念大約誕生於50年代,最初是完全主觀而無定量標準,1966年西德DIN(德國標準化學會)制定DIN 45500標準為高傳真的定量化和產品使用此稱謂的技術指標最低限提供了指導。[1] 到21世紀之後,隨著電子器件性能的提高,集成電路和數位技術的普及,市售的絕大多數廉價設備都能輕易達到60年代DIN所規定的最低標準,於是音響愛好 者對「高傳真」概念賦予了更主觀,更嚴苛的要求。為了追求聽感上的些微優越性,一些「發燒友」不惜在器材上投入巨資,比如更換貴金屬導線,而帶來的提高如 用常用的技術指標來形容,有時微不足道,其提高的原理有時也不易用普及性的電物理知識解釋,比如發燒友提出金質導線能帶來更純粹的音質,而從物理上說,金 材料的電阻率甚至大於銅 。於是,對高檔「高傳真」音響設備音質優越性的論斷,一直存在爭議,一些人試圖證明心理作用的影響,而發明了「AB盲聽」等一系列 有趣的實驗,不過迄今也沒有得出確切的結論,一般認為,理解的偏差可能和生理聽覺和大腦處理聲音的敏感度有關,也未必盡然是玄學

系統長久矣。時至今日,戴著耳機聽 mp3 彷彿才是時尚。這或許與高級音響依舊昂貴,若是不 知缺乏好的 Hi-Fi

High fidelity

High fidelity—or hi-fi or hifi—reproduction is a term used by home stereo listeners, audiophiles and home audio enthusiasts to refer to high-quality reproduction of sound[1] to distinguish it from the lower quality sound produced by inexpensive audio equipment, or the inferior quality of sound reproduction that can be heard in recordings made until the late 1940s.

Ideally, high-fidelity equipment has inaudible noise and distortion, and a flat (neutral, uncolored) frequency response within the intended frequency range.[2]

220px-audiovisual

Hi-fi speakers are a key component of quality audio reproduction.

 

揚聲器 Speakers 仍然無法欣賞音樂美聲,宛如在現場聽演唱會一般 。還請善待自己的耳朵,選個好點的喇叭,就可以輕鬆舒適地享受影音的樂趣也。

Adafruit 網頁上有一篇很好的文章

To keep the Raspberry Pi Zero as low cost and small as possible, the Pi foundation didn’t include a 3.5mm audio jack. There’s also no breakout pads for the audio output. This made us a little 🙁 at first but then we thought “hey you know, we can probably figure out how to get audio out with a little hacking!

How Audio Works on Other Pi Computers

The Broadcom chipset used for the Pi does not have a true analog output. Instead, two pins are PWM (pulse-width-modulated) at very high speeds, and filtered. The PWM frequency has to be at least 10x as high as the highest frequency we want to replicate in audio. Then, by adjusting the duty cycle of the PWM, we can ‘fake’ an audio signal.

Audio is 20Hz to 20KHz, and the PWM output from the Pi is 50MHz so we can easily filter the high 50MHz out (and anyways it cant be heard).

Looking at the Pi B schematic, we can see PWM0_OUT and PWM1_OUT are the left and right channels. R21 and R20 are voltage dividers to get the 3.3V signal down to about 1.1V max (that’s the max peak-to-peak voltage you want for audio line level.

C20/C26 works with R21/R27 to create an “RC low-pass filter”. You can calculate the cut-off frequency with 1/(2*pi*RC) = 1/(2*pi*270*33*10-9) = 17865 Hz which is pretty close to 20KHz!

C48/C34 acts as a DC-filter capacitor, it only allows AC through – speakers and headphones don’t like DC voltage!

Finally 8AV99 are ESD protection diodes. That’s to protect the Pi from static coming in and zapping the PWM pins..

Pi Zero PWM Audio

On the Pi Zero, we dont have pins PWM0 (pin #40) and PWM1 (pin #45)- those are not available on the PCB. That would normally be super 🙁 🙁 but it turns out that while those pads are not exposed, we can re-route those signals to other pins that we can get to!

You can get to PWM0 on GPIO #18 (ALT5) and PWM1 on GPIO #13 (ALT0) or GPIO #19 (ALT5) – see the full list of pins and alternate functions here

講述了樹莓派類比聲音輸出之電路和原理。不過 PWM

生 ︰何謂『脈衝寬度調變』 PWM Pulse-width modulation  ?《 網 》網說︰

500px-Duty_cycle_general.svg

Fig. 1: a pulse wave, showing the definitions of y_{min}, y_{max} and D.

350px-Pwm.svg

Fig. 2: A simple method to generate the PWM pulse train corresponding to a given signal is the intersective PWM: the signal (here the red sinewave) is compared with a sawtooth waveform (blue). When the latter is less than the former, the PWM signal (magenta) is in high state (1). Otherwise it is in the low state (0).

Pulse-width modulation uses a rectangular pulse wave whose pulse width is modulated resulting in the variation of the average value of the waveform. If we consider a pulse waveform f(t), with period T, low value y_{min}, a high value y_{max} and a duty cycle D (see figure 1), the average value of the waveform is given by:

<br /> \bar y=\frac{1}{T}\int^T_0f(t)\,dt.<br />

As f(t) is a pulse wave, its value is y_{max} for 0<t<D\cdot T and y_{min} for D\cdot T <t<T. The above expression then becomes:

"<br

This latter expression can be fairly simplified in many cases where y_{min}=0 as \bar y=D\cdot y_{max}. From this, it is obvious that the average value of the signal (\bar y) is directly dependent on the duty cycle D.

The simplest way to generate a PWM signal is the intersective method, which requires only a sawtooth or a triangle waveform (easily generated using a simple oscillator) and a comparator. When the value of the reference signal (the red sine wave in figure 2) is more than the modulation waveform (blue), the PWM signal (magenta) is in the high state, otherwise it is in the low state.

───《M♪o 之學習筆記本《丑》控制︰【紅火南】東籬南山

 

之解析度低、雜訊準位高、以及難以避免的抖動

Jitter

In electronics and telecommunications, jitter is the deviation from true periodicity of a presumably periodic signal, often in relation to a reference clock signal. In clock recovery applications it is called timing jitter.[1] Jitter is a significant, and usually undesired, factor in the design of almost all communications links.

Jitter can be quantified in the same terms as all time-varying signals, e.g., root mean square (RMS), or peak-to-peak displacement. Also like other time-varying signals, jitter can be expressed in terms of spectral density.

Jitter period is the interval between two times of maximum effect (or minimum effect) of a signal characteristic that varies regularly with time. Jitter frequency, the more commonly quoted figure, is its inverse. ITU-T G.810 classifies jitter frequencies below 10 Hz as wander and frequencies at or above 10 Hz as jitter.[2]

Jitter may be caused by electromagnetic interference and crosstalk with carriers of other signals. Jitter can cause a display monitor to flicker, affect the performance of processors in personal computers, introduce clicks or other undesired effects in audio signals, and cause loss of transmitted data between network devices. The amount of tolerable jitter depends on the affected application.

……

Sampling jitter

In analog to digital and digital to analog conversion of signals, the sampling is normally assumed to be periodic with a fixed period—the time between every two samples is the same. If there is jitter present on the clock signal to the analog-to-digital converter or a digital-to-analog converter, the time between samples varies and instantaneous signal error arises. The error is proportional to the slew rate of the desired signal and the absolute value of the clock error. Various effects such as noise (random jitter), or spectral components (periodic jitter)[specify] can come about depending on the pattern of the jitter in relation to the signal. In some conditions, less than a nanosecond of jitter can reduce the effective bit resolution of a converter with a Nyquist frequency of 22 kHz to 14 bits.[4]

This is a consideration in high-frequency signal conversion, or where the clock signal is especially prone to interference.

 

在 Hi-Fi 的召喚下,催促人們踏上 I2S Quest 之旅!!