ideoforms / AbletonOSC

Control Ableton Live 11 via Open Sound Control (OSC)
MIT License
429 stars 70 forks source link

Add support for setting gain values in dB #44

Open ideoforms opened 1 year ago

ideoforms commented 1 year ago

Currently, all volume levels are floats (0..1). The API should ideally expose the ability to set gain values in dB, which will require an internal mapping from db to linear (as provided by @marcobn), and vice versa.

zbynekdrlik commented 1 year ago

I like to have shown db value for volume for fader in touchosc mapped to track volume. Will this be possible?

marcobn commented 1 year ago

See here:

Def db2value(db):

conversion from decibel to linear scale in track volume

   if db <= 6 and db >= -18:
          return (db+34)/40
   elif db < -18 and db >= -41:
          alpha = 799.503788
          beta = 12630.61132
          gamma = 201.871345
          delta = 399.751894
          return -(np.sqrt(-alpha*db - beta) - gamma) / delta
   elif db < -41:
          alpha = 70.
          beta = 118.426374
          gamma = 7504./5567.
          return np.power(((db+alpha)/beta),gamma)
   else:
          print('out of bounds')

def value2db(vl):

conversion from linear to decibel scale in track volume

   if vl <= 1 and vl >= 0.4:
          return 40*vl -34
   elif vl < 0.4 and vl >= 0.15:
          alpha = 799.503788
          beta = 12630.61132
          gamma = 201.871345
          delta = 399.751894
          return -((delta*vl - gamma)**2 + beta)/alpha
   elif vl < 0.15:
          alpha = 70.
          beta = 118.426374
          gamma = 7504./5567.
          return beta*np.power(vl,1/gamma) - alpha
   else:
          print('out of bounds')

Marco Buongiorno Nardelli (he/him) Regents Professor, University of North Texas External Professor, Santa Fe Institute CEMI, Center for Experimental Music and Intermedia iARTA, Initiative for Advanced Research in Technology and the Arts ArtSciLab, ATEC @ the University of Texas at Dallas http://ermes.unt.edu http://www.materialssoundmusic.com

From: zbynekdrlik @.> Date: Tuesday, March 28, 2023 at 2:40 PM To: ideoforms/AbletonOSC @.> Cc: Buongiorno Nardelli, Marco @.>, Mention @.> Subject: [EXT] Re: [ideoforms/AbletonOSC] Add support for setting gain values in dB (Issue #44)

I like to have shown db value for volume for fader in touchosc mapped to track volume. Will this be possible?

— Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fideoforms%2FAbletonOSC%2Fissues%2F44%23issuecomment-1487496575&data=05%7C01%7CMarco.BuongiornoNardelli%40unt.edu%7Cd381397646ef4ce0271608db2fc453b4%7C70de199207c6480fa318a1afcba03983%7C0%7C0%7C638156292506150869%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WqNnZt1Avm9pmTGX%2FRwmPVj%2FeoytbWUUdjn0AG8oVN8%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFQOHKQYRAO2VVDCO7QT65TW6M5D3ANCNFSM6AAAAAATXJ7KDM&data=05%7C01%7CMarco.BuongiornoNardelli%40unt.edu%7Cd381397646ef4ce0271608db2fc453b4%7C70de199207c6480fa318a1afcba03983%7C0%7C0%7C638156292506307101%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DuwVYHuRFc5Nwx9reBdTVNyRLPjfiVBOfl67zByWkxk%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>