<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Barjuan Davis P.</title>
    <description>The latest articles on DEV Community by Barjuan Davis P. (@barjuandavis).</description>
    <link>https://dev.to/barjuandavis</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F389944%2F381b3448-099d-4243-a531-506f7c03ed51.jpeg</url>
      <title>DEV Community: Barjuan Davis P.</title>
      <link>https://dev.to/barjuandavis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/barjuandavis"/>
    <language>en</language>
    <item>
      <title>Synchronized Metronome on Android! 🎹 🎼 🎶 (it was bad.)</title>
      <dc:creator>Barjuan Davis P.</dc:creator>
      <pubDate>Thu, 21 May 2020 09:41:20 +0000</pubDate>
      <link>https://dev.to/barjuandavis/synchronized-metronome-on-android-it-was-bad-491o</link>
      <guid>https://dev.to/barjuandavis/synchronized-metronome-on-android-it-was-bad-491o</guid>
      <description>&lt;p&gt;So here is my final project during my undergrad final year, and i got to be honest... &lt;strong&gt;it was bad&lt;/strong&gt;. And i will explain why. &lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Background&lt;/li&gt;
&lt;li&gt;Idea and Implementation&lt;/li&gt;
&lt;li&gt;Results and Regrets&lt;/li&gt;
&lt;li&gt;Future Works (!!!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Background &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Besides only as a developer, i am also a musician. And i need to find a way "How to make sure everyone in a small band stay in tempo without any complicated in-ear-monitoring setup?". Hence why this idea came to my mind.&lt;/p&gt;

&lt;p&gt;I chose to use Nearby Connections API only because i have used it in my other project. And it also claimed that it is &lt;a href="https://developers.google.com/nearby/connections/overview"&gt;"high-bandwidth, low-latency, and fully encrypted to enable fast, secure data transfers."&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Idea &amp;amp; Implementation &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The idea is to create a simple metronome app that can connect to other devices that uses the same app using client-server approach. The server can play/pause/set tempo/configure the metronome, while other devices/clients that is joined to the server can only receives the server's command. &lt;/p&gt;

&lt;p&gt;I decided to use &lt;a href="https://www.raywenderlich.com/34-design-patterns-by-tutorials-mvvm"&gt;MVVM&lt;/a&gt; approach to my app. There are only two &lt;code&gt;Fragment&lt;/code&gt;s that serves as UI: the metronome page and the client-finding page. And there are only two &lt;code&gt;Service&lt;/code&gt;s that will run in the background: the metronome, and the connection manager. Every changes is applied to the UI using &lt;a href="https://developer.android.com/topic/libraries/data-binding/binding-adapters"&gt;Binding Adapters&lt;/a&gt; and every function calls (and returns) from the UI to the &lt;code&gt;Service&lt;/code&gt;s has to go from the only global &lt;code&gt;ViewModel&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;As mentioned, there are two services; &lt;code&gt;MetronomeService&lt;/code&gt; is responsible to do all the metronome stuff, and the &lt;code&gt;ConnectionManagerService&lt;/code&gt; - as the name implies - manages all the connection stuff. &lt;code&gt;ConnectionManagerService&lt;/code&gt; is also the only instance that has all the Nearby Connection API implementations. &lt;/p&gt;

&lt;h3&gt;
  
  
  Results and Regrets &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The whole idea turns out to be a huge mistake. I cannot even sync the metronome ticks while being played together! It somehow started all synced but gradually turned not synced when played with the exact same tempo. I also implemented naive latency compensation but turns out Nearby's latency was too spread out. Nearby mentioned that they used combination of Bluetooth and Wi-Fi and it turns out to be true. But when the switch from Bluetooth to Wi-Fi happens, the latency just spikes uncontrollably between devices in the same server.&lt;/p&gt;

&lt;p&gt;The mistakes turns out to be on both Services. On &lt;code&gt;MetronomeService&lt;/code&gt;, &lt;em&gt;there is a possibility&lt;/em&gt; that the low latency audio not consistently played throughout devices. And on &lt;code&gt;ConnectionManagerService&lt;/code&gt;, the lack of granular control in Nearby makes things just... uncontrollable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Future Works (!!!) &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I really want this project to be successful and help musicians to do gigs better. It wont be updated in near future but i have made a simple roadmap for this app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Complete UI/UX redesign&lt;/strong&gt;. The current ones looks like a bunch of placeholders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replace current metronome audio implementation with something better&lt;/strong&gt;. &lt;a href="https://github.com/google/oboe"&gt;Oboe&lt;/a&gt; came out to my mind when i am thinking about this but i didn't have much time to implement that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replace Nearby with Native Wi-Fi API&lt;/strong&gt;. I do not know if it's possible but i was thinking to make the device that acts as a server also acts as a Wi-Fi Router that only accepts connections from clients that uses the app. I know there will be security obstacles to tackle out of this idea but if you have insights about what to use/what to do, please let me know!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More metronome features!&lt;/strong&gt; Right now, it is only a metronome that plays a beep in constant beats per minute. I want to add more features such as subdivisions, more sounds, accentuations, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I really want to thank all stakeholders who helped me in this project. It was really a learning process throughout the project. By the way, here's the repo!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/barjuandavis"&gt;
        barjuandavis
      &lt;/a&gt; / &lt;a href="https://github.com/barjuandavis/wesync_kotlin"&gt;
        wesync_kotlin
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Wesync: Synchronized Metronome application made using Native Android SDK (Kotlin) and Nearby Connections API.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
wesync_kotlin&lt;/h1&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/barjuandavis/wesync_kotlin"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;And happy graduation to all of us!&lt;/p&gt;

</description>
      <category>devgrad2020</category>
      <category>octograd2020</category>
    </item>
  </channel>
</rss>
