Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Humanizer #627

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Commits on Jul 21, 2018

  1. tweaking the humanizer

    I just took a look at the humanizer and there a couple of things I do not understand and which are probably not intended to work the way they are doing right now.
    
    First of all both the humanization of the velocity and the pitch in *hydrogen.cpp* feature a negative bias of the random variable. Firstly, a random generated and afterwards a constant value determined by the get_humanize_velocity_value() and the get_random_pitch_factor() is subtracted. Is there a reason for this bias?
    
    In randomizing the pitch the random variable, which is drawn using the getGaussian() function, is only scaled using the fMaxPitchDeviation value but not with the random pitch factor of the corresponding instrument. The latter is only introduced as a negative bias. This does not seem right.
    
    For a better readbility I renamed the input variable of the getGaussian() function into "variance" since this is what it actually is: the variance of the distribution the random variable is drawn from. Also I would propose to use the get_humanize... values as a input to the getGaussian function so it is obvious that the variance will be scaled using the knots for the humanizer.
    
    There are two variables *fMaxPitchDeviation* and *nMaxTimeHumanize* defined in the source and only used for the scaling. I expect these are intended to bound the random variable. Since we are generating Gaussian white noise, the random variable is (in theory) able to take any number between minus and plus infinity. I used the two variables instead to bound the random variable to assure plausible fluctuations. But this might messed up the scaling applied here. I just looked at the humanizer so far and lack the overall knowledge of the internal working of Hydrogen. Could someone take a look at the scaling here?
    
    Last but not least I have a question: What exactly is the *swing* intended to accomplish? It is implemented as a constant and positive additive term to the offset of a note. No randomization or whatsoever takes place here.
    
    correct scaling of the humanizer inputs
    Using integration by substitution on the second moment of a distribution one can verify that the scaling of a random variable by a factor `a` multiplies its standard deviation by `a` and its variance by `a^2`. `var(a*x)=a^2var(x)`
    
    Therefore, the inputs of the knots of the humanizers have to be squared in order to have the same experience as beforehand.
    
    In other words, up to now the behavior was as follows: draw a Gaussian random number with a variance of 0.2 and scale the process by a factor controlled via the rotator buttons, which will scale the variance of the process by the square of their value.
    
    I would vote to streamline this behavior by introducing the right range and scaling to the rotator button itself and to display the variance of the white noise in the info region in Hydrogen after moving the button.
    
    verbose the maximal humanization variance
    The factors 0.2 or 0.3 in the calls to `getGaussian` in the humanization parts do act as an upper bound for the variance of the Gaussian white noise. By assigning those value to an approriately names variable their role becomes much more apparent.
    theGreatWhiteShark committed Jul 21, 2018
    Configuration menu
    Copy the full SHA
    e88c117 View commit details
    Browse the repository at this point in the history
  2. adjust mixerline output for small window sizes

    in small window sizes the phrase "Set humanize velocity parameter" needs some time to run through notification area of the mixer. Thus, one is not able to see the actual value when still rotating the knot.
    
    Instead, I moved the displayed value to the front of the display message to visible at all times.
    theGreatWhiteShark committed Jul 21, 2018
    Configuration menu
    Copy the full SHA
    240eefe View commit details
    Browse the repository at this point in the history
  3. Choosing noise color in masterMixerLine

    The Rotary knob for the **swing** was removed (because I still do not see any use of this variable and no one of the Hydrogen team responds to my questions).
    
    Instead two `QComboBox`s have been added via `LCDCombo` objects. They will be used as drop down menus to select the color of the corresponding noise. Those colors can be indiviually chosen for both the humanization of the velocity and the onset.
    
    The background picture of the master strip of the MixerLine was changed as well to nicely inegrate the changes.
    theGreatWhiteShark committed Jul 21, 2018
    Configuration menu
    Copy the full SHA
    2e0feb6 View commit details
    Browse the repository at this point in the history
  4. handling of the humanization color box signals

    The Hydrogen song does now contain the additional functions `get_humanize_time_color`, `set_humanize_time_color` and the equivalent for the velocity. The internal state is stored in the `__humanize_time_color` and `__humanize_velocity_color` intt variables.
    
    Both states are written and loaded to file properly now.
    
    Every last remaining instance of the swing factor had been removed.
    
    first draft of the noise generating functions
    
    fixing bugs in auxiliary impl of humanizer
    The random seed did have the wrong type causing the random number generator to spit `nan`.
    
    The factor `maximalHumanizationTimeVariance` has been enlarged. Since the resulting random number will be floored, there is absolutely no point in having it set to 1.
    theGreatWhiteShark committed Jul 21, 2018
    Configuration menu
    Copy the full SHA
    378274e View commit details
    Browse the repository at this point in the history
  5. adding Randomizer object for humanization

    Instead of a bunch of inline functions and dozens of global variables holding the states of the different generators of colored noise I introduced an object class `Randomizer`. It will contain interfaces to draw new random numbers as public methods and all states as private ones. To allow a better maintainance I moved
    all code concerning the random number generator in dedicated files `randomizer.cpp` and `randomizer.h`.
    
    The randomizer is now designed to be a proper part of Hydrogen. Each time the `Hydrogen::create_instance()` function is called upon starting up Hydrogen an instance of the Randomizer is created as well using `Randomizer::create_instance()`. During the runs of the audio engine the generated instance will be retrieved using `Randomizer::get_instance()`. This way only one seeded random number generator does exist and every random number, regardless of its color, is drawn from it.
    
    In addition the generators of the Gaussian white and white uniform noise source have been updated.
    - the **Gaussian white noise source** now uses both Gaussian random variables produced by the Box-Muller transformation and relies on the updated uniform white algorithm
    - the **uniform white noise source** was completely reworked and now the algorithm *Ranq1* of the book *Numerical recipes* by Press et al. is used. It is of higher quality and does not produce correlated noise like the `std::rand()` function.
    
    Some description has been added to the pink noise source.
    theGreatWhiteShark committed Jul 21, 2018
    Configuration menu
    Copy the full SHA
    33b87ae View commit details
    Browse the repository at this point in the history
  6. choosing noise color

    the Hydrogen core backend has now been updated to ask the GUI what noise color was chosen by the user. This will affect the noise source the random increment will be drawn from.
    theGreatWhiteShark committed Jul 21, 2018
    Configuration menu
    Copy the full SHA
    2d83ea4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7cbc822 View commit details
    Browse the repository at this point in the history