Invert polarity of sampler



  • @Christoph-Hart tell me you did it (praying emoji)



  • There you go:

    HiseSnippet 1094.3oc6X0saaTDEdV6rTrKopEUg3xUQbgMpDrSCkJUghyO1UVsIwxaZJ2UMY2yZOJ6NyxryFhAgDuFvSQuEtrWwc7JviPeCfyLqc10ESvtpMf.uJWj47yLey47cNyIomT3AIIBIwpxQihAh06Y6NhqFt6PJiS5tGw551cR4mN5HHQQ1YTLMIA7IVVken1.qJqPLeubqcngTtGjKhPNVv7fGyhXpbo8Z8HVXXGpObDKpf0a1pqmfuqHTjhforcCRL06T5.3.p1rR1Dq2osOSIjtJpBRHVqrivej6PwWyyr+XVB6jPPunIwE2nLwcDg9ZDqkR1cHKzu2jKcBA2zd4gfxYgfaauOymcg77PwMMJbx8nX7vpzkAulEgWi4FdjBnakLzgfP3mFRUSiLc5XrBlfOEx5xU.OgoFULc8OJbukcOlxa3rwaoYfWLQ81FuiS9qZ2NH.7T4fcE6Ne4Ual9FYP451tLNXJGM.4CLqcdJ8Lv4g.Gj5fZy+phxe6m+kecdKJim6hxC8T3wejjxShEISswtPD6HAWGQxE9jDniD9p95rbQ46JnxYp5ka0AujyzGWpJUZnKaGIR4ponGkm6bxBzbXkkMGLvs77A2YDAs58mdg4lHMNJNDZyOCBEnDMFee68f.ZZnZhzo406K3h3gBNyqXRuOnjrAC.YQrOyKz1JE9ZRtja2pODBzhD3Op0iQhGUhwI30LVzb9iEWV95CsyfqitXz4+FM0K++yl58EoJFev9TjndNwx9fzHWrWpGfHgygP7frsJo6GlstgdcVyTtuYwuieiU1Tu1ZrxlST959vwFKe33MxCGMtRe33MZ2maY65IYwpbMY0wZ1RugX2QWPofoATlGjRAV1XFNQ4bFU5DqM14Kb1UnqxUqS88eDWbRs0L6xZ2woA9S8GrZUigqm.p9T9.nFJ9t2Sqa8lSos1ZIoAAryQOW6EOeMstUqFjx8z4PGA+.gBNjWqd0usZkPgGMzQDDf9gPHaOF.piogoPs5Nep9Hb9XmMZr48w8wA+1Gur3eYg9jv3pTcnw4ZwZlE1mpV1lUu9Cp9cUcd0iMHH6beEc5qtTDFBxYpVWdHuLGqwSiNAj2AimHtuvPLWMMAn57Q.7xxDELTv6xYpCigKVmEEmHoA4hKXQQ42qhRMWmYXVtnYzLbL6PyEGaNZpxvDuwXlnaHyGIbLjpcMaC4gXhGWTw98AsHOo6dTEcx1f6HdJwfTwzwGq8fyv9TYD7J3TEImpDwFaihwlL5p+q82dnmOoO7nI+RhBhcYeiAI+3On+9oshnmmCryZkwY0us7hm+uigyZ9VZ3rMVNb1xgyVNb1bLb1UwYDQ8jhm4k0RUykeWiD7dyM+uypXuudsSyI8R0wlHblim44oC1eBFclsGarvdb2E1iMWXO9rE1i6svd74KrG2+R7POf21oJQTVoGJnWayaXVVs4Tj4ZX4j+.3oh2ZM
    

    This is the most boring example you'll ever get - if it works correctly, you should hear nothing, because the two sine waves cancel each other out πŸ™‚

    The interesting part is this script:

    const var phase = Content.addKnob("Phase", 0, 0);
    phase.setRange(0, 360, 0.1);
    phase.set("suffix", "Β°");
    function onNoteOn()
    {
        local offset = phase.getValue() / 360 * 2048;
        Message.setStartOffset(parseInt(offset));
    }
     function onNoteOff()
    {
    	
    }
     function onController()
    {
    	
    }
     function onTimer()
    {
    	
    }
     function onControl(number, value)
    {
    	
    }
    

    Just drop it on every sine generator where you want to adjust the phase and set the phase knob to your likings (you might run into performance issues if you use 100 of these modules though).
    The formula is even easier than I thought - the reason is that the sine wave generator internally uses a look up table with linear interpolation and a fixed "wavetable" size of 2048, so you even don't need the exact frequency for it.



  • @Christoph-Hart AWESOME!!!!!!!!!!!!!!!
    Will be awake all the night I guess!!!!



  • @Christoph-Hart works absolutely fine!!!!. You just made the perfect additive synth πŸ™‚
    A question: This script takes sine frequency after or before a pitch modulator? I do use pitch tables on every sinewave module



  • @hisefilo ok now you are going to have to define how I might make an additive synth using this...



  • Same, I don't understand where you need this in additive synthesis?



  • @Lindon LOL nah is just a part of it. You need to add a bunch of sinewaves by yourself. But now with this you can control phase on those sinewaves adding this script to each one of them



  • @ustk AFAIK additive synthesis is the summation of pure sinewaves. Displacing them over Y axis (phase) will affect the generated waveform. I use it to get timbres cannot be done without displacing phase (phase shift). To be honest don't know if it's a feature a real additive synth comes with



  • @hisefilo I got it πŸ‘

    A real synth is a synth you make πŸ˜ƒ



  • The phase is independant from the frequency because they all use the fixed wavetable length of 2048 samples.

    But to be honest the experiments I made with additive synthesis lead me to discard any efforts of reproducing the phase of harmonics because you simply donβ€˜t hear it - but I am curious about your findings πŸ˜‰



  • @Christoph-Hart I can hear the difference, but is much more obvious looking at the waveform. These are the 16 same sinewaves played together.

    No phase:
    Screen Shot 2019-04-03 at 7.04.14 AM.png

    Phase shifted:
    Screen Shot 2019-04-03 at 7.04.03 AM.png

    I guess nature planed the waveform to look like last one πŸ™‚



  • Yes, that the waveforms look different is obvious, but as far as I know, human ears have a very hard time to distinguish phases between harmonics.

    I found an interesting read about this subject here:

    http://www.silcom.com/~aludwig/Phase_audibility.htm



  • @Christoph-Hart Excellent paper! Will read it carefully at bed! My guess is phase is audible when it contributes to create a "recognizable" waveform (as in the images I posted. Here are 2 examples, same harmonics, with and without phase shift.

    No Phase Shift
    Phase Shifted

    My theory is that partials phase should be placed to contribute to a major simple waveform (I mean a waveform you can visually remember or recognize), shaping the final waveform by adding small variations of a major curve to make it look smooth. Just flip any of the partials on a additive sawtooth waveform and you'll see ramp to be distorted. (maybe Im crazy, but this is what I suppose)



  • I haven't read the paper yet, but for what I know, the phase is important when two or more sources are reproducing the same frequency, as the crossover frequency in a 2-way speaker for instance, where alignment is crucial... But if you take two frequencies far away enough below and above the crossover freq, the ear cannot notice a poor alignment (except if you change it in real time).



  • @ustk my post is related to phases within harmonics on the same sound. I guess phase alignment on speakers is kind of different stuff I can't understand yet



  • It was an image, but the behaviour is approximately the same if your harmonics are not identical, and the phase will automatically move in relation anyway



  • @ustk oh I got it πŸ™‚



  • BTW, the most apparent difference between your sound examples is that the unshifted sample is clipping pretty badly so you're not really hearing phase distortion, but real distortion πŸ™‚



  • @Christoph-Hart yeah. Sorry. Will send a leveled one. Are the same partials, same amplitude... But unphased raises some weird peaks.

    By the way. Having a hard time trying to calculate phase rotation. (since harmonics rotates differently based on #).
    alt text

    Any clue on how to calculate this?



  • @Christoph-Hart is there a way to do sinewaves to start when they cross zero Y value? Got some artifacts when phase is not close to 180 or 360

    Despite this, results are amazing


Log in to reply
 

17
Online

616
Users

2.5k
Topics

19.5k
Posts