HISE Logo Forum
    • Categories
    • Register
    • Login

    Invert polarity of sampler

    Scheduled Pinned Locked Moved General Questions
    44 Posts 8 Posters 4.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dan KorneffD
      Dan Korneff
      last edited by

      Is there any way to invert the polarity of audio in a sampler? AKA phase filp? I don't see a button on the sampler or any FX.

      Dan Korneff - Producer / Mixer / Audio Nerd

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        I think I'll add this to the SimpleGain module, but you can already do that with a scripted FX:

        HiseSnippet 1070.3oc6X0saaaCElx1Zq1cIaCnaXWrKDJ1.bFZMrR69AnXnI1Itvn0sFQtYCqnnfg5XKhHQpQQkD2hBrGw8nz2fMRI6H5BA23ftrhByarOGxC4G+N+vi8PAm.IIbAx55ilFCHqOy1aJSFzM.SYn96gr1zd.NQBBmbUclFiSR.ejkU0GnUXUuFJa7l62AGhYDnPEBcHmRfGQinxBsw67PZXXOrOLhFYr56tSeBm0kGxSU3opcaTLlbLdB7XrdYUrQmPgSSPVssuy1sDG6dzK2s0aMd3eDzp03IKpGQREBfIOTYNxx15eTCK688oRtvShkfZOq0g6O0KfeJK+nOjlPOJDzBtHOElxU2iG5qu75ui5FPC8GNmBSPHqOYXAgVMmPug8.pO8b8ED6WjMgSgElTqUkkAO22M7bKAdHCzUKGcJPv8SCwxEQl1yNaBJeQmdelDXIT4TSO+J.21u2g6WZOjJIAki2JkfWki5+Z7Ny4ug89iGCDYAXqY262urd5KGT1LGJW21ixfrj6Lf7UYxN+F9Dv4A.CDZRcIo2+86+z6mPjpSej.yRh4IKrwdPDcDmoIjBkOMA5If+7.sS1TeWNVT5Tu498T2wRswCKSEYQK6FwSYxEhNpdoR9VLowX8kTnn1+CEJZ+AXghpWL3VBCZYfw5ywnGMJND1mcBDxUZxqNrGLFmFJOWqIHGvY73.NiRLC.N.jB5jIfvD5kde1UJUuQUn4F6b.DBXyf4uamGoBBwBEMAWRpv8hSEKyc8M14v0QmX57wQ88peDUeeEZznDWdCaOhfFKUmuFHet8v.UbXeUTuP091BXJegnJeukspjbhz4DrvIa4cRkRNy4Wc5x07pr0DP1kGEqJEyjMuowZt4V2aiFazXbJin8INwBHFKfQ7gg3oMSv5DQUUW3VNGExIG6QeIrUiW0ndiWaZS1knidAMIAXFCBSxVEcbSiyRihCwgoPys1ZiFNpwqx+POla2yZ+bmev41tsZeuRlz87Iyl60lvP+pDSJ3gMYoQGAhao3C0gMGtn2tWwqcwbgbVeFU9jXXVKkKvPlpKHgBsmioBUjbWxReXAc.OURYSFfUUvNSg7GmF4odvk.cmwD5FfqnezLWtsVN+EWle64cGOaRWsr0rIcmOIZVrgNLbFHUvQlEDt4rfvb+Fh5qyQL7jnLl0LUE8z96gk34alZeU2mXULKUS0V6AmnZwHOButpTdxwRdb1ZmEThr9zK3QelYM4olBmR8UcEotd+kRL.nSBjZouUIIgyj58NOOJOI4pgke2sv80k0B21q6gacObq6gacObq6g6C7ei9UwiHWEmQDlH3ufj2IfNV9ZYZT2aV1ebWc6AZYG24O9q4lHU4vWPHZx91J1obK1dks3NqrE2cks3GWYK9oU1hedks3WVhE52d1MUxixS8Pn+En23Q2.
        

        This patch contains two sine generators and a scripted FX that flips the phase of one of them (resulting in silence). It's not super efficient but it should work for now.

        Dan KorneffD hisefiloH C 3 Replies Last reply Reply Quote 1
        • Dan KorneffD
          Dan Korneff @Christoph Hart
          last edited by

          @christoph-hart thanks! Ill check that out

          Dan Korneff - Producer / Mixer / Audio Nerd

          1 Reply Last reply Reply Quote 0
          • hisefiloH
            hisefilo @Christoph Hart
            last edited by

            @Christoph-Hart found this old post (@Jay remembered it)
            What's the range for those values. +1 to -1 ? Or it's in radiants?
            Im trying to add phase value to my sinewaves generators
            Also can this be used as phase shift?

            1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart
              last edited by

              No a phase inverter simply multiplies the signal with -1 so you can get only 180 degrees or nothing.

              I suggest you play with the start offset parameter in your event processing, with a little bit of math you should be able to make sample perfect phase adjustments for every synthesised waveform in HISE

              hisefiloH 1 Reply Last reply Reply Quote 2
              • hisefiloH
                hisefilo @Christoph Hart
                last edited by

                @Christoph-Hart Thanks!!! was trying to do it with Delay in SimpleGain FX.
                Start offset should be calculated for every note then? due offset will be different for every frequency (note) right? or there's a simple way to do it?

                1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart
                  last edited by

                  Yes, but you just feed the frequency into your formula and it spits out a sample value that you need. I‘ll write a example when I get back in a few hours.

                  hisefiloH 2 Replies Last reply Reply Quote 1
                  • hisefiloH
                    hisefilo @Christoph Hart
                    last edited by

                    @Christoph-Hart AWESOME!!!!! I'll be picking frequencies from a pitch table with some breakpoints, Can you do your example using this snippet? Otherwise I will figure it out later

                    HiseSnippet 849.3oc6WsrSaCDEcbRbEn1hnUn1tzK5NTQXBuxJxCRPARfn3DnkMzA6IIiX7Lt1iC0e.8CpK5+Q+T3OncF6DrSqUTRePQU3EV9buy09L2mia4xLQddLWfxhcBbP.kmnZDP4CpL.hof56CTVRsIziib0hDUNvA54gr.JJYOPJPYwbfvqa1qLj.olnXQ.voLrIpA1Fyik1p3QXBoFzB0AamX0aVrtIiVgQX9B9jUccfCz7JXezwP4xxnBTdTUKLm4ZvgbjGPIWYlUfw.10zn0eJ1CeIAIA5.CwKJRbMFwRxX4yfJCvDqVi22d.fhZqXuP1HuvJpMwV3akG6MVNTgVrEI8GJYlF8zSRu0Skd5oPOPB1kKhcBRvr7IP9jLSFNFo.ylLRUmxQTOLOHY35eJcelZKL2bP57MSJ7UDn9ay2QA+mpVsWOjIOlr4Tq8161H8RQT4wpFXJJrhLjHuHDqcFbHR6.DE4Jcp5Son7qyZQoyLWTdhIW7463BodNLuIdwFHabGFU5QhE10CUyE8g1xnbR4UXP2TUcyd0DaxTsw.x8cCSWJYy7o7IROxNywjjMGlrpIw5SoSQtG5TDR2ryFcSwCpz5ml3rrHm11gfpRGhHLgDIGet59ndPeBerzISxaxnLmALJ1LYFPaD2E2uOxMI2ScCUhyEiVhkrRw1HBBlLa90EaHxBgtB+D5WzWnO69hoEudkZDc0jUlZ+ezgO6uaG94X9dR+7Bi6qdDJ3Xe6KE4JRt9R0iYB9DJP618h9TY76618K6UF6vHPW4LqeLQQV92AJn69PNDn7I0BauV3k6oz01oh3ggmbN4cGVHAVb67B85XVeDNnQvUE5cc8Jw50KjuD+vX7AqNbil6rcDtYPitql2gZFqu2p818rKGgAhscLmx74LpaouwZgqRdufbU4O4A7C36oXver1u2mN3WalOGS62DJle8QwOjH5LYHNukIRvDJEQDeHUkLxyLEgWWhiNvE0JD7Mw0Hk5RrxHk5iUdm7MrgltrKDmWj6xHxVuKDJQruog+B2hh+kTf0zACgD+QdIaQexKLMkN62H7NoawFysE4maK1btsXq41hsmaK1YtsX2oXgbnTIeNyNZhrPPqpQymTpRkCFByxAeGfUFCgZ

                    1 Reply Last reply Reply Quote 0
                    • hisefiloH
                      hisefilo @Christoph Hart
                      last edited by

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

                      1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart
                        last edited by

                        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.

                        hisefiloH 2 Replies Last reply Reply Quote 1
                        • hisefiloH
                          hisefilo @Christoph Hart
                          last edited by

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

                          1 Reply Last reply Reply Quote 0
                          • hisefiloH
                            hisefilo @Christoph Hart
                            last edited by

                            @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

                            LindonL 1 Reply Last reply Reply Quote 0
                            • LindonL
                              Lindon @hisefilo
                              last edited by

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

                              HISE Development for hire.
                              www.channelrobot.com

                              hisefiloH 1 Reply Last reply Reply Quote 0
                              • ustkU
                                ustk
                                last edited by

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

                                Can't help pressing F5 in the forum...

                                hisefiloH 1 Reply Last reply Reply Quote 0
                                • hisefiloH
                                  hisefilo @Lindon
                                  last edited by

                                  @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

                                  1 Reply Last reply Reply Quote 0
                                  • hisefiloH
                                    hisefilo @ustk
                                    last edited by

                                    @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

                                    1 Reply Last reply Reply Quote 0
                                    • ustkU
                                      ustk
                                      last edited by ustk

                                      @hisefilo I got it 👍

                                      A real synth is a synth you make 😃

                                      Can't help pressing F5 in the forum...

                                      1 Reply Last reply Reply Quote 1
                                      • Christoph HartC
                                        Christoph Hart
                                        last edited by

                                        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 ;)

                                        hisefiloH 1 Reply Last reply Reply Quote 0
                                        • hisefiloH
                                          hisefilo @Christoph Hart
                                          last edited by

                                          @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 :)

                                          1 Reply Last reply Reply Quote 0
                                          • Christoph HartC
                                            Christoph Hart
                                            last edited by

                                            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

                                            hisefiloH 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            44

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.9k

                                            Posts