LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-02-2014, 11:24 PM   #1
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Mplayer volume increasing


I configured my desktop to fire up by RTC. It starts and loads the system. Once system has booted bash script launches mplayer - some kind of alarm clock
The issue is I'd like to get mplayer started not at full load.
I want to increase volume gradually, is it possible to increase volume when mplayer has started already?
 
Old 11-02-2014, 11:52 PM   #2
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
If you are playing an audio file using mplayer command, you can set loudness of the sound using -volume parameter.
Now play an mp3 file using
Code:
mplayer -volume 0 /path/of/audio/theme.mp3
and after that
mplayer -volume 150 /path/of/audio/theme.mp3
You can hear the difference.

If you want to increase the volume gradually. Create a loop and increase volume when it plays the file again.
Code:
i=50
while :
do
i=`expr $i + 10`
mplayer -volume $i /path/of/file.mp3
done
It will play the file until you kill the process. You can use `break` to stop playing file if `$i` reaches at it's sufficient value (you can not bear to listen the sound again).

But if your sound is a 5 minute song and you want it should increase the volume gradually for same file not for the loop.
This may be interesting. I do not know if mplayer provides any option like this.

Last edited by eklavya; 11-03-2014 at 12:27 AM.
 
Old 11-03-2014, 04:13 AM   #3
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Original Poster
Rep: Reputation: 142Reputation: 142
Thanks for reply!
Quote:
Originally Posted by eklavya View Post
But if your sound is a 5 minute song and you want it should increase the volume gradually for same file not for the loop.
This may be interesting. I do not know if mplayer provides any option like this.
Yes, it's exactly what I want to do - increase a volume within a few seconds (10-15 secs)
 
Old 11-03-2014, 04:28 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
Does it have to be mplayer? The sox suite will do this nicely.
0-100% over 5 seconds:
Code:
play mp3file.mp3 fade 5
 
Old 11-03-2014, 05:17 AM   #5
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Original Poster
Rep: Reputation: 142Reputation: 142
Mplayer just ignores "fade". Seems it's impossible for mplayer

Did it for KMix via QDbus. May be it will be interesting for something else:

Code:
#!/bin/bash
for i in `seq 1 33`;
do
    qdbus org.kde.kmix /kmix/KMixWindow/actions/decrease_volume org.qtproject.Qt.QAction.trigger
    sleep 0
done

mplayer /mnt/music/Accept-Predator/Run_Through_The_Night.mp3 -volume 100  > /dev/null 2>&1 &

for i in `seq 1 33`;
do
    qdbus org.kde.kmix /kmix/KMixWindow/actions/increase_volume org.qtproject.Qt.QAction.trigger
    sleep 1
done
script drops volume to zero, starts mplayer and increases volume to 100% within 33 seconds

No need to buy alarm clock

P.S.
Just forgot to mention for GazL: I have no sox installed.

Last edited by Teufel; 11-03-2014 at 05:47 AM.
 
Old 11-03-2014, 06:55 AM   #6
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
Yeah 'fade' is one of the effects sox provides, it won't work on any other command.

You could probably use the lavfi af filter option, something like:
Code:
mplayer -af lavfi=[afade=t=in:ss=0:d=33] file.mp3
The syntax works on 'mpv' (which is what I have installed here), it may be slightly different for original mplayer (which I don't have installed so can't check).

Anyway, if you're happy with your qdbus solution, fair enough. There's more than one way of skinning a cat, as they say.


P.S. 'sox' is quite small and well worth keeping around. Often its much simpler in use than the equivalent mplayer/ffmpeg/libav commands.
 
1 members found this post helpful.
Old 11-03-2014, 02:26 PM   #7
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Original Poster
Rep: Reputation: 142Reputation: 142
Thank you GazL, I think I'll go with mplayer+kmix. I have enough media players installed already
Anyway thanks for your suggestions!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any sw for increasing Audio output volume? prollocks Linux - Software 1 06-13-2011 09:13 AM
How to start mplayer with reduced volume to 70pct ? mplayer -volume ? frenchn00b Linux - General 1 03-29-2008 08:29 AM
Increasing a Logical Volume over a new hard-drive - Possible? rizhun Linux - Hardware 2 04-01-2006 12:56 PM
Increasing a Logical Volume over a new hard-drive - Possible? rizhun Linux - Hardware 2 04-01-2006 10:10 AM
increasing volume ergo_sum Linux - Newbie 4 09-19-2003 04:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration