Decrease / Increase Music Volume

  • #1, by marvelSaturday, 13. July 2013, 18:07 12 years ago
    I would need a little script for the + and - key to control the volume of the music. smile

    Key Killer

    599 Posts


  • #2, by superscheibenkleisteSaturday, 13. July 2013, 18:23 12 years ago
    Dazu brauchst du doch kein Script :-)
    Geh auf Tastenaktionen -> + / - -> Lautstärke ändern -> Musik -> Operator +/-
    Oder willste was Anderes?
    Superscheibenkleiste

    Newbie

    21 Posts

  • #3, by marvelSaturday, 13. July 2013, 19:22 12 years ago
    @superscheibenkleiste: Bitte in Englisch antworten. Sonst wirds für alle englischsprachigen User schwierig wink

    @all: I cannot control the music volume via the action part. When i use the action part "change volume", nothing happens when i press the keys. So i thought lua could maybe help wink Also i thought about a more fluid change of the volume... not in steps (action part)

    Key Killer

    599 Posts

  • #4, by afrlmeSaturday, 13. July 2013, 21:28 12 years ago
    you mean to fade in/out the volume smoothly/gradually as opposed to directly changing from x amount to x amount?

    I recently got my thinking cap on about the mainLoop function & that we don't necessarily need to use it for creating loops. I completely forgot about the while & repeat functions of Lua.

    In other words you could create a function which you can call along with an included variable to control the function....

    -- let's create a function to smoothly increase/decrease music volume without using mainLoop function
    function setMusicVol(sta, vol)
     if sta == 1 then
      repeat
       if getVolume(eMusicVolume) > vol then setVolume(eMusicVolume, getVolume(eMusicVolume) - 1) end
       --print("volume:" .. getVolume(eMusicVolume)) --testing only!
      until getVolume(eMusicVolume) <= vol
     elseif sta == 2 then
      repeat
       if getVolume(eMusicVolume) < vol then setVolume(eMusicVolume, getVolume(eMusicVolume) + 1) end
       --print("volume:" .. getVolume(eMusicVolume)) --testing only!
      until getVolume(eMusicVolume) >= vol
     end
    end
    


    call it via an execute a script action part > setMusicVol(sta, vol)
    sta (state) integer value (1=decrease volume, 2=increase volume)
    vol (volume) integer value (add a number between 0 & 100)

    P.S: it fades really quick so if you wanted to slow it down you would have to create an pause action part which toggles a condition but I'm not going to show how to do that for the sake of keeping this simple.

    Imperator

    7285 Posts

  • #5, by afrlmeSaturday, 13. July 2013, 23:13 12 years ago
    & something without fading...
    for you to manually alter with +/- key input commands.

    -- let's create the increase/decrease music volume function
    function adjMusicVol(sta, val)
     if sta == 1 then
      if getVolume(eMusicVolume) > 0 then setVolume(eMusicVolume, getVolume(eMusicVolume) - val) end
      if getVolume(eMusicVolume) < 0 then setVolume(eMusicVolume, 0) end
     elseif sta == 2 then
       if getVolume(eMusicVolume) < 100 then setVolume(eMusicVolume, getVolume(eMusicVolume) + val) end
       if getVolume(eMusicVolume) > 100 then setVolume(eMusicVolume, 100) end
     end
    end
    


    execute a script > adjMusicVol(sta, val)

    sta = integer value (1=decrease, 2=increase)
    val = integer value (this controls how much volume increases/decreases - I recommend value between 1 & 10)

    Imperator

    7285 Posts

  • #6, by marvelSunday, 14. July 2013, 14:44 12 years ago
    Thanks for the scripts lee. Thats fantastic.

    You know what? The + and - Keys didnt work to increase/decrease the music... because i tried to use the keys from the numeral part on the right of my laptop-keyboard. ^^ The MAIN Keys are working.

    Key Killer

    599 Posts

  • #7, by afrlmeSunday, 14. July 2013, 14:53 12 years ago
    Thanks for the scripts lee. Thats fantastic.

    You know what? The + and - Keys didnt work to increase/decrease the music... because i tried to use the keys from the numeral part on the right of my laptop-keyboard. ^^ The MAIN Keys are working.


    haha razz

    yes, speaking of that, we could do with adding some more keys to the key input such as ctrl, alt, shift etc & the numerical keys.
    but people who would use numerical keys should take into consideration that not all people on laptops/netbooks or people using small keyboards have easy access or access to the numpad.

    Imperator

    7285 Posts