<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Abdullah Arif Ansari on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Abdullah Arif Ansari on Medium]]></description>
        <link>https://medium.com/@abdullahansarii?source=rss-c20aa3e52214------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZArz2oUl1SybQ6WH61Owqw.jpeg</url>
            <title>Stories by Muhammad Abdullah Arif Ansari on Medium</title>
            <link>https://medium.com/@abdullahansarii?source=rss-c20aa3e52214------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 09:54:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abdullahansarii/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My FIR Bandpass Filter Passed Its Own Testbench for Six Years. It Was a Sign Detector.]]></title>
            <link>https://levelup.gitconnected.com/my-fir-bandpass-filter-passed-its-own-testbench-for-six-years-it-was-a-sign-detector-7bc1fecfa2df?source=rss-c20aa3e52214------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bc1fecfa2df</guid>
            <category><![CDATA[matlab]]></category>
            <category><![CDATA[fpga]]></category>
            <category><![CDATA[digital-filters]]></category>
            <category><![CDATA[verilog]]></category>
            <dc:creator><![CDATA[Muhammad Abdullah Arif Ansari]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 15:30:25 GMT</pubDate>
            <atom:updated>2026-09-08T15:30:25.022Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What MATLAB’s HDL Coder generated, why the generated testbench could never catch it, and the two word-length changes that fixed it.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ZKzidgHGlGIWoj2hyyfPYw.png" /></figure><p>In 2020 I built a FIR band-pass filter in Verilog for a university course. I designed the response in MATLAB, generated the RTL with Filter Design HDL Coder, ran the generated testbench, got no errors, wrote it up, submitted it, and put the whole thing on GitHub.</p><p>It picked up 13 stars and 8 forks. Eight people copied that code into their own projects.</p><p>Last week I went back to read it properly for the first time since. The 51-tap filter in that repository does not filter anything. Its output is the sign bit of the accumulator and nothing else — a comparator wearing a filter’s clothes.</p><p>And the generated testbench passed. Every time. For six years.</p><p>Here’s how that happens, because the failure mode is not specific to me, to MATLAB, or to filters.</p><h3>The repository</h3><p>Two designs, both Direct-Form FIR band-pass filters with exact linear phase:</p><ul><li>bandpass.v — 11 taps, fully serial. One multiplier, folded over 9 clock cycles. Passband 0.079–0.171 × f&lt;sub&gt;s&lt;/sub&gt;.</li><li>firbandpass.v — 51 taps, fully parallel. 51 multipliers, one sample per clock. Passband 0.191–0.255 × f&lt;sub&gt;s&lt;/sub&gt;, stopband below −56 dB.</li></ul><p>The coefficients in both are fine. I checked them by decoding the fixed-point constants straight out of the Verilog and computing the frequency response: symmetric, linear phase, exact zeros at DC and Nyquist. The DSP was never the problem.</p><p>The problem was in the boxes I filled in on the <em>Filter Internals → Specify Precision</em> tab.</p><h3>Bug one: an output that could only be ±full scale</h3><p>Here is the fixed-point specification the generator recorded in its own header comment:</p><pre>// Filter Internals  : Specify Precision<br>//   Output          : s8,32  -&gt; [-2.980232e-08 2.980232e-08)<br>//   Accumulator     : s20,20 -&gt; [-5.000000e-01 5.000000e-01)<br>//   Round Mode      : floor<br>//   Overflow Mode   : saturate</pre><p>Read those two ranges next to each other.</p><p>The accumulator holds values in ±0.5. The output can represent values in ±0.0000000298. The output format is ²²⁴ times narrower than the thing feeding it — a factor of about 17 million.</p><p>s8,32 means 8 bits total with 32 fractional bits. That is legal fixed-point notation, and it describes a number that can only express values smaller than 2⁻²⁵. I have no memory of choosing it. I suspect I typed a word length and a fraction length into two boxes without checking that the combination made sense, and the tool did exactly what I asked.</p><p>The generated conversion between them looks like this:</p><pre>assign output_typeconvert =<br>    (sum50[19] == 1&#39;b0 &amp; sum50[18:0] != 19&#39;b0000000000000000000) ? 8&#39;b01111111 :<br>    (sum50[19] == 1&#39;b1 &amp;&amp; sum50[18:0] != 19&#39;b1111111111111111111) ? 8&#39;b10000000 :<br>    $signed({sum50[19], 7&#39;b0000000});</pre><p>Translated: <em>if the accumulator is positive and not exactly zero, output +127. If it is negative and not exactly −1 LSB, output −128. Otherwise output the sign bit.</em></p><p>I swept the entire 20-bit accumulator range through that expression. It produces exactly two distinct values: −128 and +127.</p><p>So the 51-tap filter — the good one, −56 dB stopband, genuinely well designed — computes a beautiful weighted sum across 51 taps and then throws all of it away, emitting a hard-limited square wave that carries the sign and nothing else.</p><h3>The smoking gun</h3><p>The part that stopped me was not the bug. It was the testbench.</p><p>The generated firbandpass_tb.v is 7,000 lines. It has 3,429 stimulus samples, 3,429 expected output values, a checker that compares them on every clock, and an error counter. It looks like real verification.</p><p>I counted the distinct values in its data_out_expected array:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*jpYgaw29D7axc2ROgZ2RSQ.png" /></figure><p>That is the entire golden reference. Three values, two of which are the saturation rails.</p><p>MATLAB generated those vectors by simulating its own fixed-point model — using the same specification that produced the broken RTL. The reference and the implementation agreed perfectly, because they were both wrong in exactly the same way.</p><p>This is the lesson worth taking away. A generated testbench checks that the RTL matches the model. It cannot check that the model matches your intent. If you get the specification wrong, the golden vectors encode your mistake with perfect fidelity, the checker reports zero errors, and you ship.</p><p>A vendor-generated testbench is a <em>self-consistency</em> check. It is not a <em>correctness</em> check. Those are different things, and I did not understand the difference in 2020.</p><h3>Bug two: the accumulator that wrapped</h3><p>The 11-tap serial filter had a quieter problem.</p><p>Its accumulator was specified as sfix26_En24 — range ±2. Its coefficients are:</p><pre>-0.09375, -0.25, -0.25, 0, 0.34375, 0.5, 0.34375, 0, -0.25, -0.25, -0.09375</pre><p>The worst-case output of any FIR filter is the L1 norm of its coefficients — Σ|h| — because that is what you get when the input signal lines up in sign with every tap at once. Here:</p><p><strong>Σ|h| = 2.375</strong></p><p>An accumulator with a range of ±2 holding a value that can legitimately reach 2.375. And the generated overflow mode was not saturate — it was wrap:</p><pre>wire signed [26:0] add_temp;          // 27 bits, holds the true sum<br>assign add_temp   = add_signext + add_signext_1;<br>assign acc_sum_1  = add_temp[25:0];   // truncated to 26 bits -&gt; wraps</pre><p>Wrapping is the dangerous choice. Saturation clips a loud signal — ugly, but recognisable, and it preserves the sign. Wrapping takes +2.03 and returns −1.97. A single sample flips to full-scale negative in the middle of a positive peak. In audio that is a click; in a control loop it is a step change in the wrong direction.</p><p>I modelled the datapath bit-accurately and ran it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*g3N1IZS8keNaX4nZqc041Q.png" /></figure><p>Notice the first row. A pure sine at the centre frequency <em>never</em> overflows — peak gain is 1.972 against a limit of 2.0, so it clears by 1.4%. If you test with a sine, everything looks perfect. Add harmonics — a square wave, a chirp, real-world noise — and it wraps on nearly half of all samples.</p><p>Once I had a proper testbench, the simulator printed it straight out:</p><pre>FAIL sample 12: filter_out = 1744840192, expected -2550127104</pre><p>Expected −2.55 × 1⁰⁹. Got +1.74 × 1⁰⁹. The sign is inverted. That is the wrap, caught in the act.</p><h3>The fixes</h3><p>Both are small, and neither touches a coefficient or the architecture.</p><p>firbandpass.v — stop crushing the output into a format that cannot hold it. The accumulator is already the right answer, so just emit it:</p><pre>- output  signed [7:0] data_out;  //sfix8_En32<br>+ output  signed [19:0] data_out; //sfix20_En20<br><br>- assign output_typeconvert = (sum50[19] == 1&#39;b0 &amp; ... ) ? 8&#39;b01111111 : ... ;<br>+ assign output_typeconvert = sum50;</pre><p>Peak gain is 1.088 and the input range is ±0.25, so the output never exceeds 0.397 against an accumulator range of ±0.5. Nothing saturates. Distinct output values in simulation went from 2 to 65.</p><p>bandpass.v — give the accumulator the one extra bit it always needed:</p><pre>- reg signed [25:0] acc_out_1;      // sfix26_En24, range +/-2<br>+ reg signed [26:0] acc_out_1;      // sfix27_En24, range +/-4<br><br>- assign acc_sum_1 = add_temp[25:0];<br>+ assign acc_sum_1 = add_temp[26:0];</pre><p>Σ|h| = 2.375 fits inside ±4 with room to spare, so overflow is now impossible and the datapath is bit-exact. The output port did not change at all — sfix33_En30 was already ±4. The accumulator was the only thing that had been too narrow.</p><p>Two word lengths. That was the whole bug surface.</p><h3>The testbench that would have caught both</h3><p>I threw away the stored-vector approach and wrote benches that compare each design against an independent reference model — one written from the filter specification, not generated from it.</p><p>For an FIR filter there is one test that is close to definitive:</p><blockquote><em>Feed it an impulse. The output must be the coefficients.</em></blockquote><p>That is what an FIR <em>is</em>. If the impulse response doesn’t match the taps, something between the multiplier and the output pin is lying to you. It needs no golden file, because the expected values are the coefficients already sitting in the design.</p><p>Then the general case: a 64-bit integer model of the filter, compared sample by sample under full-scale square, random, and worst-case-sign stimulus:</p><pre>expected = 0;<br>for (k = 0; k &lt; TAPS; k = k + 1)<br>  expected = expected + $signed(hist[LATENCY + k]) * $signed(h[k]) * OUTPUT_SCALE;<br><br>if (filter_out !== expected[32:0]) errors = errors + 1;</pre><p>And one test aimed squarely at the failure I’d missed — a test that simply asserts the output actually varies:</p><pre>$display(&quot;  distinct output values observed: %0d&quot;, distinct);<br>if (distinct &lt;= 3) begin<br>  errors = errors + 1;<br>  $display(&quot;  FAIL: output takes only %0d distinct values -- &quot;<br>           &quot;it is a sign detector, not a filter&quot;, distinct);<br>end</pre><p>That check is three lines and it would have saved six years.</p><p>The important property: <strong>both benches fail on the original RTL and pass on the fixed version. </strong>A test written after the fact is worthless unless you confirm it fails against the bug. I ran them against the 2020 files to prove it.</p><pre>$ make sim<br>PASS  bandpass_filter: 585 checks, 0 mismatches<br>PASS  basicfir: 704 checks, 0 mismatches</pre><p>One command, a few seconds, no license server. The whole thing runs on <a href="https://bleyer.org/icarus/">Icarus Verilog</a>.</p><h3>What I’d tell 2020 me</h3><ol><li><strong>Compute Σ|h| and compare it to your accumulator range.</strong> One line of arithmetic. It is the single most common fixed-point bug in FIR design, and it is entirely preventable.</li><li><strong>Prefer saturate over wrap.</strong> If your accumulator does overflow, you want the loud signal clipped, not sign-inverted. Wrap turns a clipped peak into a full-amplitude glitch.</li><li><strong>“Specify Precision” means you own the arithmetic.</strong> Full precision is the safe default. If you override it, write down the range of every signal and check the conversions, because the tool will implement whatever you type without complaint.</li><li><strong>A generated testbench proves self-consistency, not correctness.</strong> Golden vectors derived from the same specification as the RTL cannot detect an error in that specification.</li><li><strong>Assert that your output varies.</strong> Any signal processing block whose output collapses onto two values is broken. It costs three lines to check and it catches an entire class of scaling bugs.</li><li><strong>Test with harmonics, not just sines.</strong> A pure tone cleared my broken accumulator by 1.4%. A square wave at the same frequency broke it on half the samples.</li></ol><p>None of this is exotic. It is the checking I skipped because the tool said zero errors and I believed it.</p><h3>The repository</h3><p>Everything above is in the repo, including the plot, the benches, and the before/after RTL:</p><p><a href="https://github.com/AbdullahAnsarii/BandPassFilter">github.com/AbdullahAnsarii/BandPassFilter</a></p><pre>git clone https://github.com/AbdullahAnsarii/BandPassFilter<br>cd BandPassFilter<br>make sim</pre><p>The step-by-step MATLAB tutorial is still there in Instructions.pdf, and if you want the original walkthrough of designing the filter, I wrote that up separately: <a href="https://medium.com/p/65559c53dd58">How to create a Finite Impulse Response (FIR) Bandpass Filter, using Verilog in MATLAB</a>.</p><p>If you have generated HDL sitting in a repository somewhere with a generated testbench passing next to it — go and check Σ|h| against your accumulator, and go and count the distinct values on your output. It takes ten minutes. Mine took six years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bc1fecfa2df" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/my-fir-bandpass-filter-passed-its-own-testbench-for-six-years-it-was-a-sign-detector-7bc1fecfa2df">My FIR Bandpass Filter Passed Its Own Testbench for Six Years. It Was a Sign Detector.</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add Instagram-Style Stories to Your React Native App in Minutes]]></title>
            <link>https://levelup.gitconnected.com/add-instagram-style-stories-to-your-react-native-app-in-minutes-aaee539bf940?source=rss-c20aa3e52214------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaee539bf940</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[rn-story]]></category>
            <dc:creator><![CDATA[Muhammad Abdullah Arif Ansari]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 21:48:08 GMT</pubDate>
            <atom:updated>2026-09-07T15:15:44.521Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Images, videos, progress bars, and tap gestures — with rn-story, a lightweight, TypeScript-first stories component for React Native and Expo, now built on expo-video.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmGxdXQMkyu0MG_swTkmFg.jpeg" /></figure><p>Stories are everywhere. Instagram, WhatsApp, Snapchat, LinkedIn, even food delivery apps — the full-screen, tap-to-advance format has become one of the most recognizable UI patterns in mobile.</p><p>And it <em>looks</em> simple. A full-screen image, some progress bars, tap left, tap right. How hard can it be?</p><p>Harder than it looks. Building stories from scratch means solving a surprising number of small problems at once:</p><ul><li>Progress bars that stay perfectly in sync with image durations and video lengths</li><li>Tap zones for next/previous that don’t conflict with long-press-to-pause</li><li>Resuming a paused story with the <em>remaining</em> time, not the full duration</li><li>Videos that report their own duration — eventually, asynchronously, sometimes never</li><li>Loading states that don’t trap the user when a network image stalls</li><li>Notches, the Android status bar and the home indicator getting in the way of your header</li></ul><p>I built <a href="https://github.com/AbdullahAnsarii/rn-story">rn-story</a> to solve all of that in a single component, and version 2.0 is a ground-up rewrite with a full test suite behind it. This post shows you how to ship a complete stories experience — avatar rail, full-screen viewer, video support — in a few minutes.</p><h3>What you get</h3><ul><li>📸 Image and video stories with an animated progress bar per story</li><li>🎬 Video through expo-video, one player per story — the next video buffers while the current story plays, so advancing is instant</li><li>🎯 A progress bar that tells the truth: it pauses while a video buffers, and the story ends exactly when the video does</li><li>👆 The gestures users expect: tap right for next, tap left for previous, long-press to pause, release to resume</li><li>🔗 An optional “See More” link per story (the swipe-up pattern, as a button)</li><li>🧩 A custom header slot — perfect for an avatar, username, and close button</li><li>📐 Safe-area aware: bars and header stay clear of notches, the Android status bar and the home indicator</li><li>🎨 Pass-through props for the image, the video view, the player and the modal — or render images with your own component (expo-image, blurhash…)</li><li>📊 onStoryStart for &quot;viewed&quot; tracking and analytics</li><li>🛡️ Written in TypeScript — every prop and the Story object are fully typed</li><li>🪶 Zero runtime dependencies, no native code of its own — works in Expo Go</li></ul><h3>Installation</h3><p>expo-video powers video stories and is a peer dependency, so install it alongside the package with the version that matches your Expo SDK (52 or newer). react-native-safe-area-context is optional but recommended — most apps already have it:</p><pre>npx expo install rn-story expo-video react-native-safe-area-context</pre><p>Not using Expo? Install the packages with npm, make sure <a href="https://docs.expo.dev/bare/installing-expo-modules/">Expo modules are configured</a> in your bare React Native project, and rebuild (expo-video has native code):</p><pre>npm install rn-story expo-video react-native-safe-area-context<br>npx pod-install</pre><h3>Your first story in ten lines</h3><pre>import Stories from &#39;rn-story&#39;;<br>import type { Story } from &#39;rn-story&#39;;<br><br>const stories: Story[] = [<br>  { media: &#39;https://example.com/photo.jpg&#39;, mediaType: &#39;image&#39; },<br>  { media: &#39;https://example.com/clip.mp4&#39;, mediaType: &#39;video&#39; },<br>];<br><br>export default function MyStories() {<br>  return &lt;Stories stories={stories} /&gt;;<br>}</pre><p>That’s a working viewer: full-screen media, animated progress bars, tap navigation, long-press to pause. Images show for 3 seconds by default (configurable per story with duration), and videos play for exactly as long as the video lasts.</p><h3>The gestures, for free</h3><p>Everything users already know from Instagram works out of the box:</p><ul><li>Tap the right half → next story</li><li>Tap the left half → previous story</li><li>Long-press anywhere → pause the story and its progress bar</li><li>Release → resume from where it left off — with the remaining time, not a restarted bar</li><li>Android back button → wired to an onClose callback you provide</li></ul><h3>A real stories rail</h3><p>A lone viewer isn’t how stories ship. The real pattern is a horizontal rail of avatars; tapping one opens that profile’s stories; finishing them moves to the next profile; going back past the first story returns to the previous profile.</p><p>That flow is exactly what the navigation callbacks are for. onNext/onPrevious fire on ordinary navigation, and two dedicated callbacks fire at the edges: onAllStoriesEnd when there&#39;s nothing left to play forward, and onPreviousFirstStory when the user backs out of the first story.</p><pre>import { useCallback, useState } from &#39;react&#39;;<br>import { Image, Pressable, ScrollView, Text } from &#39;react-native&#39;;<br>import { SafeAreaProvider, SafeAreaView } from &#39;react-native-safe-area-context&#39;;<br>import Stories from &#39;rn-story&#39;;<br>import type { Story } from &#39;rn-story&#39;;<br><br>type Profile = {<br>  id: number;<br>  profileName: string;<br>  profileImage: string;<br>  stories: Story[];<br>};<br><br>const PROFILES: Profile[] = [<br>  {<br>    id: 1,<br>    profileName: &#39;Abdullah&#39;,<br>    profileImage: &#39;https://picsum.photos/id/64/200/200&#39;,<br>    stories: [<br>      {<br>        media: &#39;https://picsum.photos/id/1015/1080/1920&#39;,<br>        mediaType: &#39;image&#39;,<br>        seeMoreUrl: &#39;https://abdullahansari.me&#39;,<br>      },<br>      {<br>        media: &#39;https://picsum.photos/id/1016/1080/1920&#39;,<br>        mediaType: &#39;image&#39;,<br>        duration: 12000, // this one stays up for 12 seconds<br>      },<br>    ],<br>  },<br>  {<br>    id: 2,<br>    profileName: &#39;Pug life&#39;,<br>    profileImage: &#39;https://picsum.photos/id/1025/200/200&#39;,<br>    stories: [<br>      {<br>        media:<br>          &#39;https://raw.githubusercontent.com/AbdullahAnsarii/rn-story/master/docs/demo.mp4&#39;,<br>        mediaType: &#39;video&#39;,<br>      },<br>      {<br>        media: &#39;https://picsum.photos/id/1025/1080/1920&#39;,<br>        mediaType: &#39;image&#39;,<br>      },<br>    ],<br>  },<br>];<br><br>export default function App() {<br>  // null means the story viewer is closed<br>  const [current, setCurrent] = useState&lt;number | null&gt;(null);<br><br>  const close = useCallback(() =&gt; setCurrent(null), []);<br><br>  // Finished a profile? Move on to the next one, or close after the last.<br>  const nextProfile = useCallback(() =&gt; {<br>    setCurrent((i) =&gt;<br>      i === null ? null : i &lt; PROFILES.length - 1 ? i + 1 : null<br>    );<br>  }, []);<br><br>  // Backed out of the first story? Go back a profile, or close on the first.<br>  const previousProfile = useCallback(() =&gt; {<br>    setCurrent((i) =&gt; (i === null || i === 0 ? null : i - 1));<br>  }, []);<br><br>  return (<br>    &lt;SafeAreaProvider&gt;<br>      &lt;SafeAreaView edges={[&#39;top&#39;]}&gt;<br>        &lt;ScrollView horizontal&gt;<br>          {PROFILES.map((profile, index) =&gt; (<br>            &lt;Pressable<br>              key={profile.id}<br>              onPress={() =&gt; setCurrent(index)}<br>              style={{ alignItems: &#39;center&#39;, margin: 8 }}<br>            &gt;<br>              &lt;Image<br>                source={{ uri: profile.profileImage }}<br>                style={{<br>                  width: 64,<br>                  height: 64,<br>                  borderRadius: 32,<br>                  borderWidth: 2,<br>                  borderColor: &#39;#25D366&#39;,<br>                }}<br>              /&gt;<br>              &lt;Text numberOfLines={1}&gt;{profile.profileName}&lt;/Text&gt;<br>            &lt;/Pressable&gt;<br>          ))}<br>        &lt;/ScrollView&gt;<br><br>        {current !== null &amp;&amp; (<br>          &lt;Stories<br>            stories={PROFILES[current].stories}<br>            onAllStoriesEnd={nextProfile}<br>            onPreviousFirstStory={previousProfile}<br>            onClose={close}<br>            onStoryStart={(index, story) =&gt; console.log(&#39;viewing&#39;, index, story.media)}<br>          /&gt;<br>        )}<br>      &lt;/SafeAreaView&gt;<br>    &lt;/SafeAreaProvider&gt;<br>  );<br>}</pre><p>Two details worth noticing:</p><p><strong>Swapping stories just works.</strong> When onAllStoriesEnd moves current to the next profile, the component receives a new stories array and restarts cleanly from the first story. You don&#39;t need to unmount and remount anything, and you don&#39;t need to manage keys.</p><p><strong>The viewer closes by unmounting.</strong> Rendering &lt;Stories /&gt; conditionally is the whole show/hide mechanism — no visible prop to keep in sync.</p><h3>Make it yours</h3><p>The header is a per-story ReactNode, so the avatar row you see in every stories UI is just your own component — typically an avatar, a username, and a close button, often over a subtle gradient:</p><pre>const storiesWithHeader = profile.stories.map((story) =&gt; ({<br>  ...story,<br>  header: (<br>    &lt;MyStoryHeader profile={profile} onClose={close} /&gt;<br>  ),<br>}));</pre><p>In 3.0 every layer underneath is reachable too:</p><pre>&lt;Stories<br>  stories={stories}<br>  isMuted={muted}                          // mute video stories<br>  videoProps={{ contentFit: &#39;contain&#39; }}   // anything expo-video&#39;s VideoView takes<br>  configurePlayer={(player) =&gt; {           // anything expo-video&#39;s player exposes<br>    player.audioMixingMode = &#39;duckOthers&#39;;<br>  }}<br>  renderImage={(story, props) =&gt; (         // or swap the image component entirely<br>    &lt;ExpoImage {...props} contentFit=&quot;cover&quot; placeholder={{ blurhash: story.blurhash }} /&gt;<br>  )}<br>  animationBarColor=&quot;#fff&quot;                 // progress bar fill<br>  animationBarBackgroundColor=&quot;rgba(255,255,255,0.35)&quot;<br>  seeMoreText=&quot;Read more&quot;                  // label for the See More button<br>  loadingComponent={&lt;MySpinner /&gt;}         // shown while media loads<br>  statusBarStyle=&quot;light-content&quot;           // status bar icons while the viewer is open<br>/&gt;</pre><p>And if a story has a seeMoreUrl, a pill-shaped button appears at the bottom and opens the link — the classic &quot;swipe up&quot; pattern without the swipe. Prefer an in-app browser or a bottom sheet? onSeeMorePress hands you the story instead, and renderSeeMore replaces the button altogether.</p><h3>Videos that behave</h3><p>Video is where hand-rolled stories usually fall apart, so this is where 3.0 spent most of its effort:</p><ul><li><strong>Preloading. </strong>While the current story plays, the next video already has its own expo-video player buffering in the background. When the viewer advances, that player is handed to the screen — no spinner, no black frame.</li><li><strong>Honest progress.</strong> The bar holds while a video buffers and the story ends the moment the video does, so the bar and the picture never drift apart. A story with an explicit duration still follows that duration.</li><li><strong>Never wedges.</strong> A video that fails to load is skipped, a source that never reports its length falls back to a default duration, and readiness is also inferred from playback progress — so no missed event can leave the viewer stuck on a loader.</li><li><strong>Protected media.</strong> headers on a story are sent with the request, for both images and videos.</li></ul><h3>Upgrading from 2.x</h3><p>Most apps only need to swap the dependency: expo-av is gone, expo-video (Expo SDK 52+) is in. Every 2.x prop and the Story shape keep working. The README has a short <a href="https://github.com/AbdullahAnsarii/rn-story#upgrading-to-30">Upgrading to 3.0</a> table with the handful of behavior changes (the status bar goes light while the viewer is open, a video story ends when the video does):</p><h3>Wrapping up</h3><p>Stories are one of those features that looks like an afternoon and turns into a week once progress bars, gestures, and video timing enter the picture. rn-story packs that week into an npm install — and 3.0 ships with 73 tests behind it, verified in Expo Go on iOS and Android.</p><ul><li>📦 npm: <a href="https://www.npmjs.com/package/rn-story">npmjs.com/package/rn-story</a></li><li>⭐ GitHub: <a href="https://github.com/AbdullahAnsarii/rn-story">github.com/AbdullahAnsarii/rn-story</a></li><li>▶️ Live demo: <a href="https://snack.expo.dev/@abdullahansari/rn-story-demo">snack.expo.dev/@abdullahansari/rn-story-demo</a></li><li>📚 Full example app: <a href="https://github.com/AbdullahAnsarii/rn-story/tree/master/example">rn-story/example</a></li></ul><p>If it saves you that week, a star on GitHub genuinely helps other people find it — and if you hit anything odd, <a href="https://github.com/AbdullahAnsarii/rn-story/issues">open an issue</a>. It’s MIT-licensed, and contributions are welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaee539bf940" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/add-instagram-style-stories-to-your-react-native-app-in-minutes-aaee539bf940">Add Instagram-Style Stories to Your React Native App in Minutes</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a Finite Impulse Response (FIR) Bandpass Filter, using Verilog in MATLAB]]></title>
            <link>https://levelup.gitconnected.com/how-to-create-a-finite-impulse-response-fir-bandpass-filter-using-verilog-in-matlab-65559c53dd58?source=rss-c20aa3e52214------2</link>
            <guid isPermaLink="false">https://medium.com/p/65559c53dd58</guid>
            <category><![CDATA[custom-band-pass-filter]]></category>
            <category><![CDATA[vlsi]]></category>
            <category><![CDATA[filters]]></category>
            <category><![CDATA[band-pass-filter-design]]></category>
            <category><![CDATA[fir-filter]]></category>
            <dc:creator><![CDATA[Muhammad Abdullah Arif Ansari]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 11:43:34 GMT</pubDate>
            <atom:updated>2026-09-09T14:22:50.946Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Update, September 2026:</em></strong><em> the design process below is still right, but two of the fixed-point word lengths I chose in Step 3 were wrong, and the generated testbench couldn’t catch it. The repo is now fixed with real self-checking test benches — the story of what went wrong is </em><a href="https://abdullahansarii.medium.com/my-fir-bandpass-filter-passed-its-own-testbench-for-six-years-it-was-a-sign-detector-7bc1fecfa2df"><em>here</em></a><em>.</em></p><h3><strong>DIGITAL FILTERS:</strong></h3><p>Digital filters are commonly used in discrete signal processing to eliminate or preserve certain portions of the signal. Digital filters are divided into two categories which are Finite Impulse Response (FIR) and Infinite Impulse Response (IIR). The most common types of digital filters are following </p><ol><li><strong>Low pass filter</strong></li><li><strong>High pass filter</strong></li><li><strong>Bandpass filter</strong></li></ol><h3><strong>BANDPASS FILTER:</strong></h3><p>A bandpass filter is a device that allows frequencies within a specified range and ignores frequencies beyond that range.</p><h4><strong>CENTER FREQUENCY</strong></h4><p>The frequency at the center of the high cut-off frequency and low cut-off frequency is called the center frequency.</p><h4>PASS BANDWIDTH</h4><p>The difference between the high cut-off frequency and the low cut-off frequency is called pass bandwidth.</p><h3>ANALOG BAND PASS FILTER:</h3><p>Before we jump in to design a digital FIR band pass filter we should understand how an analog band pass filter works.</p><h4>DIAGRAM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*-BkjvBp2RMF0TKtRAt-Uaw.png" /><figcaption>ANALOG BAND PASS FILTER</figcaption></figure><h4>EXPLANATION</h4><p>The analog band pass filter circuit is created by cascading a high pass filter and a low pass filter by choosing appropriate values of resistors and capacitors shown in the diagram. The high cut-off frequency is calculated by the formula fc1 = 1 / 2π*R1*C1. While the low cut-off frequency is calculated by the formula fc2 = 1 / 2π*R2*C2. By using the values of fc1 and fc2 we can calculate the pass bandwidth and center frequency of an analog band pass filter.</p><h4>OUTPUT</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*E-9XSimXV9jnDI_2a2Xmlw.png" /><figcaption>OUTPUT</figcaption></figure><h3>CALCULATIONS:</h3><p>Here we will calculate fpass1, fpass2 and sampling frequency according to the given OBE requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*tlIyIOYqk0JONDyMUhs_LA.png" /></figure><p>Here we found out that Fpass1 = 29500 Hz and Fpass2 = 30500 KHz, and if we use these values we gets a pass bandwidth of 1 KHz. </p><ol><li>Fpass2 — Fpass1 = Bandwidth</li><li>30500–29500 = Bandwidth</li><li>1000 Hz = Bandwidth</li></ol><p>To calculate sampling frequency we will use the Nyquist formula:</p><blockquote>“it is necessary to use a sampling rate “fs” at least twice the highest waveform frequency.” </blockquote><ol><li>fpass = ½(fs)</li><li>fs = 62000 Hz</li></ol><p>We can apply a sampling frequency greater than or equal to 62000 Hz in our band pass filter.</p><h3>FILTER DESIGN:</h3><p>First, we will open Matlab and type the command “filterDesigner” in the command window. The filter Designer window appears as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*1j_haall3128fL-ERZPhwA.png" /><figcaption><strong>Step 1</strong></figcaption></figure><p>Now we will select options i.e. Response Type, Design Method, and Frequency Specifications according to the calculations we made earlier. By putting all the values we get a band pass filter of center frequency 30000 Hz as shown below.</p><blockquote>This is the step to be careful with: if you pick “Specify Precision” instead of full precision, check that the output range can hold the accumulator range, and that the accumulator can hold Σ|h|. Mine couldn’t — <a href="https://abdullahansarii.medium.com/my-fir-bandpass-filter-passed-its-own-testbench-for-six-years-it-was-a-sign-detector-7bc1fecfa2df">here’s what that looked like</a>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*8q50ryIcs64Yxv7KrEAPWA.png" /><figcaption><strong>Step 2</strong></figcaption></figure><p>The impulse response of the bandpass filter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*RswzoCKAnk9TqVK1ppwxFg.png" /><figcaption><strong>Step 3</strong></figcaption></figure><p>Now we will quantize the filter before generating its Verilog code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*N2GgDUIY0AddgtTjmvEuyQ.png" /><figcaption><strong>Step 4</strong></figcaption></figure><p>Now select Target =&gt; Generate HDL following dialog box appears we will select appropriate options and then click “Generate” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*oWfmEffdiiGX84ewj2hMOw.png" /><figcaption><strong>Step 5</strong></figcaption></figure><p>Verilog code generation of our band pass filter starts as shown in the command window below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*0MlABmXNs5NCJg5rakPAcg.png" /><figcaption><strong>Step 6</strong></figcaption></figure><p>The Verilog code after being generated gets stored as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*sB9ABcVAguYAaUBY_u33zw.png" /><figcaption><strong>Step 6</strong></figcaption></figure><h3>RTL SCHEMATIC</h3><p>The following RTL schematic is obtained after synthesizing the generated Verilog code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*kHy8uFq0QaWkS5M0u9kL9g.png" /></figure><h3><strong>SIMULATION</strong></h3><p>After running the simulation of the testbench file, we get the following timing diagram. In 2022 I took this as confirmation the filter was working. It wasn’t — the generated testbench was checking the RTL against golden vectors produced from the same fixed-point specification, so it could never detect that the specification itself was wrong. Six years later I found the output was saturating to ±full scale on every sample: <a href="https://abdullahansarii.medium.com/my-fir-bandpass-filter-passed-its-own-testbench-for-six-years-it-was-a-sign-detector-7bc1fecfa2df">My FIR Bandpass Filter Passed Its Own Testbench for Six Years. It Was a Sign Detector.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*RbN3RYernLL2A9pck1JBgw.png" /></figure><h3>VERILOG CODE</h3><p>The complete code can be found at:</p><p><a href="https://github.com/AbdullahAnsarii/BandPassFilter">https://github.com/AbdullahAnsarii/BandPassFilter</a></p><p>Also check out my portfolio website for more such projects at:<br><a href="https://abdullahansari.me/">https://abdullahansari.me/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65559c53dd58" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-create-a-finite-impulse-response-fir-bandpass-filter-using-verilog-in-matlab-65559c53dd58">How to create a Finite Impulse Response (FIR) Bandpass Filter, using Verilog in MATLAB</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>