<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>alavi.me - science</title>
    <subtitle>My mind on the web</subtitle>
    <link rel="self" type="application/atom+xml" href="https://alavi.me/tags/science/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://alavi.me"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2024-10-01T00:00:00+00:00</updated>
    <id>https://alavi.me/tags/science/atom.xml</id>
    <entry xml:lang="en">
        <title>Understanding Sample Rate, Bit Rate And Bit Depth</title>
        <published>2024-10-01T00:00:00+00:00</published>
        <updated>2024-10-01T00:00:00+00:00</updated>
        
        <author>
          <name>
            Alireza Alavi
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alavi.me/blog/samplerate-bitrate-bitdepth/"/>
        <id>https://alavi.me/blog/samplerate-bitrate-bitdepth/</id>
        
        
        <content type="html" xml:base="https://alavi.me/blog/samplerate-bitrate-bitdepth/">&lt;p&gt;These are my notes as a software engineer on understanding Sample rate, bit rate and bit depth.&lt;&#x2F;p&gt;
&lt;p&gt;The explanations might seem incoherent at first, but I think if you read the whole post it becomes more clear.
Also read the &lt;a href=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;#relevant-and-good-posts&quot;&gt;relevant and good posts&lt;&#x2F;a&gt; for some other explanations from other perspectives.&lt;&#x2F;p&gt;
&lt;p&gt;The notes are written in an outline style.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;our-world-is-continuous-analog&quot;&gt;Our World Is Continuous (Analog)&lt;a class=&quot;zola-anchor&quot; href=&quot;#our-world-is-continuous-analog&quot; aria-label=&quot;Anchor link for: our-world-is-continuous-analog&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sounds in our world are analog. The sounds that you hear or the sounds that you make are all analog signals&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Analog signals happen in &lt;strong&gt;continuous&lt;&#x2F;strong&gt; time. Meaning, if we want to draw a diagram of the signal representing it&#x27;s intensity on one axis and time on another (A signal is a series of changes in time), the diagram would look like this:
&lt;img src=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;.&#x2F;assets&#x2F;Analog-Signal-433185949.png&quot; alt=&quot;What is Analog Signal? - ELE Times&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;In order for these signals to be understood, used and processed in our digital devices (phones, PC, TV, etc.) they should be converted into digital signals, used within the device and then either be sent to another digital medium, or be converted to an analog signal again and then sent to an analog medium
(Digital signals are explained later).&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Example from sound&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
&lt;p&gt;Your voice(analog) -&amp;gt; travels through air to reach microphone(analog) -&amp;gt; microphone vibrates (analog) -&amp;gt; gets converted to digital -&amp;gt; sent as digital signal to a speaker via a digital medium (digital signals on a wire)-&amp;gt; the speaker vibrates the air in a way that recreates your voice (analog) -&amp;gt; travels through air (analog) -&amp;gt; The listener&#x27;s ear picks up the vibrations(analog) -&amp;gt; Signals in nervous system (?)&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;Time, As we define it, is continuous(or as continuous as it gets) so anything happening in our world is continuous, since it happens in time.&lt;&#x2F;p&gt;
&lt;p&gt;Also note that all of the things that I said might not be true, since we really don&#x27;t have a concrete definition of what time is, and the line between continuity and being discrete is blurry(like most other things in our world).&lt;&#x2F;p&gt;

&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;what-are-digital-signals&quot;&gt;What Are Digital Signals?&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-are-digital-signals&quot; aria-label=&quot;Anchor link for: what-are-digital-signals&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;A digital signal is a type of &lt;strong&gt;discrete signal&lt;&#x2F;strong&gt;(as opposed to &lt;strong&gt;continuous&lt;&#x2F;strong&gt; ).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Discrete signal&lt;&#x2F;strong&gt;: we will ignore the continuity of time, and assume that time happens in discrete amounts. So there will be nothing there between time 1 and time 2.&lt;&#x2F;li&gt;
&lt;li&gt;Now &lt;strong&gt;digital means:&lt;&#x2F;strong&gt; our &lt;strong&gt;time&lt;&#x2F;strong&gt; is discrete, and our &lt;strong&gt;intensities&lt;&#x2F;strong&gt; are &lt;strong&gt;also&lt;&#x2F;strong&gt; discrete&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;blockquote&gt;
&lt;p&gt;In &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Digital_signal_processing&quot;&gt;digital signal processing&lt;&#x2F;a&gt;,
a digital signal is a representation of a physical(analog) signal that is
sampled and quantized. A digital signal is an abstraction that is
discrete in time and amplitude. [1]&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;.&#x2F;assets&#x2F;Digital.signal.discrete.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;See how in the above diagram, no values can exist between the defined values.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-to-convert-analog-signal-to-digital-signal&quot;&gt;How To Convert Analog Signal To Digital Signal&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-to-convert-analog-signal-to-digital-signal&quot; aria-label=&quot;Anchor link for: how-to-convert-analog-signal-to-digital-signal&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Now, With that explanation of digital signals, we can understand the basics of how we convert analog signal to digital:
&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;discrete time intervals&lt;&#x2F;strong&gt; (for example every second), we will &lt;strong&gt;sample&lt;&#x2F;strong&gt; our signal. Meaning, we will measure it at that moment.
This is called our &lt;strong&gt;sample rate&lt;&#x2F;strong&gt; (here our sample rate is 1 sample per second)&lt;&#x2F;li&gt;
&lt;li&gt;Now that we took the sample, since our original signal is continuous, our measured intensity value is a Real number($\mathbb{R}$) and can be something like 0.333333.... or $\pi$ (3.14...),
we cannot use that number in our digital system! So we have to round it to a &lt;strong&gt;defined value&lt;&#x2F;strong&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Imagine our digital signal graph as a checkered graph.
The vertical lines are your time intervals (sample rate as we defined earlier) and the vertical lines are your defined values, to which you will round your intensities.
The more dense the vertical lines are, the higher your sample rate.
And the more dense your horizontal lines, the higher accuracy for rounding your intensities you have (&lt;strong&gt;Bit depth&lt;&#x2F;strong&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Analog signal:&lt;&#x2F;strong&gt;
&lt;img src=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;.&#x2F;assets&#x2F;analog.png&quot; alt=&quot;graph of an analog signal&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Digital signal with lower bit depth and sample rate&lt;&#x2F;strong&gt; ( we consider the thicker lines as our bit depth and sample rate values in this example ):
&lt;img src=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;.&#x2F;assets&#x2F;digital-lowrate.png&quot; alt=&quot;graph of digital signal with lower rate&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Digital signal with higher bit depth and sample rate&lt;&#x2F;strong&gt; ( all lines are considered as our bit depth and sample rate values):
&lt;img src=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;.&#x2F;assets&#x2F;digital-highrate.png&quot; alt=&quot;graph of analog signal with high rate&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Notice how as we raise the sample rate and bit depth, we get closer to our actual analog signal
&lt;img src=&quot;https:&#x2F;&#x2F;external-content.duckduckgo.com&#x2F;iu&#x2F;?u=https%3A%2F%2Fwoodandfirestudio.com%2Fwp-content%2Fuploads%2F2023%2F05%2Fen1-1.jpg&amp;amp;f=1&amp;amp;nofb=1&amp;amp;ipt=6bd309b419d31bfab05f6a8fdd79afa224a6c00e139b3da4335d9660d2f3eca6&amp;amp;ipo=images&quot; alt=&quot;Sampling rate &amp;amp; bit depth explained in simple terms&quot; &#x2F;&gt;
&lt;img src=&quot;https:&#x2F;&#x2F;external-content.duckduckgo.com&#x2F;iu&#x2F;?u=https%3A%2F%2Funison.audio%2Fwp-content%2Fuploads%2FSample-Rate-vs-Bit-Depth.png.webp&amp;amp;f=1&amp;amp;nofb=1&amp;amp;ipt=04967924bc439f8e694c41b30e6649a8405f527ae835fcd0f376a03fcbb33591&amp;amp;ipo=images&quot; alt=&quot;https:&#x2F;&#x2F;external-content.duckduckgo.com&#x2F;iu&#x2F;?u=https%3A%2F%2Funison.audio%2Fwp-content%2Fuploads%2FSample-Rate-vs-Bit-Depth.png.webp&amp;amp;f=1&amp;amp;nofb=1&amp;amp;ipt=04967924bc439f8e694c41b30e6649a8405f527ae835fcd0f376a03fcbb33591&amp;amp;ipo=images&quot; &#x2F;&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;why-is-it-called-bit-depth&quot;&gt;Why Is It Called &quot;bit depth&quot;?&lt;a class=&quot;zola-anchor&quot; href=&quot;#why-is-it-called-bit-depth&quot; aria-label=&quot;Anchor link for: why-is-it-called-bit-depth&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A &quot;bit&quot; is the smallest value in a digital system. It&#x27;s either 0 or 1&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;One bit can represent 2 values, and 2 bits can represent 4 values. The general rule is with $n$ bits we can represent $2^n$ values.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Bit depth refers to &quot;how many bits do we have for the number we want to represent our intensity with?&quot; so the more bits we have, more values we can express. So our estimations of our analog signal&#x27;s intensity becomes more accurate&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;A 24-bit audio is more accurate in terms of the intensity of each sample than a 16-bit&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Example with color:
An image with 8-bit depth is more accurate in displaying different intensities (shades) of colors&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;alavi.me&#x2F;blog&#x2F;samplerate-bitrate-bitdepth&#x2F;.&#x2F;assets&#x2F;bit-depth.png&quot; alt=&quot;Demonstration of the effect of increasing bit depth in an image&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;We can say that:&lt;br &#x2F;&gt;
if (sample_rate $\rightarrow \infty$ and bit_depth $\rightarrow \infty$) then &lt;strong&gt;Our signal is analog&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;

&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;what-is-bit-rate&quot;&gt;What Is &quot;bit rate&quot;?&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-is-bit-rate&quot; aria-label=&quot;Anchor link for: what-is-bit-rate&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;bit rate&lt;&#x2F;strong&gt; (&lt;strong&gt;bitrate&lt;&#x2F;strong&gt; or as a variable &lt;em&gt;R&lt;&#x2F;em&gt;) is the number of &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Bit&quot;&gt;bits&lt;&#x2F;a&gt; that are conveyed or processed per unit of time.[2]&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;blockquote&gt;
&lt;p&gt;The bit rate is expressed in the unit &lt;strong&gt;bit per second&lt;&#x2F;strong&gt; (symbol: &lt;strong&gt;bit&#x2F;s&lt;&#x2F;strong&gt;), often in conjunction with an &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SI_prefix&quot;&gt;SI prefix&lt;&#x2F;a&gt; such as &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Kilo-&quot;&gt;kilo&lt;&#x2F;a&gt; (1 kbit&#x2F;s = 1,000 bit&#x2F;s), &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Mega-&quot;&gt;mega&lt;&#x2F;a&gt; (1 Mbit&#x2F;s = 1,000 kbit&#x2F;s), &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Giga-&quot;&gt;giga&lt;&#x2F;a&gt; (1 Gbit&#x2F;s = 1,000 Mbit&#x2F;s) or &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Tera-&quot;&gt;tera&lt;&#x2F;a&gt; (1 Tbit&#x2F;s = 1,000 Gbit&#x2F;s).[2]&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;relevant-and-good-posts&quot;&gt;Relevant And Good Posts&lt;a class=&quot;zola-anchor&quot; href=&quot;#relevant-and-good-posts&quot; aria-label=&quot;Anchor link for: relevant-and-good-posts&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;pudding.cool&#x2F;2018&#x2F;02&#x2F;waveforms&#x2F;&quot;&gt;
  Let&#x27;s learn about waveforms - The pudding
&lt;&#x2F;a&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.waveroom.com&#x2F;blog&#x2F;bit-rate-vs-sample-rate-vs-bit-depth&#x2F;&quot;&gt;
  Bit rate vs. Sample rate vs. Bit depth - waveroom
&lt;&#x2F;a&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;engineeryoursound.com&#x2F;continuous-vs-discrete-signals-what-is-the-difference&#x2F;&quot;&gt;
  Continuous vs discrete signals. What is the difference? - engineeryoursound
&lt;&#x2F;a&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.izotope.com&#x2F;en&#x2F;learn&#x2F;digital-audio-basics-sample-rate-and-bit-depth.html&quot;&gt;
  Digital audio basics: sample rate and bit depth - izotope
&lt;&#x2F;a&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;a class=&quot;zola-anchor&quot; href=&quot;#sources&quot; aria-label=&quot;Anchor link for: sources&quot;&gt;&lt;i class=&quot;icon&quot;&gt;&lt;&#x2F;i&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;1: &lt;a class=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Digital_signal&quot;&gt;
Digital signal - wikipedia
&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;2: &lt;a class=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Bit_rate&quot;&gt;
Bit rate - wikipedia
&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
</feed>
