Lautsprecher und Mikrofon noch in Betrieb

  • Hallo an alle,


    Anleitungen, um den Lautsprecher und das Mikrofon stummzuschalten , wenn doorpi im Schlaf (Standby) ist?


    Tatsächlich in Betrieb doorpi, der Lautsprecher und das Mikrofon immer funktioniert: Wenn Sie in das Mikrofon sprechen, hören wir den Lautsprecher.
    Gibt es eine Möglichkeit, anzuhalten ? Und natürlich laufen sie wieder, wenn jemand an der Tür-Taste aktiviert.


    Im Voraus vielen Dank. Mit freundlichen Grüßen.


    Pat

  • Ja, das geht. Ich mache das mit einem PiFace-Modul, das eine Verbindung zwischen einem separaten Verstärker und einem Lautsprecher herstellt oder trennt. Hier mal meine entsprechenden doorpi.ini-Einträge:



    Zeile 4 sorgt dafür, dass der Verstärker nach dem Abnehmen an der Gegensprechstelle für 60 Sekunden mit dem Lautsprecher verbunden ist. Zeile 7 trennt den Lautsprecher vom Verstärker nach dem Auflegen. Die Zeilen 11 bis 17 definieren den Anschluss des PiFace-Moduls, über den die Verbindung zwischen Verstärker und Lautsprecher läuft.


    Gruß,


    Thorsten

  • dpt danke Ihnen für Ihre Antwort,


    Hier habe ich keine piface Karte.


    Mein Audio-Adapter wird in einen USB-Seite auf die Himbeere ft3 gesteckt
    und auf der anderen Seite des Lautsprechers und Mikrofons.


    Wie Sie Ihre Datei ohne doorpi.ini piface zu übersetzen?


    Mit freundlichen Grüßen.


    Pat


    nb: Der obige Text aus einer Google-Übersetzung ist.
    Ich glaube, dass der Übersetzer seine Arbeit zu tun.
    Haben Sie den Text zu verstehen? Ansonsten kann ich auf Englisch verbringen.

  • Well, Pat,


    to tell you the truth, I have cracked a Raspi by putting to much voltage on a pin of the I/O interface. After that, I decided to purchase a PiFace 2 module, which was a very good idea. Hence, I would strongly recommend to buy such a module.


    An advantage of the PiFace module is that it already has to relay outputs for controlling external devices like an amplifier. Even microphones or loudspeakers can easily be switched by them.


    By the way, it's no prolem for me to directly communicate in English language. On the other hand, it's funny to see how Google translates "Raspberry Pi". ;)


    Have a nice day,


    Thorsten

  • Hello Pat054,


    did you already try to use alsamixer to mute and unmute the speaker?


    Something like:

    Code
    amixer sset Master mute


    or


    Code
    amixer -c 0 set Master playback 0% mute


    Check the documentation for more information.
    I already tought about that, but did not have time to try it.
    I think this should work for all speakers and you don't need to use a relay (e.g. if your speaker is connected via USB, a relay between is not easily possible).


    Maybe some other doorpi users have some additional ideas, because this could be interesting more and I think it would be maybe good to integrate it as feature into doorpi.


    motom001_new: What do you think? Whould it be possible to intetrage such feature into doorpi?


    br
    Chris

  • Hello Streicher,


    Thank you for your answer. Indeed, I was looking for a command to mute the sound adapter without going through a relay.


    Yes, I have already used alsamixer but in screen mode (by entering alsamixer in the console).


    On the other hand, I never used directly its own "man amixer" commands in the console.


    The two commands "amixer -c 1 sset Master mute" and "amixer -c 1 set Master playback 0% mute" do not work, I have this: amixer: Unable to find simple control 'Master',0


    On the other hand, the following command works, it cuts off the sound:


    Code
    pi@raspberrypi:~ $ amixer -c 1 sset Speaker mute
    Simple mixer control 'Speaker',0
      Capabilities: pvolume pswitch pswitch-joined
      Playback channels: Front Left - Front Right
      Limits: Playback 0 - 151
      Mono:
      Front Left: Playback 25 [17%] [-23.69dB] [off]
      Front Right: Playback 25 [17%] [-23.69dB] [off]

    To restore the sound, simply run the command:



    Code
    pi@raspberrypi:~ $ amixer -c 1 sset Speaker unmute
    Simple mixer control 'Speaker',0
      Capabilities: pvolume pswitch pswitch-joined
      Playback channels: Front Left - Front Right
      Limits: Playback 0 - 151
      Mono:
      Front Left: Playback 25 [17%] [-23.69dB] [on]
      Front Right: Playback 25 [17%] [-23.69dB] [on]

    That's great


    How do you integrate these 2 commands into a python program?
    (I have never done)


    Cordially.


    Pat

  • I don't have experience in python, but it looks the function os.system(command) should help, where command is e.g. 'amixer -c 1 sset Speaker unmute'
    https://docs.python.org/3/library/os.html#os.system



    But why not running directly a shell script?



    doorpi.ini part:


    Code
    ...
    [EVENT_OnKeyPressed_onboardpins.0]
    10 = os_execute:/usr/local/etc/DoorPi/scripts/speaker_unmute.sh
    20 = <something else ... e.g. call something>
    ...



    speaker_unmute.sh

    Bash
    #!/bin/bash
    /usr/bin/amixer -c 1 sset Speaker unmute

    maybe it is also directly working in the doorpi.ini with:



    10 = os_execute:/usr/bin/amixer -c 1 sset Speaker unmute
    But I am not sure.



    The only thing is when to you mute the speaker again? With a timer? Or is it possible to trigger it e.g. when the call is disconnected, ...?

  • Thank you to you for this track.


    Effectively, you have to create two bash files named speaker_mute.sh (to stop the sound) and speaker_unmute (to reset the sound).
    As a reminder, a bash allows you to launch shell commands as if you were launching them in a console.


    So I created a speaker_mute.sh file (to stop the sound) with the nano editor such as:


    Code
    sudo nano speaker_mute.sh
    ....
    #!/usr/bin/env bash
    /usr/bin/amixer -c 1 sset Speaker mute
    ...
    ctrl + o +ENTER +ctrl x


    Then I created the executable such as:


    Code
    sudo chmod +x speaker_mute.sh


    And then I started the command:


    Code
    ./speaker_mute.sh


    It's great: the sound has gone out!


    Then I created a speaker_unmute.sh file (to resume the sound) with the nano editor such as:


    Code
    sudo nano speaker_unmute.sh
    ...
    #!/usr/bin/env bash
    /usr/bin/amixer -c 1 sset Speaker unmute
    ...
    ctrl + o +ENTER +ctrl x


    Then I created the executable such as:


    Code
    sudo chmod +x speaker_unmute.sh


    And then I started the command:



    Code
    ./speaker_unmute.sh


    It's great: the sound is back!


    Now, actually, you will have to integrate these files into doorpi.ini.
    For this, I did this in my doorpi.ini (without Piface card):



    And if I now activate the bell button, I have my smartphone that sounds.
    Then I pick up: I have the sound.
    And then I hang up: the sound cuts.


    It's awesome!


    Pat