Rockbox Technical Forums

Rockbox Development => Feature Ideas => Topic started by: chrisjj on April 26, 2010, 04:54:45 PM

Title: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: chrisjj on April 26, 2010, 04:54:45 PM
Is there a plug-in that can do audio fade-out upon playback?

Thanks.
Title: Re: Plug-in for audio fade?
Post by: Chronon on April 26, 2010, 05:01:05 PM
I think you need to elaborate more on what you want.  I'm not sure what "audio fade-out upon playback" means.
Title: Re: Plug-in for audio fade?
Post by: karashata on April 26, 2010, 05:03:26 PM
There isn't a plugin, but there is a crossfade setting you might check out and see if it will do what you want. To enable it, from the main menu, go to Settings -> Playback Settings -> Crossfade -> Enable Crossfade, and choose a mode for crossfade to use. If you want to change the various settings related to crossfade you can do that as well within the Crossfade submenu until you get it configured just how you like it.

I hope that helps!
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 26, 2010, 06:01:39 PM
> I think you need to elaborate more on what you want.  I'm not sure what "audio fade-out upon playback" means.

By audio fade-out I mean the effect wherein volume decreases steadily to zero, e.g. at the end of many pop songs.

I want to be able to add this effect during rockbox playback of a track.

> There isn't a plugin

Ah. Thanks.

> but there is a crossfade setting you might check out and see if it will do what you want.

Thanks but that does only crossfade not plain fade AFAICT.

The standard "Fade out on Stop/pause" might do if it could altered for greater duration e.g. 3s rather than the current ~0.5s. I have asked in a separate thread.

Title: Re: Plug-in for audio fade?
Post by: saratoga on April 26, 2010, 06:34:30 PM
Thanks but wtat does only crossfade not plain fade AFAICT.


The standard "Fade out on Stop/pause" might do if it could altered for greater duration e.g. 3s rather than the current ~0.5s. I have asked in a separate thread.

Never tried it but the manual suggests that crossfade does what you want.  Have you tried it?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 26, 2010, 06:57:34 PM
Never tried it but the manual suggests that crossfade does what you want.  Have you tried it?
Yes. I find it does only what my reading of the manual suggests - crossfade between two tracks, not fade out from one track to silence. Thanks though for the suggestion S.
Title: Re: Plug-in for audio fade?
Post by: evilnick on April 26, 2010, 07:09:32 PM
A possible workaround would be to have a file of total silence and add that to the playlist after the song you want to fade out, then use crossfade.

Kind of a kludge but it should work.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 26, 2010, 07:31:04 PM
Thanks, but that would leave the crossfade occuring on every other track transition. "Fade on Stop/pause" would be acceptable only because I don't need an unfaded Stop/pause.
Title: Re: Plug-in for audio fade?
Post by: Llorean on April 26, 2010, 10:22:24 PM
Considering Rockbox isn't a DJing tool, but rather a playback tool for portable devices for listening, features like this generally aren't a high priority (and often will be weighed very critically against any additional costs they might bring with them).
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 26, 2010, 10:33:06 PM
Additional costs from a plug-in??
Title: Re: Plug-in for audio fade?
Post by: Llorean on April 26, 2010, 10:35:50 PM
How many audio manipulation plugins do you see currently?

I was simply discussing the general situation, anyway.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 26, 2010, 10:45:28 PM
> How many audio manipulation plugins do you see currently?

None so far. Did I miss any?? :)

Perhaps the plug-in API doesn't go for that much. Fair enough.

> I was simply discussing the general situation, anyway.

OK. Mine wasn't a request for added functionality.
Title: Re: Plug-in for audio fade?
Post by: soap on April 27, 2010, 01:05:54 AM
Do you want to queue up one track at a time and have it fade to stop?
Or do you want to fade every individual track in a multi-track playlist to silence before starting the next track?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 05:41:25 AM
Do you want to queue up one track at a time and have it fade to stop?
Or do you want to fade every individual track in a multi-track playlist to silence before starting the next track?

I want just "to add this effect during rockbox playback of a track." I .e. on command, RB does fade effect to silence.

EDIT: There needs to be a restore, ideally upon repeat of that command and/or pause/stop and/or track switch.
Title: Re: Plug-in for audio fade?
Post by: soap on April 27, 2010, 06:37:26 AM
I am having a problem understanding what you want.
I am unable to parse your last reply.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 07:02:44 AM
I am having a problem understanding what you want.
I am unable to parse your last reply.

Now edited.
Title: Re: Plug-in for audio fade?
Post by: soap on April 27, 2010, 07:05:54 AM
I am having a problem understanding what you want.
I am unable to parse your last reply.

Now edited.

No better for me.

How about rephrasing?

And please directly answer my two questions - it will help me understand where you are coming from.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 07:19:01 AM
>> I want just "to add this effect during rockbox playback of a track." I .e. on command, RB does fade effect to silence.
> No better for me.
> How about rephrasing?

OK...

I want a command (e.g. single keypress) that when issued triggers RB to do a fade to silence. I.e. to take the volume of the audio steadily down to zero.

>> And please directly answer my two questions - it will help me understand where you are coming from.

OK:

> Do you want to queue up one track at a time and have it fade to stop?

No.

> Or do you want to fade every individual track in a multi-track playlist to silence before starting the next track?

No.

Thanks for your patience! :)
Title: Re: Plug-in for audio fade?
Post by: linuxstb on April 27, 2010, 07:26:12 AM
chrisjj,

So you want a "mute" feature? 

i.e. you press a button, the music fades to silence, but continues playing silently?  You then press the same button again to un-mute it?

Dave.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 12:35:42 PM
> you press a button, the music fades to silence

Yes.

> but continues playing silently?

Actually not necessary.

> You then press the same button again to un-mute it?

Actually not necessary. E.g. auto-unmute on track switch or Play would be OK.
Title: Re: Plug-in for audio fade?
Post by: karashata on April 27, 2010, 12:44:29 PM
So... What you want then is an on-demand fadeout at the end of a track when you press a button..?

Since demand for such a feature is likely to be very, very low, you'll likely have to figure out how to code something like that yourself, or find a developer who would be interested in working on something like this... (Something that might be rather difficult, but who knows..? One of the developers might actually find something like that interesting...)

In any case, it might be a good idea to look through the docs index and look through some of the wiki articles on how to download the source code, how to set up a build environment, and how to compile the firmware... Of course, this all assumes you have some knowledge of C programming so you could actually write the code to add such a feature... You could probably borrow some of the code from the fadeout on stop/pause, tweaked a little to do what you want.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 12:57:01 PM
> So... What you want then is an on-demand fadeout at the end of a track when you press a button..?

No. What I want is an on-demand fade-out when I press a button.

> Since demand for such a feature is likely to be very, very low, you'll likely have
> to figure out how to code something like that yourself, or find a developer

Well first it seems a good idea to get the answer to this question.

Title: Re: Plug-in for audio fade?
Post by: Llorean on April 27, 2010, 12:58:43 PM
So why exactly doesn't "Fade on stop/pause" work for this?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 01:05:32 PM
So why exactly doesn't "Fade on stop/pause" work for this?

As I said:

Quote
The standard "Fade out on Stop/pause" might do if it could altered for greater duration e.g. 3s rather than the current ~0.5s.

I asked the question because if the answer is "Yes", I'd expect such a plug-in to offer that flexibility.
Title: Re: Plug-in for audio fade?
Post by: karashata on April 27, 2010, 01:08:19 PM
Well, feel free to download the source code and modify the fadeout duration if you feel it needs to be longer. I'm not sure the developers want to make it longer by default, and making it a user-configurable setting...

Actually, would anything be wrong with making that a user-configurable setting if it was done effectively..?
Title: Re: Plug-in for audio fade?
Post by: Llorean on April 27, 2010, 01:16:38 PM
"Might do" is different from "will do" though. If you added a duration option to fade on stop/pause, what else would be missing?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 01:40:39 PM
> "Might do" is different from "will do" though.

Agreed :)

> If you added a duration option to fade on stop/pause, what else would be missing?

Normal (iimediate) "Play" - I just discovered that "Fade on stop/pause" actually does Fade on stop/pause & play, whereas I need Play to be immediate.

Title: Re: Plug-in for audio fade?
Post by: Llorean on April 27, 2010, 01:47:47 PM
That's not a question.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 01:52:11 PM
I refer to the OP! :)
Title: Re: Plug-in for audio fade?
Post by: Llorean on April 27, 2010, 01:57:58 PM
Then you shouldn't quote a different post.

Please, be explicit about what you're saying/asking. Do not use pronouns like "this" to reference things outside of the post you're writing unless it's a specific response to a quote you're including, or the post above it. Otherwise it makes what you're saying nearly impossible to follow.

At this point in time, what exactly are you asking? You've been told that no plugin exists currently to do what you want, you've been told how you could accomplish similar effect and that you'd otherwise have to edit the source code. But you're now referring to some mystery unanswered question.
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 05:00:14 PM
> "Might do" is different from "will do" though.

Agreed :)

> If you added a duration option to fade on stop/pause, what else would be missing?

Normal (immediate) "Play" - I just discovered that "Fade on stop/pause" actually does Fade on stop/pause & play, whereas I need Play to remain immediate.

> You've been told that no plugin exists currently to do what you want

So I have - apologies.

> you've been told how you could accomplish similar effect

Crossfade? The snag with that is it is not on-command - once enabled, it applies to all track switches.

> and that you'd otherwise have to edit the source code.

I'll come back to that possibility when I've learned more. Thanks!

Title: Re: Plug-in for audio fade?
Post by: soap on April 27, 2010, 05:37:08 PM
> you've been told how you could accomplish similar effect

Crossfade? The snag with that is it is not on-command - once enabled, it applies to all track switches.

Noticing the emphasis on "on-command" I need to clarify one question:
Are you saying you want fade-to-pause/stop assigned to a button independent of the normal pause/stop button so that you can fade with one button and not fade with another?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 06:13:11 PM
> Noticing the emphasis on "on-command" I need to clarify one question:
> Are you saying you want fade-to-pause/stop assigned to a button
> independent of the normal pause/stop button so that you can
> fade with one button and not fade with another?

No I'm not saying that. But for the fact fade-to-pause/stop mode affects Play, then I'd need only the fade period lengthened for my requirements to be fully met by just the normal pause/stop button.
Title: Re: Plug-in for audio fade?
Post by: soap on April 27, 2010, 06:27:29 PM
So, just to be sure I'm clear, a setting that when enabled turns the normal "abrupt" stop/pause into a gentle fade out stop/pause?  But no fade in.

Correct?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 06:41:55 PM
> So, just to be sure I'm clear, a setting that when enabled turns the
> normal "abrupt" stop/pause into a gentle fade out stop/pause?  But no fade in.

Yes, except there's no requirement for this to be on a setting -  I'd be happy with this being a build option.
Title: Re: Plug-in for audio fade?
Post by: soap on April 27, 2010, 08:13:55 PM
Rockbox does not tend to do build-time options.  (Though one could obviously tweak the code in such a manner.)

What it sounds like an agreeable option for you would be is to expand on the previously discussed "Fade on stop / pause" option.  An expansion which expanded the length of fade and added an option to Fade on stop / pause, play, or both .

Does this sound like the idea in a nutshell?  (Not saying it will get done, but at least we can clearly define the goal)?
Title: Re: Plug-in for audio fade?
Post by: chrisjj on April 27, 2010, 08:44:22 PM
> What it sounds like an agreeable option for you would be is to expand on the previously discussed "Fade on stop /
> pause" option.  An expansion which expanded the length of fade and added an option to Fade on stop / pause, play, or both .
>
> Does this sound like the idea in a nutshell?

That would certainly meet my requirements.

But perhaps the following would simpler and meet more of the requirements of others:

Setting for duration of "Fade on stop/pause" up
Setting for duration of "Fade on stop/pause" down.

And perhaps the same time would be a good time to improve both the UI label "Fade on stop/pause" and the CGF label "volume fade", changing to "Fade on stop/pause/play."

> (Not saying it will get done, but at least we can clearly define the goal)?

Sure!
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: soap on April 28, 2010, 08:41:39 PM
Ok, I don't feel the meta discussion on quoting is needed, nor appropriate, in this thread and I'm going to shit-can it.

Quote abuse (or lack of quoting) is such a rare event that I also don't feel it needs stickied, and suggest that staff PM "offenders" in the future and not clutter an otherwise functional thread.

Two posts on the quoting topic is sufficient.  Eight is outright silly.

Edit:  PM me if you have good reason to see this thread unlocked.  I personally feel the original topic has reached a conclusion / agreement.

Title: Re: Plug-in for audio fade?
Post by: chrisjj on December 16, 2016, 11:06:51 PM
I want a command (e.g. single keypress) that when issued triggers RB to do a fade to silence. I.e. to take the volume of the audio steadily down to zero.

It seems Crossfade on manual would do this for me https://archive.is/KEfsp#selection-515.0-520.0 . However crossfade seems brokens at the moment http://forums.rockbox.org/index.php/topic,51605.0.html .
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: Bilgus on December 28, 2016, 03:50:11 PM
And A lua x-mas present for you as well  :D

Code: [Select]
--Bilgus 12-2016
TIMEOUT = rb.HZ/4
SOUND_VOLUME = 0 --This is a CONSTANT
local vol_min = -60 --rb.sound_min(SOUND_VOLUME)

function cfg_num_setting(str_name)
local file = io.open(rb.ROCKBOX_DIR .. "/config.cfg", "r")
    if not file then
        return nil
    end
local value = nil
local contents = file:read("*all")

    i, j = string.find(contents, str_name .. ":")
    if j ~= nil then
        file:seek ("set", rb.atoi(j))
        value = file:read ("*num")
    end
    file:close() -- GC takes care of this if you would've forgotten it
    return value
end

local volume = cfg_num_setting("volume")
    if volume == nil then
        volume = rb.sound_default(SOUND_VOLUME)
    end

local vol_orig = volume


    if rb.pcm_is_playing() then
        while (volume > vol_min) do
            rb.sleep(TIMEOUT)
            rb.yield()
            volume = volume - 1
            rb.sound_set(SOUND_VOLUME, volume);
        end
        rb.audio_pause()
        rb.sleep(rb.HZ)
        rb.sound_set(SOUND_VOLUME, vol_orig); -- Set back to original so it doesn't get overwritten in config.cfg
        os.exit()

    else
        volume = vol_min
        rb.sound_set(SOUND_VOLUME, volume);
        rb.sleep(rb.HZ)
        rb.audio_resume()
        while (volume < vol_orig) do
            rb.sleep(TIMEOUT)
            rb.yield()
            volume = volume + 1
            rb.sound_set(SOUND_VOLUME, volume);
        end
        rb.sound_set(SOUND_VOLUME, vol_orig);

        os.exit()
    end
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: chrisjj on December 28, 2016, 07:49:01 PM
Thanks. On the ZEN simulator, that Lua script gives me this error in the GUI http://i.imgur.com/EGgZmmJ.png and the console:

Code: [Select]
/Bilgus_Keyfade.lua:31: attempt to call field 'pcm_is_playing' (a nil value)
stack traceback:
        /Bilgus_Keyfade.lua:31: in main chunk
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: Bilgus on December 28, 2016, 08:31:46 PM
just tried downloading the file and installed on the zen sim it worked fine, make sure it has 'if rb.pcm_is_playing() then'
if you are in doubt take a screen shot of the file open on your pc
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: chrisjj on December 28, 2016, 08:37:59 PM
just tried downloading the file and installed on the zen sim it worked fine,

Coo. I get the fail even on the default config.

make sure it has 'if rb.pcm_is_playing() then' if you are in doubt take a screen shot of the file open on your pc

No doubt, but here it is anyway: http://i.imgur.com/VHEEbcB.png
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: Bilgus on December 28, 2016, 10:11:15 PM
weird  maybe you don't have that function available???, What version is the rom on the sim you are using?
 try replacing   'if rb.pcm_is_playing() then'
with
Code: [Select]
AUDIO_STATUS_PLAY = 1
    if rb.audio_status() == AUDIO_STATUS_PLAY then
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: Bilgus on December 29, 2016, 03:45:46 PM
I'm working on a configurable fade to stop fade to play plugin now..
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: chrisjj on January 03, 2017, 08:08:51 AM
weird  maybe you don't have that function available???

Same on iPod Video sim: http://i.imgur.com/kAgBC1L.png

, What version is the rom on the sim you are using?

I'm not aware of using any Lua ROM. I'm just selecting your .lua file.

try replacing   'if rb.pcm_is_playing() then'
with
Code: [Select]
AUDIO_STATUS_PLAY = 1
    if rb.audio_status() == AUDIO_STATUS_PLAY then

On ZEN simulator, that fixes it. First run fades to zero. Second fades to set volume.

I did once hear the fade down start with a jump for the set volume of about -20 to a louder volume, before starting the the fade.

And the script gives this error http://i.imgur.com/YcvQeBH.png

Thanks!
Title: Re: "Fade on stop/pause" duration control (was: Plug-in for audio fade?)
Post by: chrisjj on January 11, 2017, 07:53:58 PM
weird  maybe you don't have that function available???

Same on iPod Video sim: http://i.imgur.com/kAgBC1L.png


FTR, here's the export from the Windows ZEN sim (3ee7972-161218, built by rasher http://rasher.dk/rockbox/simulator/) on which this .lua gives an error, confirming the function is missing: http://i.imgur.com/GiG9m9z.png

Here's the export from the ZEN device (custom build from pamaury, 3cda546d5-170111) on which this .lua doesn't gives an error, showing the function present: http://i.imgur.com/5r4wqxl.png.

I'd guess this function is a recent addition.