Skip to content

Latest commit

 

History

History
380 lines (291 loc) · 22.1 KB

README_Microbit.md

File metadata and controls

380 lines (291 loc) · 22.1 KB

Mewt Microbit

Mewt allows you to create a hardware button to Mute and Unmute all system microphones with a single press for Windows, Mac and Linux.

Mewt works at the operating system (OS) level, so this will mute/unmute all conferencing software (Zoom, Google Meet, Teams, WebEx, Blue Jeans, GoToMeeting, Skype, Slack, Facebook, Discord, etc.)

Mewt will continuously display the current Mute/Unmute state so you can tell at a glance if your microphone is enabled without having to search for the onscreen icon.

When Mewt detects that your microphone is transmitting audio, it will display a sound visualizer to help you avoid embarassing hot-mic incidents via RGB LED light indicator. Hot mic currently works in Windows, but not yet in Mac or Linux

mewtdemo

Muted Unmuted Hot Mic
mewt unmewt Hot Mic

How Mewt works

Click to expand

Mewt is made up of 2 parts:

  1. Physical components
    1. Physical buttons to control mute state, with a built-in LED to display mute state / hot-mic
    2. A Microbit microcontroller to interface with the button and the LED. This is also what will communicate with your computer
  2. Code running on your computer to
    1. Recognize button presses to toggle microphone mute/unmute
    2. Read microphone mute/unmute state and send information to the Microbit to display status
    3. Read microphone volume levels and send information to the Microbit to display hot-mic mewtdesign

How to build Mewt

Click to expand

Get a Microbit (both V1 and V2 should work)

Note: these are not referral links, I do not benefit from you clicking on these links. I am not making an endorsement for any merchant. These are purely to help people get started

  • $15 USDmicrobit

Connect your computer to your Mewt Microbit

Click to expand
  • Windows

    Click to expand
    1. Download mewt_microbit.exe
      your browser may give you a warning when you try to download. Select Keep to continue downloading. keepanyway
    2. IMPORTANT please UNPLUG Mewt from your computer's USB before continuing.
    3. Find where you downloaded mewt_microbit.exe and run the file.
    4. Windows Defender / User Access Control may ask several times if you want to continue, follow screenshots to continue. windowsdefenderrunanywayunknownpublisher
    5. You will then see Mewt install itself installingmewt
    6. You will see a prompt to plug Mewt into a USB port pluginmewt
    7. When you plug in your Mewt, the prompt will disappear. Your Mewt should show an X
    Status Represents
    X Muted mewted
    O Unmuted, but not transmitting unmewted
    Hot mic Volume indicator Hot Mic
    • To test out Mewt, go to online-voice-recorder.com, and click on the red button to record. You should see it react to any sounds your microphone picks up.
      onlinevoicerecorder
      mewtdemo

    Curious as to what the installation program did? Did the installation not work? Click here to expand

    1. mewt_microbit.exe is a self-extracting version of mewt_microbit.zip.
    2. Download mewt_microbit.zip to your computer
    3. Navigate to where you saved mewt_microbit.zip, right click on it and select Extract All extractall
    4. In the next window, type in c:\mewt then Extract extracttocmewt
    5. IMPORTANT please UNPLUG Mewt from your computer's USB before continuing.
    6. In File Explorer navigate to c:\mewt, right click on setup_mewt.bat (its icon has gears in it), then select Open setup_mewt.bat
    7. You will see a prompt to plug Mewt into a USB port pluginmewt
    8. When you plug in your Mewt, the prompt will disappear. Your Mewt should show an X mewted
  • Mac

    Click to expand

    Setup your Microbit

    1. Plug in your Microbit into a USB port
    2. Go to this MakeCode page
    3. Click Edit in the upper right hand corner
    4. Click on the 3 dots next to Download in the lower left hand corner, then "Pair Device.
      pairdevice
    5. In the new popup window, click Pair Device again pairdeviceagain
    6. In the next popup window, select your Microbit device, then click Connect bbcmicrobitcmsis-dap
    7. If all went well, then the icon next to Download should now be a USB logo you may need to refresh the webpage for the logo to appear usbdownload
    8. Click Download to push the code to your Microbit

    Setup your Mac

    1. Download mewt.zip
      your browser may give you a warning when you try to download. Select Keep to continue downloading. keepanyway
    2. IMPORTANT please UNPLUG Mewt from your computer's USB before continuing.
    3. Navigate to where you saved mewt.zip from Finder->Downloads, right click on it and select Open With->Archive Utility extractall
    4. Open Terminal from Finder->Applications->Utilities->Terminal
    5. In the Terminal console, navigate to where you unzipped mewt.zip typically this is cd $HOME/Downloads/mewt
    6. Type in python mac_install_mewt.py, wait for the prompt to plug in your Mewt macinstall
    7. When you plug in your Mewt, the prompt will disappear. Your Mewt may flash a white light briefly. After a short delay, Mewt will light up with a steady Blue. Based on your system/Arduino setup, it may take 15-20 seconds for the steady light to come on. mewtready
  • Linux

    Click to expand

    Setup your Microbit

    1. Plug in your Microbit into a USB port
    2. Go to this MakeCode page
    3. Click Edit in the upper right hand corner
    4. Click on the 3 dots next to Download in the lower left hand corner, then "Pair Device.
      pairdevice
    5. In the new popup window, click Pair Device again pairdeviceagain
    6. In the next popup window, select your Microbit device, then click Connect bbcmicrobitcmsis-dap
    7. If all went well, then the icon next to Download should now be a USB logo you may need to refresh the webpage for the logo to appear usbdownload
    8. Click Download to push the code to your Microbit

    Setup your Linux

    1. Download mewt.zip
    2. IMPORTANT please UNPLUG Mewt from your computer's USB before continuing.
    3. Navigate to where you extracted mewt.zip from Terminal
    4. Type in python3 linux_install_mewt.py, wait for the prompt to plug in your Mewt
    5. When you plug in your Mewt, the prompt will disappear. Your Mewt may flash a white light briefly. After a short delay, Mewt will light up with a steady Blue. Based on your system/Arduino setup, it may take 15-20 seconds for the steady light to come on.
    6. Run pacmd list-sources to list all audio devices in your system.
    7. With online-voice-recorder.com running, iterate through your sources with the below command until you identify the one that will correctly mute your microphone pacmd set-source-mute X 1 where X = your source number. Start with 0 and work upwards
    8. Once you have identified your microphone, grep pacmd linux_mewt.py to find the 2 instances where it's called and replace the microphone index.

Running Mewt

Click to expand
  • Windows

    Click to expand
    1. In File Explorer navigate to C:\mewt
    2. To run Mewt in Headless/No-User-Interface mode, run start_mewt.bat startmewt
    • To exit from Headless/No-User-Interface mode, simply unplug your Mewt from the USB port
    1. To run Mewt in Verbose mode, run start_mewt_verbose.bat. This will open a console that will provide more information. startmewtverbose mewtverbose
    • To exit from Verbose mode, you can hit Ctrl+C, or close the PowerShell window or simply unplug your Mewt from the USB port
    • The very first time you use Mewt, you will need to press the button twice in order to activate it (sorry, it's a bug, still a work-in-progress). After it has been activated, every single button press will turn the primary microphone in your system from Unmuted to Muted, and vice versa.
  • Mac

    Click to expand
    1. Open Terminal from Finder->Applications->Utilities->Terminal
    2. In the Terminal console, navigate to where you unzipped mewt.zip typically this is cd $HOME/Downloads/mewt
    3. Type in python mewt.py mewtready
    • To exit from Verbose mode, you can hit Ctrl+C, or close the PowerShell window or simply unplug your Mewt from the USB port
    • The very first time you use Mewt, you will need to press the button twice in order to activate it (sorry, it's a bug, still a work-in-progress). After it has been activated, every single button press will turn the primary microphone in your system from Unmuted to Muted, and vice versa.
    • After you exit Mewt from the terminal, the light on the button will stay on until you restart Mewt or you unplug Mewt from the USB port
  • Linux

    Click to expand
    1. Open Terminal
    2. In the Terminal console, navigate to where you unzipped mewt.zip
    3. Type in python3 linux_mewt.py
    • The very first time you use Mewt, you will need to press the button twice in order to activate it (sorry, it's a bug, still a work-in-progress). After it has been activated, every single button press will turn the primary microphone in your system from Unmuted to Muted, and vice versa.
    • After you exit Mewt from the terminal, the light on the button will stay on until you restart Mewt or you unplug Mewt from the USB port

Make your enclosure

Click to expand

How does the Mewt code work

Click to expand
  • Microbit

    Click to expand Mewt's Microbit code wires the below inputs, outputs and placeholders together:

    Input from user

    • Button: User issues command to Mewt to mute/unmute microphone by pressing the A/B buttons

    Output to computer

    • Serial: Microbit opens up a communications channel to pass along the user input via commands to the computer. 1=mute, 0=unmute

    Input from computer

    • Serial: After the computer issues the command to mute/unmute the system microphone, it passes a value to Microbit to represent the current state of the microphone. 0=muted, 1=umuted. It is also possible to receive values >1 if the computer supports streaming microphone volume data (for hot-mic support).

    Output to user

    • LED: Microbit takes the input from computer and maps them to be displayed to the user via the combination of LED lights.
    Status Represents
    X Muted mewted
    O Unmuted, but not transmitting unmewted
    Hot mic Volume indicator, every dot represents increments of 5 Hot Mic

    Pseudocode

    • Sets Serial communications speed to 9600 baud
    • Inititalizes the mutecommand to 1 (for mute) and sends it via to the computer via Serial
    • Initializes screen to display an X
    • If button A is pressed, sets mewtcommand to 1 (for mute) and then resets the Microbit (there is currently no way to turn off the microphone LED programmatically, resetting is the only way)
    • If button B is pressed, sets mewtcommand to 0 (for unmute), sends it via to the computer via Serial, clears the screen, draws an O, and runs a DetectSound function to turn on the Microphone LED.
    • If A+B is pressed or if the Logo is touched, it will toggle the mewtcommand (will mute if currently unmuted, and vice versa)
    • If data is received from the computer via Serial, will draw the corresponding information on the LED
  • Windows

    Click to expand

    Mewt Windows leverages the AudioDeviceCmdlets PowerShell library for its communications with system microphones. See Acknowledgments

    Setup Pseudocode

    • Reads command line arguments *Passing Zoom or Meet as an argument will make Mewt attempt to send the shortcut for application-level muting respectively
    • Reads the COM port to look for Mewt on from mewt_com_port.txt. should have been detected and written as part of the setup
    • Imports AudioDeviceCmdlets library
    • If it's the first time Mewt/AudioDeviceCmdlets has run on this computer, it will install/copy the files to the correct directories for future use
    • Opens a separate process to output the volume stream of the current microphone to a file out.txt
    • Creates a Serial bus communicatioons using the COM port from above
    • Clears the console and outputs Mewt Ready for verbose mode
    • Declares some temporary variables to keep state for last button state and unmewtable device I encountered USB microphone that unmuted itself right after a mute command was sent that needed specialized treatment
    • Takes a snapshot of all system audio devices, filtered down to just the microphones/recording devices
    • Starts a timer to gauge how long each press is taking to effect for verbose mode

    Loop Pseudocode

    • Take the last value from audio stream and write it to mewt_stream.txt
    • Queries current mute state from computer and inverts it *AudioDeviceCmdlets returns 1 for mute, but Mewt sends 0 for mute in order to more logically support hot-mic
    • If current state is unmuted, but microphone is capturing no volume, AudioDeviceCmdlets returns 0. Replace this 0 to 1 before sending to Mewt
    • Otherwise, send last volume value to Mewt
    • Check against previous mute state to prevent unnecessary commands sending mute when microphone is currently muted
    • Read button state from Arduino
    • Timestamps mute state change start
    • If we received Zoom or Meet from command line argument, then switch windows focus to Zoom or Google Chrome respectively and send appropriate shortcut key the Chrome tab that Meet is on has to be the in-focus tab for this to work
    • Iteratives through each available system microphone and mutes them individually, making sure to save the primary microphone, and checking if there's been a change of devices removed a device or added a device
    • For every microphone muted/unmuted, timestamps how long it took from start to finish
    • Checks for unmewtable device if user wants to mute, and we muted every microphone, but a microphone subsequently reports that it's unmuted
    • Waits for a fraction over half a second and mutes that unmewtable device again beats me why this works, it just does
    • Once we have discovered an unmewtable device, we will save it so that we don't waste time checking it every time. Mewt will go directly to doing a 2nd mute attempt on these devices
    • Exits if port to Arduino no longer active if Mewt is physically unplugged
  • Mac

    Click to expand

    Mewt Mac leverages AppleScript in order to set the recording volume of the primary microphone to 0 for mute, and 100 for unmute. *There is a more robust way to actually mute microphones (as opposed to setting volume to 0), and to iterate through each microphone. To do so, we can leverage the Audio MIDI Setup application. However, this currently takes 3-5 seconds per toggle and is not efficient enough to use without further optimization.

    Setup Pseudocode

    • Reads the COM port to look for Mewt on from port_arduino. should have been detected and written as part of the setup
    • Creates a Serial bus communicatioons using the COM port from above
    • Declares some temporary variables to keep state for last button state
    • Clears the console

    Loop Pseudocode

    • Read button state from Arduino
    • test_data.csv refers to hot-mic feature that is currently being tested and not yet integrated
    • If 1 received, then mute by calling mac_native_mewt.scpt AppleScript
    • Otherwise, if 0 received, then unmute by calling mac_native_unmewt.scpt AppleScript
    • Write 1/0 for mute/unmute to serial so Arduino can display the correct status lights
  • Linux

    Click to expand

    Mewt Linux was tested on Ubuntu 20.04 LTS and 18.04LTS. It leverages the PulseAudio library for its communications with system microphones. See Acknowledgments The code currently mutes/unmutes a single microphone as opposed to iterating through every single device. Since you're a Linux user, have at it!

    Setup Pseudocode

    • Reads the COM port to look for Mewt on from port_arduino. should have been detected and written as part of the setup
    • Creates a Serial bus communicatioons using the COM port from above
    • Declares some temporary variables to keep state for last button state
    • Clears the console

    Loop Pseudocode

    • Read button state from Arduino
    • test_data.csv refers to hot-mic feature that is currently being tested and not yet integrated
    • If 1 received, then mute by calling pacmd set-source-mute X 1 _where X is microphone to be muted
    • Otherwise, if 0 received, then unmute by calling pacmd set-source-mute _X_01 _where X is microphone to be unmuted
    • Write 1/0 for mute/unmute to serial so Arduino can display the correct status lights

How you can support Mewt

Click to expand

All I ask is that you take a moment to do something kind.

  • Think of what you would have been willing to contribute to the Mewt project (however small the amount), and donate that to your favorite charity instead.

  • See someone hungry or cold? Buy them a small meal or cheap socks.

  • Have elderly neighbors? Offer to help shovel their driveway or mow their lawn.

  • People across the political divide have you on edge? Bake them some cookies just to be nice.

  • Even something as simple as given a random stranger your best smile.

If you can report back via this 5 second #UnMewtForGood questionnaire, it would really make my day. I'm hoping we can push out $1000 and/or 100 hours of kindness from this little corner of the internet.

Questions/Comments/Help

Join me on the Mewt Discord

Acknowledgments

Click to expand