<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="post-text" itemprop="text">
      <p>hello everyone,<br>
      </p>
      <p>for a raspberrry applicance I need to setup the input volume of
        the microphone programaticaly</p>
      <p>in c++, I can read the actual value (changed if I change it in
        the pa mixer), but as I set it, it does not seem to work... <br>
      </p>
      <p>after I launched my code, I check in the pa panel mixer, the
        volume is not changed</p>
      <p>below, the sources with their chanels and volumes</p>
      <pre style="" class="lang-cpp prettyprint prettyprinted"><code><span class="pln">SOURCE </span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"> </span><span class="str">'alsa_output.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-stereo.monitor'</span><span class="pln"> </span><span class="str">'Monitor of Audio Adapter Analog Stereo'</span><span class="pln">
   </span><span class="pun">(</span><span class="lit">0</span><span class="pun">)=</span><span class="pln"> </span><span class="lit">65536</span><span class="pln">
   </span><span class="pun">(</span><span class="lit">1</span><span class="pun">)=</span><span class="pln"> </span><span class="lit">65536</span><span class="pln">
SOURCE </span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">1</span><span class="pun">]</span><span class="pln"> </span><span class="str">'alsa_input.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-mono'</span><span class="pln"> </span><span class="str">'Audio Adapter Analog Mono'</span><span class="pln">
   </span><span class="pun">(</span><span class="lit">0</span><span class="pun">)=</span><span class="pln"> </span><span class="lit">26281</span><span class="pln">
SOURCE </span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">2</span><span class="pun">]</span><span class="pln"> </span><span class="str">'alsa_output.0.analog-stereo.monitor'</span><span class="pln"> </span><span class="str">'Monitor of bcm2835 ALSA Analog Stereo'</span><span class="pln">
   </span><span class="pun">(</span><span class="lit">0</span><span class="pun">)=</span><span class="pln"> </span><span class="lit">65536</span><span class="pln">
   </span><span class="pun">(</span><span class="lit">1</span><span class="pun">)=</span><span class="pln"> </span><span class="lit">65536</span></code></pre>
      <p>so I try to change volume of source index #1</p>
      <pre style="" class="lang-cpp prettyprint prettyprinted"><code><span class="kwd">void</span><span class="pln"> setVolume</span><span class="pun">(</span><span class="typ">int</span><span class="pln"> index</span><span class="pun">,</span><span class="typ">int</span><span class="pln"> volume</span><span class="pun">)</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
    pa_operation</span><span class="pun">*</span><span class="pln"> o</span><span class="pun">;</span><span class="pln">
    currentVolume</span><span class="pun">.</span><span class="pln">values</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]=</span><span class="pln">volume</span><span class="pun">;</span><span class="pln">
    </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!(</span><span class="pln">o </span><span class="pun">=</span><span class="pln"> pa_context_set_source_output_volume</span><span class="pun">(</span><span class="pln">context</span><span class="pun">,</span><span class="pln"> index</span><span class="pun">,</span><span class="pln"> </span><span class="pun">&</span><span class="pln">currentVolume</span><span class="pun">,</span><span class="pln"> NULL</span><span class="pun">,</span><span class="pln"> NULL</span><span class="pun">)))</span><span class="pln"> 
    </span><span class="pun">{</span><span class="pln">
        printf</span><span class="pun">(</span><span class="str">"pa_context_set_source_output_volume() failed"</span><span class="pun">);</span><span class="pln">
        </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
    printf</span><span class="pun">(</span><span class="str">"new volume: %d\n"</span><span class="pun">,</span><span class="pln">currentVolume</span><span class="pun">.</span><span class="pln">values</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]);</span><span class="pln">
    pa_operation_unref</span><span class="pun">(</span><span class="pln">o</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span></code></pre>
      <p>please can someone help ?</p>
      <p>thanks</p>
    </div>
  <br /> <table style="border-top: 1px solid #D3D4DE;">
        <tr>
      <td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/2016/icons/icon-envelope-tick-round-orange_184x116-v1.png" height="29px" /></a></td>
                <td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Garanti sans virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>               </td>
        </tr>
</table>
</body>
</html>