How to keep the audio profile at A2DP while using a mic with Bluetooth headset? (Push-to-talk) [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
1













This question already has an answer here:



  • Headphones microphone is not working

    3 answers



I have a CEL-TEC F5A headset.
The spec says:




Bluetooth 4.0, profiles: Headset, Hands free, A2DP, AVRCP/HSP/HFP




It plays nicely with High Fidelity Playback (A2DP sink) profile.



When I want to switch audio input to the headset's microphone, the output profile automatically changes to Headset Head Unit (HFS/HFP) and the quality is terrible - like 8bit sound or something. When I switch it back to A2DP, the input is back to desktop mic.



I've read few of other questions and seems A2DP is expected not to support input, right? But the HFP part in HFS/HFP is High Fidelity Playback I guess? That sounds like it could work as a headset and still not sound like 1950's phone.



How could I simplify switching between the profiles so that it is HFS/HFP when I talk and A2DP when I listen? E.g. as a push-to-talk.



Ubuntu 17.10, no sound customization IIRC, everything latest.
https://www.kabelmanie.cz/cel-tec-f5a-active-noise-bluetooth-stereo-sluchatka-s-mikrofonem/



My output:



$ pactl list cards
Card #0
Name: alsa_card.pci-0000_00_03.0
...

Card #4
Name: bluez_card.00_19_5D_25_6F_6C
Driver: module-bluez5-device.c
Owner Module: 30
Properties:
device.description = "F5A"
device.string = "00:19:5D:25:6F:6C"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_00_19_5D_25_6F_6C"
bluez.class = "0x240404"
bluez.alias = "F5A"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp_sink
Ports:
headset-output: Headset (priority: 0, latency offset: 0 usec, available)
Part of profile(s): a2dp_sink, headset_head_unit
headset-input: Headset (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit


The problem here is not that the microphone does not work, but rather that the audio quality worsens when it is activated.










share|improve this question















marked as duplicate by dobey, Eric Carvalho, Zanna, Elder Geek, George Udosen Feb 25 at 17:17


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    1
    down vote

    favorite
    1













    This question already has an answer here:



    • Headphones microphone is not working

      3 answers



    I have a CEL-TEC F5A headset.
    The spec says:




    Bluetooth 4.0, profiles: Headset, Hands free, A2DP, AVRCP/HSP/HFP




    It plays nicely with High Fidelity Playback (A2DP sink) profile.



    When I want to switch audio input to the headset's microphone, the output profile automatically changes to Headset Head Unit (HFS/HFP) and the quality is terrible - like 8bit sound or something. When I switch it back to A2DP, the input is back to desktop mic.



    I've read few of other questions and seems A2DP is expected not to support input, right? But the HFP part in HFS/HFP is High Fidelity Playback I guess? That sounds like it could work as a headset and still not sound like 1950's phone.



    How could I simplify switching between the profiles so that it is HFS/HFP when I talk and A2DP when I listen? E.g. as a push-to-talk.



    Ubuntu 17.10, no sound customization IIRC, everything latest.
    https://www.kabelmanie.cz/cel-tec-f5a-active-noise-bluetooth-stereo-sluchatka-s-mikrofonem/



    My output:



    $ pactl list cards
    Card #0
    Name: alsa_card.pci-0000_00_03.0
    ...

    Card #4
    Name: bluez_card.00_19_5D_25_6F_6C
    Driver: module-bluez5-device.c
    Owner Module: 30
    Properties:
    device.description = "F5A"
    device.string = "00:19:5D:25:6F:6C"
    device.api = "bluez"
    device.class = "sound"
    device.bus = "bluetooth"
    device.form_factor = "headset"
    bluez.path = "/org/bluez/hci0/dev_00_19_5D_25_6F_6C"
    bluez.class = "0x240404"
    bluez.alias = "F5A"
    device.icon_name = "audio-headset-bluetooth"
    device.intended_roles = "phone"
    Profiles:
    a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
    headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
    off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    Active Profile: a2dp_sink
    Ports:
    headset-output: Headset (priority: 0, latency offset: 0 usec, available)
    Part of profile(s): a2dp_sink, headset_head_unit
    headset-input: Headset (priority: 0, latency offset: 0 usec)
    Part of profile(s): headset_head_unit


    The problem here is not that the microphone does not work, but rather that the audio quality worsens when it is activated.










    share|improve this question















    marked as duplicate by dobey, Eric Carvalho, Zanna, Elder Geek, George Udosen Feb 25 at 17:17


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1






      This question already has an answer here:



      • Headphones microphone is not working

        3 answers



      I have a CEL-TEC F5A headset.
      The spec says:




      Bluetooth 4.0, profiles: Headset, Hands free, A2DP, AVRCP/HSP/HFP




      It plays nicely with High Fidelity Playback (A2DP sink) profile.



      When I want to switch audio input to the headset's microphone, the output profile automatically changes to Headset Head Unit (HFS/HFP) and the quality is terrible - like 8bit sound or something. When I switch it back to A2DP, the input is back to desktop mic.



      I've read few of other questions and seems A2DP is expected not to support input, right? But the HFP part in HFS/HFP is High Fidelity Playback I guess? That sounds like it could work as a headset and still not sound like 1950's phone.



      How could I simplify switching between the profiles so that it is HFS/HFP when I talk and A2DP when I listen? E.g. as a push-to-talk.



      Ubuntu 17.10, no sound customization IIRC, everything latest.
      https://www.kabelmanie.cz/cel-tec-f5a-active-noise-bluetooth-stereo-sluchatka-s-mikrofonem/



      My output:



      $ pactl list cards
      Card #0
      Name: alsa_card.pci-0000_00_03.0
      ...

      Card #4
      Name: bluez_card.00_19_5D_25_6F_6C
      Driver: module-bluez5-device.c
      Owner Module: 30
      Properties:
      device.description = "F5A"
      device.string = "00:19:5D:25:6F:6C"
      device.api = "bluez"
      device.class = "sound"
      device.bus = "bluetooth"
      device.form_factor = "headset"
      bluez.path = "/org/bluez/hci0/dev_00_19_5D_25_6F_6C"
      bluez.class = "0x240404"
      bluez.alias = "F5A"
      device.icon_name = "audio-headset-bluetooth"
      device.intended_roles = "phone"
      Profiles:
      a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
      headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
      off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
      Active Profile: a2dp_sink
      Ports:
      headset-output: Headset (priority: 0, latency offset: 0 usec, available)
      Part of profile(s): a2dp_sink, headset_head_unit
      headset-input: Headset (priority: 0, latency offset: 0 usec)
      Part of profile(s): headset_head_unit


      The problem here is not that the microphone does not work, but rather that the audio quality worsens when it is activated.










      share|improve this question
















      This question already has an answer here:



      • Headphones microphone is not working

        3 answers



      I have a CEL-TEC F5A headset.
      The spec says:




      Bluetooth 4.0, profiles: Headset, Hands free, A2DP, AVRCP/HSP/HFP




      It plays nicely with High Fidelity Playback (A2DP sink) profile.



      When I want to switch audio input to the headset's microphone, the output profile automatically changes to Headset Head Unit (HFS/HFP) and the quality is terrible - like 8bit sound or something. When I switch it back to A2DP, the input is back to desktop mic.



      I've read few of other questions and seems A2DP is expected not to support input, right? But the HFP part in HFS/HFP is High Fidelity Playback I guess? That sounds like it could work as a headset and still not sound like 1950's phone.



      How could I simplify switching between the profiles so that it is HFS/HFP when I talk and A2DP when I listen? E.g. as a push-to-talk.



      Ubuntu 17.10, no sound customization IIRC, everything latest.
      https://www.kabelmanie.cz/cel-tec-f5a-active-noise-bluetooth-stereo-sluchatka-s-mikrofonem/



      My output:



      $ pactl list cards
      Card #0
      Name: alsa_card.pci-0000_00_03.0
      ...

      Card #4
      Name: bluez_card.00_19_5D_25_6F_6C
      Driver: module-bluez5-device.c
      Owner Module: 30
      Properties:
      device.description = "F5A"
      device.string = "00:19:5D:25:6F:6C"
      device.api = "bluez"
      device.class = "sound"
      device.bus = "bluetooth"
      device.form_factor = "headset"
      bluez.path = "/org/bluez/hci0/dev_00_19_5D_25_6F_6C"
      bluez.class = "0x240404"
      bluez.alias = "F5A"
      device.icon_name = "audio-headset-bluetooth"
      device.intended_roles = "phone"
      Profiles:
      a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
      headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
      off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
      Active Profile: a2dp_sink
      Ports:
      headset-output: Headset (priority: 0, latency offset: 0 usec, available)
      Part of profile(s): a2dp_sink, headset_head_unit
      headset-input: Headset (priority: 0, latency offset: 0 usec)
      Part of profile(s): headset_head_unit


      The problem here is not that the microphone does not work, but rather that the audio quality worsens when it is activated.





      This question already has an answer here:



      • Headphones microphone is not working

        3 answers







      bash sound 17.10 bluetooth microphone






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 24 at 21:37









      Zanna

      48.2k13120228




      48.2k13120228










      asked Feb 10 at 0:02









      Ondra Žižka

      81311024




      81311024




      marked as duplicate by dobey, Eric Carvalho, Zanna, Elder Geek, George Udosen Feb 25 at 17:17


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by dobey, Eric Carvalho, Zanna, Elder Geek, George Udosen Feb 25 at 17:17


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Based on this article I fear that Bluetooth won't give me the pleasure of hearing a quality sound and speak over the headset at the same time. :/



          Not accepting this answer though, I am still hoping someone will come up with some way to do so.






          share|improve this answer



























            up vote
            0
            down vote













            I was about to return the headset and wait for Bluetooth 5.0 headset, but then realized, that's the best functionality I can get with my BT 4.0 laptop. So I kept them.



            Still, listening to a French guy over 16 bit 8000 Hz audio wasn't really the right way to have a meeting. For few days, I was switching between the two modes using Ubuntu's sound settings dialog, but that's really, really annoying as you can imagine.



            So I wrote this script leveraging pacmd which toggles between the 2 modes:



            • Crappy audio, microphone on

            • Near-CD quality audio, microphone off

            It is not polished, has some dead code, and I use my own phones ID's, but it may be an inspiration for your own script. Latest version here.



            #!/bin/bash

            #### Restart Bluetooth
            if [ "$1" == "resetBT" ] ; then
            sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
            exit;
            fi;

            #### Toggle listen/speak
            if [ "$1" == "" -o "$1" == "toggle" ] ; then
            LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
            if [ "$LINE" == "" ] ; then echo "F5A headset not found"; exit; fi

            SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
            if $(echo "$LINE" | grep $SINK_NAME &> /dev/null) ; then
            echo "Detected quality sound output, that means we can't speak; switch that."
            $0 speak;
            else
            echo "Quality sound not found, switch to the good sound."
            $0 listen;
            fi
            fi

            #### Change the output to F5A
            if [ "$1" == "listen" ] ; then
            LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
            if [ "$LINE" == "" ] ; then echo "F5A phones not found"; exit; fi
            # name: <bluez_sink.00_19_5D_25_6F_6C.headset_head_unit>

            ## Get what's between <...>
            SINK_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;

            ## The above gives an ID according to the active profile.
            ## To set manually:
            #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.headset_head_unit"
            #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"

            ## Switch the output to that.
            echo "Switching audio output to $SINK_NAME";
            pacmd set-default-sink "$SINK_NAME"

            #### Change profile to quality output + no mic. From `pacmd list-cards`:
            CARD="bluez_card.00_19_5D_25_6F_6C"
            PROFILE="a2dp_sink"
            echo "Switching audio profile to $PROFILE";
            pacmd set-card-profile $CARD $PROFILE
            exit;
            fi;

            #### Input
            if [ "$1" == "speak" ] ; then
            ## Change profile to crappy output + mic. From `pacmd list-cards`:
            CARD="bluez_card.00_19_5D_25_6F_6C"
            pacmd set-card-profile $CARD headset_head_unit

            LINE=`pacmd list-sources | grep '(name:|alias)' | grep -B1 F5A | head -1`
            if [ "$LINE" == "" ] ; then echo "F5A mic not found"; exit; fi
            SOURCE_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
            #SOURCE_NAME="bluez_source.00_19_5D_25_6F_6C.headset_head_unit"
            #SOURCE_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink.monitor"
            echo "Switching audio input to $SOURCE_NAME";
            pacmd set-default-source "$SOURCE_NAME" || echo 'Try `pacmd list-sources`.';
            fi;


            #### Resources:

            ## Why this is needed
            # https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/

            ## My original question
            # https://askubuntu.com/questions/1004712/audio-profile-changes-automatically-to-hsp-bad-quality-when-i-change-input-to/1009156#1009156

            ## Script to monitor plugged earphones and switch when unplugged (Ubuntu does that, but nice script):
            # https://github.com/freundTech/linux-helper-scripts/blob/master/padevswitch/padevswitch


            Hope this helps someone :) Still, I am not accepting this answer either, hoping for some magic that will enable good sound with mic on.






            share|improve this answer





























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              Based on this article I fear that Bluetooth won't give me the pleasure of hearing a quality sound and speak over the headset at the same time. :/



              Not accepting this answer though, I am still hoping someone will come up with some way to do so.






              share|improve this answer
























                up vote
                0
                down vote













                Based on this article I fear that Bluetooth won't give me the pleasure of hearing a quality sound and speak over the headset at the same time. :/



                Not accepting this answer though, I am still hoping someone will come up with some way to do so.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Based on this article I fear that Bluetooth won't give me the pleasure of hearing a quality sound and speak over the headset at the same time. :/



                  Not accepting this answer though, I am still hoping someone will come up with some way to do so.






                  share|improve this answer












                  Based on this article I fear that Bluetooth won't give me the pleasure of hearing a quality sound and speak over the headset at the same time. :/



                  Not accepting this answer though, I am still hoping someone will come up with some way to do so.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 10 at 1:37









                  Ondra Žižka

                  81311024




                  81311024






















                      up vote
                      0
                      down vote













                      I was about to return the headset and wait for Bluetooth 5.0 headset, but then realized, that's the best functionality I can get with my BT 4.0 laptop. So I kept them.



                      Still, listening to a French guy over 16 bit 8000 Hz audio wasn't really the right way to have a meeting. For few days, I was switching between the two modes using Ubuntu's sound settings dialog, but that's really, really annoying as you can imagine.



                      So I wrote this script leveraging pacmd which toggles between the 2 modes:



                      • Crappy audio, microphone on

                      • Near-CD quality audio, microphone off

                      It is not polished, has some dead code, and I use my own phones ID's, but it may be an inspiration for your own script. Latest version here.



                      #!/bin/bash

                      #### Restart Bluetooth
                      if [ "$1" == "resetBT" ] ; then
                      sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
                      exit;
                      fi;

                      #### Toggle listen/speak
                      if [ "$1" == "" -o "$1" == "toggle" ] ; then
                      LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                      if [ "$LINE" == "" ] ; then echo "F5A headset not found"; exit; fi

                      SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
                      if $(echo "$LINE" | grep $SINK_NAME &> /dev/null) ; then
                      echo "Detected quality sound output, that means we can't speak; switch that."
                      $0 speak;
                      else
                      echo "Quality sound not found, switch to the good sound."
                      $0 listen;
                      fi
                      fi

                      #### Change the output to F5A
                      if [ "$1" == "listen" ] ; then
                      LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                      if [ "$LINE" == "" ] ; then echo "F5A phones not found"; exit; fi
                      # name: <bluez_sink.00_19_5D_25_6F_6C.headset_head_unit>

                      ## Get what's between <...>
                      SINK_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;

                      ## The above gives an ID according to the active profile.
                      ## To set manually:
                      #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.headset_head_unit"
                      #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"

                      ## Switch the output to that.
                      echo "Switching audio output to $SINK_NAME";
                      pacmd set-default-sink "$SINK_NAME"

                      #### Change profile to quality output + no mic. From `pacmd list-cards`:
                      CARD="bluez_card.00_19_5D_25_6F_6C"
                      PROFILE="a2dp_sink"
                      echo "Switching audio profile to $PROFILE";
                      pacmd set-card-profile $CARD $PROFILE
                      exit;
                      fi;

                      #### Input
                      if [ "$1" == "speak" ] ; then
                      ## Change profile to crappy output + mic. From `pacmd list-cards`:
                      CARD="bluez_card.00_19_5D_25_6F_6C"
                      pacmd set-card-profile $CARD headset_head_unit

                      LINE=`pacmd list-sources | grep '(name:|alias)' | grep -B1 F5A | head -1`
                      if [ "$LINE" == "" ] ; then echo "F5A mic not found"; exit; fi
                      SOURCE_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
                      #SOURCE_NAME="bluez_source.00_19_5D_25_6F_6C.headset_head_unit"
                      #SOURCE_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink.monitor"
                      echo "Switching audio input to $SOURCE_NAME";
                      pacmd set-default-source "$SOURCE_NAME" || echo 'Try `pacmd list-sources`.';
                      fi;


                      #### Resources:

                      ## Why this is needed
                      # https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/

                      ## My original question
                      # https://askubuntu.com/questions/1004712/audio-profile-changes-automatically-to-hsp-bad-quality-when-i-change-input-to/1009156#1009156

                      ## Script to monitor plugged earphones and switch when unplugged (Ubuntu does that, but nice script):
                      # https://github.com/freundTech/linux-helper-scripts/blob/master/padevswitch/padevswitch


                      Hope this helps someone :) Still, I am not accepting this answer either, hoping for some magic that will enable good sound with mic on.






                      share|improve this answer


























                        up vote
                        0
                        down vote













                        I was about to return the headset and wait for Bluetooth 5.0 headset, but then realized, that's the best functionality I can get with my BT 4.0 laptop. So I kept them.



                        Still, listening to a French guy over 16 bit 8000 Hz audio wasn't really the right way to have a meeting. For few days, I was switching between the two modes using Ubuntu's sound settings dialog, but that's really, really annoying as you can imagine.



                        So I wrote this script leveraging pacmd which toggles between the 2 modes:



                        • Crappy audio, microphone on

                        • Near-CD quality audio, microphone off

                        It is not polished, has some dead code, and I use my own phones ID's, but it may be an inspiration for your own script. Latest version here.



                        #!/bin/bash

                        #### Restart Bluetooth
                        if [ "$1" == "resetBT" ] ; then
                        sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
                        exit;
                        fi;

                        #### Toggle listen/speak
                        if [ "$1" == "" -o "$1" == "toggle" ] ; then
                        LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                        if [ "$LINE" == "" ] ; then echo "F5A headset not found"; exit; fi

                        SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
                        if $(echo "$LINE" | grep $SINK_NAME &> /dev/null) ; then
                        echo "Detected quality sound output, that means we can't speak; switch that."
                        $0 speak;
                        else
                        echo "Quality sound not found, switch to the good sound."
                        $0 listen;
                        fi
                        fi

                        #### Change the output to F5A
                        if [ "$1" == "listen" ] ; then
                        LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                        if [ "$LINE" == "" ] ; then echo "F5A phones not found"; exit; fi
                        # name: <bluez_sink.00_19_5D_25_6F_6C.headset_head_unit>

                        ## Get what's between <...>
                        SINK_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;

                        ## The above gives an ID according to the active profile.
                        ## To set manually:
                        #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.headset_head_unit"
                        #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"

                        ## Switch the output to that.
                        echo "Switching audio output to $SINK_NAME";
                        pacmd set-default-sink "$SINK_NAME"

                        #### Change profile to quality output + no mic. From `pacmd list-cards`:
                        CARD="bluez_card.00_19_5D_25_6F_6C"
                        PROFILE="a2dp_sink"
                        echo "Switching audio profile to $PROFILE";
                        pacmd set-card-profile $CARD $PROFILE
                        exit;
                        fi;

                        #### Input
                        if [ "$1" == "speak" ] ; then
                        ## Change profile to crappy output + mic. From `pacmd list-cards`:
                        CARD="bluez_card.00_19_5D_25_6F_6C"
                        pacmd set-card-profile $CARD headset_head_unit

                        LINE=`pacmd list-sources | grep '(name:|alias)' | grep -B1 F5A | head -1`
                        if [ "$LINE" == "" ] ; then echo "F5A mic not found"; exit; fi
                        SOURCE_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
                        #SOURCE_NAME="bluez_source.00_19_5D_25_6F_6C.headset_head_unit"
                        #SOURCE_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink.monitor"
                        echo "Switching audio input to $SOURCE_NAME";
                        pacmd set-default-source "$SOURCE_NAME" || echo 'Try `pacmd list-sources`.';
                        fi;


                        #### Resources:

                        ## Why this is needed
                        # https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/

                        ## My original question
                        # https://askubuntu.com/questions/1004712/audio-profile-changes-automatically-to-hsp-bad-quality-when-i-change-input-to/1009156#1009156

                        ## Script to monitor plugged earphones and switch when unplugged (Ubuntu does that, but nice script):
                        # https://github.com/freundTech/linux-helper-scripts/blob/master/padevswitch/padevswitch


                        Hope this helps someone :) Still, I am not accepting this answer either, hoping for some magic that will enable good sound with mic on.






                        share|improve this answer
























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          I was about to return the headset and wait for Bluetooth 5.0 headset, but then realized, that's the best functionality I can get with my BT 4.0 laptop. So I kept them.



                          Still, listening to a French guy over 16 bit 8000 Hz audio wasn't really the right way to have a meeting. For few days, I was switching between the two modes using Ubuntu's sound settings dialog, but that's really, really annoying as you can imagine.



                          So I wrote this script leveraging pacmd which toggles between the 2 modes:



                          • Crappy audio, microphone on

                          • Near-CD quality audio, microphone off

                          It is not polished, has some dead code, and I use my own phones ID's, but it may be an inspiration for your own script. Latest version here.



                          #!/bin/bash

                          #### Restart Bluetooth
                          if [ "$1" == "resetBT" ] ; then
                          sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
                          exit;
                          fi;

                          #### Toggle listen/speak
                          if [ "$1" == "" -o "$1" == "toggle" ] ; then
                          LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                          if [ "$LINE" == "" ] ; then echo "F5A headset not found"; exit; fi

                          SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
                          if $(echo "$LINE" | grep $SINK_NAME &> /dev/null) ; then
                          echo "Detected quality sound output, that means we can't speak; switch that."
                          $0 speak;
                          else
                          echo "Quality sound not found, switch to the good sound."
                          $0 listen;
                          fi
                          fi

                          #### Change the output to F5A
                          if [ "$1" == "listen" ] ; then
                          LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                          if [ "$LINE" == "" ] ; then echo "F5A phones not found"; exit; fi
                          # name: <bluez_sink.00_19_5D_25_6F_6C.headset_head_unit>

                          ## Get what's between <...>
                          SINK_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;

                          ## The above gives an ID according to the active profile.
                          ## To set manually:
                          #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.headset_head_unit"
                          #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"

                          ## Switch the output to that.
                          echo "Switching audio output to $SINK_NAME";
                          pacmd set-default-sink "$SINK_NAME"

                          #### Change profile to quality output + no mic. From `pacmd list-cards`:
                          CARD="bluez_card.00_19_5D_25_6F_6C"
                          PROFILE="a2dp_sink"
                          echo "Switching audio profile to $PROFILE";
                          pacmd set-card-profile $CARD $PROFILE
                          exit;
                          fi;

                          #### Input
                          if [ "$1" == "speak" ] ; then
                          ## Change profile to crappy output + mic. From `pacmd list-cards`:
                          CARD="bluez_card.00_19_5D_25_6F_6C"
                          pacmd set-card-profile $CARD headset_head_unit

                          LINE=`pacmd list-sources | grep '(name:|alias)' | grep -B1 F5A | head -1`
                          if [ "$LINE" == "" ] ; then echo "F5A mic not found"; exit; fi
                          SOURCE_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
                          #SOURCE_NAME="bluez_source.00_19_5D_25_6F_6C.headset_head_unit"
                          #SOURCE_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink.monitor"
                          echo "Switching audio input to $SOURCE_NAME";
                          pacmd set-default-source "$SOURCE_NAME" || echo 'Try `pacmd list-sources`.';
                          fi;


                          #### Resources:

                          ## Why this is needed
                          # https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/

                          ## My original question
                          # https://askubuntu.com/questions/1004712/audio-profile-changes-automatically-to-hsp-bad-quality-when-i-change-input-to/1009156#1009156

                          ## Script to monitor plugged earphones and switch when unplugged (Ubuntu does that, but nice script):
                          # https://github.com/freundTech/linux-helper-scripts/blob/master/padevswitch/padevswitch


                          Hope this helps someone :) Still, I am not accepting this answer either, hoping for some magic that will enable good sound with mic on.






                          share|improve this answer














                          I was about to return the headset and wait for Bluetooth 5.0 headset, but then realized, that's the best functionality I can get with my BT 4.0 laptop. So I kept them.



                          Still, listening to a French guy over 16 bit 8000 Hz audio wasn't really the right way to have a meeting. For few days, I was switching between the two modes using Ubuntu's sound settings dialog, but that's really, really annoying as you can imagine.



                          So I wrote this script leveraging pacmd which toggles between the 2 modes:



                          • Crappy audio, microphone on

                          • Near-CD quality audio, microphone off

                          It is not polished, has some dead code, and I use my own phones ID's, but it may be an inspiration for your own script. Latest version here.



                          #!/bin/bash

                          #### Restart Bluetooth
                          if [ "$1" == "resetBT" ] ; then
                          sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
                          exit;
                          fi;

                          #### Toggle listen/speak
                          if [ "$1" == "" -o "$1" == "toggle" ] ; then
                          LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                          if [ "$LINE" == "" ] ; then echo "F5A headset not found"; exit; fi

                          SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
                          if $(echo "$LINE" | grep $SINK_NAME &> /dev/null) ; then
                          echo "Detected quality sound output, that means we can't speak; switch that."
                          $0 speak;
                          else
                          echo "Quality sound not found, switch to the good sound."
                          $0 listen;
                          fi
                          fi

                          #### Change the output to F5A
                          if [ "$1" == "listen" ] ; then
                          LINE=`pacmd list-sinks | grep '(name:|alias)' | grep -B1 F5A | head -1`
                          if [ "$LINE" == "" ] ; then echo "F5A phones not found"; exit; fi
                          # name: <bluez_sink.00_19_5D_25_6F_6C.headset_head_unit>

                          ## Get what's between <...>
                          SINK_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;

                          ## The above gives an ID according to the active profile.
                          ## To set manually:
                          #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.headset_head_unit"
                          #SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"

                          ## Switch the output to that.
                          echo "Switching audio output to $SINK_NAME";
                          pacmd set-default-sink "$SINK_NAME"

                          #### Change profile to quality output + no mic. From `pacmd list-cards`:
                          CARD="bluez_card.00_19_5D_25_6F_6C"
                          PROFILE="a2dp_sink"
                          echo "Switching audio profile to $PROFILE";
                          pacmd set-card-profile $CARD $PROFILE
                          exit;
                          fi;

                          #### Input
                          if [ "$1" == "speak" ] ; then
                          ## Change profile to crappy output + mic. From `pacmd list-cards`:
                          CARD="bluez_card.00_19_5D_25_6F_6C"
                          pacmd set-card-profile $CARD headset_head_unit

                          LINE=`pacmd list-sources | grep '(name:|alias)' | grep -B1 F5A | head -1`
                          if [ "$LINE" == "" ] ; then echo "F5A mic not found"; exit; fi
                          SOURCE_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
                          #SOURCE_NAME="bluez_source.00_19_5D_25_6F_6C.headset_head_unit"
                          #SOURCE_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink.monitor"
                          echo "Switching audio input to $SOURCE_NAME";
                          pacmd set-default-source "$SOURCE_NAME" || echo 'Try `pacmd list-sources`.';
                          fi;


                          #### Resources:

                          ## Why this is needed
                          # https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/

                          ## My original question
                          # https://askubuntu.com/questions/1004712/audio-profile-changes-automatically-to-hsp-bad-quality-when-i-change-input-to/1009156#1009156

                          ## Script to monitor plugged earphones and switch when unplugged (Ubuntu does that, but nice script):
                          # https://github.com/freundTech/linux-helper-scripts/blob/master/padevswitch/padevswitch


                          Hope this helps someone :) Still, I am not accepting this answer either, hoping for some magic that will enable good sound with mic on.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Feb 23 at 21:42

























                          answered Feb 23 at 21:00









                          Ondra Žižka

                          81311024




                          81311024












                              Popular posts from this blog

                              pylint3 and pip3 broken

                              Missing snmpget and snmpwalk

                              How to enroll fingerprints to Ubuntu 17.10 with VFS491