Welcome to the Rockbox Technical Forums!
> 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.
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.
--Bilgus 12-2016TIMEOUT = rb.HZ/4SOUND_VOLUME = 0 --This is a CONSTANTlocal 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 endlocal value = nillocal 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 valueendlocal volume = cfg_num_setting("volume") if volume == nil then volume = rb.sound_default(SOUND_VOLUME) endlocal 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
/Bilgus_Keyfade.lua:31: attempt to call field 'pcm_is_playing' (a nil value)stack traceback: /Bilgus_Keyfade.lua:31: in main chunk
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
AUDIO_STATUS_PLAY = 1 if rb.audio_status() == AUDIO_STATUS_PLAY then
Page created in 0.055 seconds with 16 queries.