Close
0%
0%

Smart earbuds

The stmart earbuds are earbuds that helps you prevent ear damage for artists and staff on stage

Public Chat
Similar projects worth following
With a sound cancelling technology, these earbuds allow stage people to work without damaging their hearing. How does it work ? Depending on where the user is, external sound will be canceled /reduced to maximize the comfort of the user. For example if one is close to the stage speakers the ear buds will cancel the sound to protect the ears. the Cancelling can work automatically or be controlled with a software. This project is aiming to be the next generation of earplugs.

You can find the link of our software prototype on the page.

This is a school project made to experiment with Iot.

At the beginning we wanted have wireless headphones and modify them to put  microphones where we wanted them to be. But since we didn't have the time and skills to that we had to keep it simple.

So our aim was to have the microphones connected to the raspberry pi 4, capture the music around. The raspberry would send the data to the software which would send  the clients sound parameters back to the raspberry. The raspi would then proceed to cancel the sound that need to be canceled and send the new wave shifted to the headphones via Bluetooth. For the testing we stayed in jack connection.

It's was very hard to do this project in time because the main components arrived late and we went through lots of problems using Raspberry pi for the first time.

Roadmapping for Coding Sound Treatment in Earbuds .pdf

The roadmapping for "How to code in Raspberry PI ?"

Adobe Portable Document Format - 623.86 kB - 05/05/2022 at 10:48

Preview

Roadmapping Coding Android App for Sound Control.pdf

The roadmapping for "How to code the App through Android ?"

Adobe Portable Document Format - 163.42 kB - 05/05/2022 at 10:48

Preview

  • 1 × Headphones blutooth, wireless, stereo headphones
  • 1 × raspberry pi 4 small processor used for calculating in real time the sound intensity and communicate it to the speakersand headphones with blutooth.
  • 2 × I2s microphones two small MEMS microphone to pick up the intensity of the surrounding sounds

  • 01/06/2022 Project log entry #7

    lauren06/01/2022 at 21:59 0 comments

    # -*- coding: utf-8 -*-
    ##############################################
    # QuadMic Test for all 4-Microphones
    # ---- this code plots the time series for all
    # ---- four MEMS microphones on the QuadMic
    # ---- attached to the Raspberry Pi
    #
    # -- by Josh Hrisko, Principal Engineer
    #       Maker Portal LLC 2021
    #
    
    import pyaudio,sys,time
    import matplotlib
    matplotlib.use('TkAgg')
    import numpy as np
    import matplotlib.pyplot as plt
    #
    ##############################################
    # Finding QuadMic Device 
    ##############################################
    #
    def indx_getter():
        quadmic_indx = []
        for indx in range(audio.get_device_count()):
            dev = audio.get_device_info_by_index(indx) # get device
            if dev['maxInputChannels']==2 :
                print('-'*30)
                print('Mics!')
                print('Device Index: {}'.format(indx)) # device index
                print('Device Name: {}'.format(dev['name'])) # device name
                print('Device Input Channels: {}'.format(dev['maxInputChannels'])) # channels
                quadmic_indx = int(indx)
                channels = dev['maxInputChannels']
        if quadmic_indx == []:
            print('No Mic Found')
            sys.exit() # exit the script if no QuadMic found
        return quadmic_indx,channels # return index, if found
    #
    ##############################################
    # pyaudio Streaming Object
    ##############################################
    #
    def audio_dev_formatter():
        stream = audio.open(format=pyaudio_format,rate=samp_rate,
                            channels=chans,input_device_index=quadmic_indx,
                            input=True,output_device_index=(0),output=True,frames_per_buffer=CHUNK) # audio stream
        stream.stop_stream() # stop streaming to prevent overload
        return stream
    #
    ##############################################
    # Grabbing Data from Buffer
    ##############################################
    #
    def data_grabber():
        stream.start_stream() # start data stream
        channel_data = [[]]*chans # data array
        [stream.read(CHUNK,exception_on_overflow=False) for ii in range(0,1)] # clears buffer
        for frame in range(0,int(np.ceil((samp_rate*record_length)/CHUNK))):
            if frame==0:
                print('Recording Started...')
            # grab data frames from buffer
            stream_data = stream.read(CHUNK,exception_on_overflow=False)
            data = np.frombuffer(stream_data,dtype=buffer_format) # grab data from buffer
            stream_listen = stream.write(data) #writting the data allows us to have the microphones' feedback  
            for chan in range(chans): # loop through all channels
                channel_data[chan] = np.append(channel_data[chan],
                                            data[chan::chans]) # separate channels
        print('Recording Stopped')
        return channel_data
    #
    ##############################################
    # functions for plotting data
    ##############################################
    #
    def plotter():
        ##########################################
        # ---- time series for all mics
        plt.style.use('ggplot') # plot formatting
        fig,ax = plt.subplots(figsize=(12,8)) # create figure
        ax.set_ylabel('Amplitude',fontsize=16) # amplitude label
        ax.set_ylim([-2**15,2**15]) # set 16-bit limits
        fig.canvas.draw() # draw initial plot
        ax_bgnd = fig.canvas.copy_from_bbox(ax.bbox) # get background
        lines = [] # line array for updating
        for chan in range(chans): # loop through channels
            chan_line, = ax.plot(data_chunks[chan],
                    label='Microphone {0:1d}'.format(chan+1)) # initial channel plot
            lines.append(chan_line) # channel plot array
        ax.legend(loc='upper center',
                  bbox_to_anchor=(0.5,-0.05),ncol=chans) # legend for mic labels
        fig.show() # show plot
        return fig,ax,ax_bgnd,lines
    
    def plot_updater():
        ##########################################
        # ---- time series and full-period FFT
        fig.canvas.restore_region(ax_bgnd) # restore background (for speed)
        for chan in range(chans):
            lines[chan].set_ydata(data_chunks[chan]) # set channel data
            ax.draw_artist(lines[chan]) # draw line
        fig.canvas.blit(ax.bbox) # blitting (for speed)
        fig.canvas.flush_events() # required for blitting
        return lines
    #
    ##############################################
    # Main Loop
    ##############################################
    #
    if __name__=="__main__":
        #########################
        # Audio Formatting
        #########################...
    Read more »

  • 01/06/2022 Project log entry #6

    lauren06/01/2022 at 10:02 0 comments


    This is the wave form of the sound captured by the microphones. Two colors, two channels, two microphone.

    So In the previous log, I talk about different python code that I struggled with. I finally succeed at plotting the wave form with the code that was made for Quadramicrophones. Here it is :
    # -*- coding: utf-8 -*-
    ##############################################
    # QuadMic Test for all 4-Microphones
    # ---- this code plots the time series for all
    # ---- four MEMS microphones on the QuadMic
    # ---- attached to the Raspberry Pi
    #
    # -- by Josh Hrisko, Principal Engineer
    #       Maker Portal LLC 2021
    #
    
    import pyaudio,sys,time
    import matplotlib
    matplotlib.use('TkAgg')
    import numpy as np
    import matplotlib.pyplot as plt
    #
    ##############################################
    # Finding QuadMic Device 
    ##############################################
    #
    def indx_getter():
        quadmic_indx = []
        for indx in range(audio.get_device_count()):
            dev = audio.get_device_info_by_index(indx) # get device
            if dev['maxInputChannels']==2 :
                print('-'*30)
                print('Mics!')
                print('Device Index: {}'.format(indx)) # device index
                print('Device Name: {}'.format(dev['name'])) # device name
                print('Device Input Channels: {}'.format(dev['maxInputChannels'])) # channels
                quadmic_indx = int(indx)
                channels = dev['maxInputChannels']
        if quadmic_indx == []:
            print('No Mic Found')
            sys.exit() # exit the script if no QuadMic found
        return quadmic_indx,channels # return index, if found
    #
    ##############################################
    # pyaudio Streaming Object
    ##############################################
    #
    def audio_dev_formatter():
        stream = audio.open(format=pyaudio_format,rate=samp_rate,
                            channels=chans,input_device_index=quadmic_indx,
                            input=True,frames_per_buffer=CHUNK) # audio stream
        stream.stop_stream() # stop streaming to prevent overloa
        return stream
    #
    ##############################################
    # Grabbing Data from Buffer
    ##############################################
    #
    def data_grabber():
        stream.start_stream() # start data stream
        channel_data = [[]]*chans # data array
        [stream.read(CHUNK,exception_on_overflow=False) for ii in range(0,1)] # clears buffer
        for frame in range(0,int(np.ceil((samp_rate*record_length)/CHUNK))):
            if frame==0:
                print('Recording Started...')
            # grab data frames from buffer
            stream_data = stream.read(CHUNK,exception_on_overflow=False)
            data = np.frombuffer(stream_data,dtype=buffer_format) # grab data from buffer
            for chan in range(chans): # loop through all channels
                channel_data[chan] = np.append(channel_data[chan],
                                            data[chan::chans]) # separate channels
        print('Recording Stopped')
        return channel_data
    #
    ##############################################
    # functions for plotting data
    ##############################################
    #
    def plotter():
        ##########################################
        # ---- time series for all mics
        plt.style.use('ggplot') # plot formatting
        fig,ax = plt.subplots(figsize=(12,8)) # create figure
        ax.set_ylabel('Amplitude',fontsize=16) # amplitude label
        ax.set_ylim([-2**15,2**15]) # set 16-bit limits
        fig.canvas.draw() # draw initial plot
        ax_bgnd = fig.canvas.copy_from_bbox(ax.bbox) # get background
        lines = [] # line array for updating
        for chan in range(chans): # loop through channels
            chan_line, = ax.plot(data_chunks[chan],
                    label='Microphone {0:1d}'.format(chan+1)) # initial channel plot
            lines.append(chan_line) # channel plot array
        ax.legend(loc='upper center',
                  bbox_to_anchor=(0.5,-0.05),ncol=chans) # legend for mic labels
        fig.show() # show plot
        return fig,ax,ax_bgnd,lines
    
    def plot_updater():
        ##########################################
        # ---- time series and full-period FFT
        fig.canvas.restore_region(ax_bgnd) # restore background (for speed)
        for chan in range(chans):
            lines[chan].set_ydata(data_chunks[chan]) # set channel data
            ax.draw_artist(lines[chan]) # draw line
        fig.canvas.blit(ax.bbox) # blitting (for speed)
        fig.canvas.flush_events() # required for blitting
        return lines
    #
    ##############################################...
    Read more »

  • 29/05/2022 Project log entry #5

    lauren05/29/2022 at 20:35 0 comments

    I am frustrated.

    We were trying to find a way to display sound signals on computer when streaming it. I tried to use python codes on the raspberry screen. One plotted a chart but there was no signal. I assume that it's because I'm failing to let the code acknowledge the microphone or even the raspberry. One of the codes that I found was used for a quadramic, where I thought I just had to change the device name and the number of channels but nooo.  For the others I also tried to change the devices and channels and it's a nope.

    Yes I tried node-red and it's a no too.

    (this photo disappeared lol will re-upload it when I'll be less desperate)

     When I used  it on the raspberry desktop the terminal was saying that the microphone was silent because the raspberry was busy. So I started node red through ssh communication. You see on the picture that the microphone remain silent when I start streaming. It not, the microphone, not the wiring, I can record easily on a terminal. The mic node that I use is node-red-contrib-mic that you can find in the library. With this microphone node I can input the recording card which is found typing arecord -l on the terminal. for me It is 1,0 which I indicate with plughw: 1,0 on the microphone properties.
     
    I tried with different type of microphone node did'nt work. One of them saved a recording file in my raspi tough. But when I aplay it it's very short and can't hear anything.

    With node-red-contrib-sox-utils :


    I really tried with a lot of mic node :'''''(.

    All of the tutorials on how to use I2S mic with raspi 4 didn't work and there's like two :'( and some forums discussions. I searched and searched and searched nothing. Each time I find a solution there's another problem with the raspberry that I have to google and google and at the end the project is not going anywhere.

    I think I would recommend using Arduino if you want to visualize something without struggling because it's already included in the software. I tried with the adafruit M0 card and here is a signal (me speaking). 


  • 19/05/2022 Project log entry #4

    maxime.sauvage05/19/2022 at 10:55 0 comments

    19/05/2022

    The headphones had STILL NOT ARRIVED.

    The app for the earbuds is now finished.

    After struggling a little bit, we succeed at making the microphones work. We soldered the mics pins. Now we are trying to find a way to visualize audio signals. We tried to have access to the raspberry pi screen via vnc but the screen is blank black and we can just run one application at a time. We manage to download spyder on raspberry and are currently trying to display the graphics on there.

  • 12/05/2022 Project log entry #3 sequel - Connexion problem solved

    lauren05/12/2022 at 23:00 0 comments

    So we previously couldn't connect the raspberry pi to my computer.

    Problems/Solutions :

    Pb: the raspberry couldn't connect to my 4G when the connection file was in the ssh folder created at the sd card root.

    S: I put the file directly in the sd card root

    Pb : When connected to 4G, the raspberry wouldn't connect to the computer. The connection wasn't allowed. When it was allowed the raspberry default password didn't work.

    S: I directly configured the wifi when enabling ssh on Raspberry Imager (when you install all the files on the sd card aka when you're flashing). I also chose a user name and a password for the raspberry (still at the flashing stage). The new imager version requires that now.  /!\ Apparently, you still have to put the wifi connection file on the sd after flashing it this way.

    Pb : the connection would time out

    S : Your pc and rby might  not be on the same wifi, or you have bad connection.

    Pb : a lot of command that I found on internet where in linux and not window langage, plus my ubuntu didn't no matter even after re downloading 234655 times on internet or the windows store.

    S: Just follow this https://codedesign.fr/tutorial/wsl2-linux-sous-windows/ it's how to install it via the windows shell

  • 12/05/2022 Project log entry #3

    maxime.sauvage05/12/2022 at 10:41 0 comments

    12/05/2022

    The headphones that we ordered had still not arrived. 

    Meanwhile, we’ve continued trying to connect the Raspberry Pi to a computer and a phone. We also made good progress on designing an app for a phone through the help of the web site Glide. This app will have all functionalities necessary for the user.

  • 05/05/2022 Project log entry #2

    maxime.sauvage05/05/2022 at 10:45 0 comments

    05/05/2022

    The road making of the project was produced.

    We received the microphones and started wiring it with the Raspberry Pi. We also started looking for a SHELL code to use for the making of the app.

  • 21/04/2022 Project log entry #1

    maxime.sauvage04/21/2022 at 10:33 0 comments

    21/04/2022

    We created the hackaday page for the project. The schematics and components were immediately added.

    Half of the group worked on defining our user's persona model in order to better figure out the needs our project should solve. This process is to be completed by the next session.

    Meanwhile the others were figuring out how the Node Red (the control interface for the Raspberry Pi) operates and started to test a few configurations.

View all 8 project logs

  • 1
    Wiring and testing of Adafruit 's i2s microphones

    Make sure you set the raspberry up before this step and connected to your laptop via ssh.

    For the wiring and testing of the Adafruit mic you can follow these steps :

    https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test

    sensors_pi_i2s_stereo_bb.png

  • 2
    Take the control via you computer

    In this step we are going to be able to see Raspberry desktop via your computer.

    For that your are going to download VNCviewer both on the raspberry and you computer.

    https://www.realvnc.com/fr/connect/download/viewer/windows/

    To install the software on Raspberry pi put the downloaded file in the raspi sd card.

    When you've done installing it on both devices open vnc on your computer. Make sure that the Raspberry and your computer are connected to the same network.

    Enter your raspberry ip address.

    Then login with the same password and username that you chose while setting up the raspberry. There you go, you have access to the raspberry screen.
  • 3
    Python3 and spyder

    For this project you will need to install spyder3 in the raspberry pi. Run these in the raspberry terminal.

    sudo apt update
    sudo apt-get install spyder3

View all 4 instructions

Enjoy this project?

Share

Discussions

Vo-An NGUYEN wrote 04/21/2022 at 09:05 point

Hello guys, nice to meet you all ! 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates