Beispiel #1
0
def isMasterMute():
  "is nao sound volume muted?"
  strOutput = system.executeAndGrabOutput( "amixer sget Master | grep 'Front Right: Playback' | cut -d[ -f4 | cut -d] -f1", True );
  strOutput = strOutput.strip();
  bMute = ( strOutput == "off" );
  debug.debug( "isMasterMute: %d (strOutput='%s')" % ( bMute, strOutput ) );
  return bMute;
Beispiel #2
0
def isMasterMute():
    "is nao sound volume muted?"
    strOutput = system.executeAndGrabOutput(
        "amixer sget Master | grep 'Front Right: Playback' | cut -d[ -f4 | cut -d] -f1",
        True)
    strOutput = strOutput.strip()
    bMute = (strOutput == "off")
    debug.debug("isMasterMute: %d (strOutput='%s')" % (bMute, strOutput))
    return bMute
Beispiel #3
0
def getCurrentMasterVolume():
    "get nao master sound system volume (in %)"
    "return 0 on error or problem (not on nao or ...)"
    try:
        ad = naoqitools.myGetProxy('ALAudioDevice')
        nVal = ad.getOutputVolume()
        debug.debug("getCurrentMasterVolume: %d" % (nVal))
        return nVal
    except BaseException, err:
        print("getCurrentMasterVolume: error '%s'" % str(err))

    print("WRN: => using old one using fork and shell!")

    strOutput = system.executeAndGrabOutput(
        "amixer sget Master | grep 'Front Right: Playback' | cut -d[ -f2 | cut -d% -f1",
        True)
    if (strOutput == ''):
        return 0
    nValR = int(strOutput)
    strOutput = system.executeAndGrabOutput(
        "amixer sget Master | grep 'Front Left: Playback' | cut -d[ -f2 | cut -d% -f1",
        True)
    nValL = int(strOutput)
    nVal = (nValR + nValL) / 2
    debug.debug("getCurrentMasterVolume: %d (%d,%d)" % (nVal, nValL, nValR))
    return nVal


# getCurrentMasterVolume - end
Beispiel #4
0
# sound volume (premisse of the robot's class)

def getCurrentMasterVolume():
    "get nao master sound system volume (in %)"
    "return 0 on error or problem (not on nao or ...)"
    try:
        ad = naoqitools.myGetProxy( 'ALAudioDevice' );
        nVal = ad.getOutputVolume();
        debug.debug( "getCurrentMasterVolume: %d" % ( nVal ) );
        return nVal;
    except BaseException, err:
        print( "getCurrentMasterVolume: error '%s'" % str( err ) );
        
    print( "WRN: => using old one using fork and shell!" );
  
    strOutput = system.executeAndGrabOutput( "amixer sget Master | grep 'Front Right: Playback' | cut -d[ -f2 | cut -d% -f1", True );
    if( strOutput == '' ):
        return 0;
    nValR = int( strOutput );
    strOutput = system.executeAndGrabOutput( "amixer sget Master | grep 'Front Left: Playback' | cut -d[ -f2 | cut -d% -f1", True );
    nValL = int( strOutput );
    nVal = ( nValR + nValL ) / 2;
    debug.debug( "getCurrentMasterVolume: %d (%d,%d)" % ( nVal, nValL, nValR ) );
    return nVal;
# getCurrentMasterVolume - end

def setMasterVolume( nVolPercent ):
    "change the master volume (in %)"
    if( nVolPercent < 0 ):
        nVolPercent = 0;
    if( nVolPercent > 100 ):