justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: Recently i'd asked about formula used in RS5k to map gain to velocity (askjf.com/index.php?q=6883s and based on your reply wrote a function to adjust velocity by dB. But what i found out was that although the calculated velocity values at 6 dB velocity intervals (i.e. 2, 4, 16, 32, 64, 127) did match the Loudness Meter JSFX readings, the intermediate values did not.Turns out that according to the Loudness Meter output, within each range gain isn't mapped to velocity uniformly, therefore division of 6 by the number of velocity units in the range (e.g. 6/16, 6/32, 6/64) to find out dB per velocity unit doesn't produce accurate results. The diviation could be up to 6 velocity units. So my question is if there's a formula you would be able share which takes into account this lack of uniformity in the mapping or if you could explain how it's calculated.
Asked by Buy One (95.134.60.x) on October 15 2023, 2:00pm
Reply on October 15 2023, 2:14pm (edited at October 15 2023, 2:22pm):
    are you interpolating between these steps in dB or as a scale that is later converted to dB? Sounds like you're doing the former and you should be doing the latter. e.g.
    max_sc = 1; // +0 dB, aka 10^(0/20)
    min_sc = 0; // -inf dB
    max_v = 127;
    min_v = 1;
    
    sc = min_sc + (noteval - min_v) / (max_v - min_v) * (max_sc - min_sc);
    gain_db = log10(sc)*20; // convert scale to dB
    
    If you want to see the gain difference for each step, calculate sc and gain_db for the steps then look at the difference between each step's gain_db.


Comments:
  • Posted by Buy One (95.134.60.x) on October 15 2023, 5:55pm:
    Thank you, this helped a lot

  • Posted by Justin on October 15 2023, 7:47pm:
    np! also beware if sc ends up as 0 log10(0) will give you a NaN or whatnot

  • Posted by Buy One (95.134.60.x) on October 16 2023, 7:59am:
    OK


Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2024 Justin Frankel. | RSS