jnuyens / freedomev

FreedomEV repository. Unlocking the full potential of Linux on your EV!
GNU General Public License v3.0
185 stars 28 forks source link

Speed sensitive volume #8

Closed lau85 closed 5 years ago

lau85 commented 5 years ago

I think it is "must have" feature. Wondering why it is not included as standard. Wrote it yesterday and only tested today on a single ride. Volume formula can be improved as everything else in this script. Use at your own risk.

jnuyens commented 5 years ago

This is a great addition, indeed! Also, your code is very nice and gives some illustrations to optimise the existing stuff! Thanks a lot!

ramonsmits commented 5 years ago

Can you explain the math and behavior behind this? Trying to understand when the functions are called and how it calculates the right value which also depends on the configured volume level.

Does this mean that the UI volume level is fixed and is a different value?

lau85 commented 5 years ago

It reads vehicle speed and volume when script is started. We will have it as INIT_SPEED and INIT_VOLUME for later. Also PREV_VOLUME(previous) is set to the same value as INIT_VOLUME. Then every second it does: If volume have been changed from GUI. (CURRENT_VOLUME is different from PREV_VOLUME) it updates INIT_SPEED and INIT_VOLUME to current values. If volume is the same (no changes from GUI), but speed is different, increases/decreases volume using formula NEW_SPEED = INIT_SPEED + (0.333 * (CURRENT_SPEED - INIT_SPEED)/10000). 10000 there is for 10 miles/h.

Made 200 km today. I can say that the script is working pretty well. There was only one situation when volume was increased unexpectedly. Apart from that single case, I couldn't really if it is working at all. :)

On Thu, Mar 7, 2019 at 4:31 PM Ramon Smits notifications@github.com wrote:

Can you explain the math and behavior behind this? Trying to understand when the functions are called and how it calculates the right value which also depends on the configured volume level.

Does this mean that the UI volume level is fixed and is a different value?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jnuyens/freedomev/pull/8#issuecomment-470547650, or mute the thread https://github.com/notifications/unsubscribe-auth/At-qUOpok74JSeBSC92Kyqp3Ks-J39cwks5vUSLagaJpZM4bhZ8p .

lau85 commented 5 years ago

sorry, should be NEW_VOLUME = INIT_VOLUME + (0.333 * (CURRENT_SPEED - INIT_SPEED)/10000).

ramonsmits commented 5 years ago

Ok, I think I understand but you would see the volume indicator to slightly up/down right?

What happens when you adjust the volume on the highway? Lets see I turn the volume down on the highway and then slow down. Would this slightly keep decreasing the actual volume too?

I see it is a while loop and seems to adjust every second right? I'm not familiar with this scripting language.

ramonsmits commented 5 years ago

By the way, instead of adding .333 should this be a multiplication as I think volume due to wind noise being exponential?

lau85 commented 5 years ago

If you change volume on high speed, it updates unit values and will lower it automatically if you slow down. For now it is linear. And only tested on Model S 2013 with premium audio. Need to do more real life testing. As always, time is an issue.

On Thu, Mar 7, 2019, 7:05 PM Ramon Smits notifications@github.com wrote:

By the way, instead of adding .333 should this be a multiplication as I think volume due to wind noise being exponential?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jnuyens/freedomev/pull/8#issuecomment-470609830, or mute the thread https://github.com/notifications/unsubscribe-auth/At-qUPSSFvfv35mbR_pn8jyJhOoo9hB-ks5vUUbOgaJpZM4bhZ8p .

jnuyens commented 5 years ago

I'm also testing on my Model X, fixed some minor issues, it seems to work very nice :) Saturday, we have a 11 hour drive across EU ahead, so plenty of testing opportunities at highway speeds.