HISE Logo Forum
    • Categories
    • Register
    • Login

    Recreate Bitcrusher Module in Scriptnode

    Scheduled Pinned Locked Moved General Questions
    31 Posts 7 Posters 1.9k 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.
    • Casey KolbC
      Casey Kolb
      last edited by

      Hi all! I'm sure I'm missing something simple here, but is there a good way to recreate the bitcrusher sample rate knob in scriptnode? There's the bitcrush node, but I'm not sure how to do the sample rate. Thanks!

      Casey Kolb
      Founder & CEO of Lunacy Audio
      Composer | Producer | Software Developer

      Casey KolbC 1 Reply Last reply Reply Quote 0
      • Casey KolbC
        Casey Kolb @Casey Kolb
        last edited by

        I think I may have just found it. The sampleandhold node seems to do something similar.

        Casey Kolb
        Founder & CEO of Lunacy Audio
        Composer | Producer | Software Developer

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

          @Casey-Kolb yup, this is more or less what it does (however the sample and hold doesn't support sub-sample reducing).

          Casey KolbC 1 Reply Last reply Reply Quote 1
          • Casey KolbC
            Casey Kolb @Christoph Hart
            last edited by

            @Christoph-Hart said in Recreate Bitcrusher Module in Scriptnode:

            @Casey-Kolb yup, this is more or less what it does (however the sample and hold doesn't support sub-sample reducing).

            Got it! I'm not sure what sub-sample reducing is, but it sounds like I can use the sampleandhold node interchangeably with the "Sample Rate" from the Degrade module?

            Casey Kolb
            Founder & CEO of Lunacy Audio
            Composer | Producer | Software Developer

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

              @Casey-Kolb The sample and hold will hold a value for the given samples. So if it's set to 2, it will effectively reduce the sample rate from 44.1kHz to 22kHz (if it's set to 4 it will be 11kHz and so on). However the hold duration is an integer value so you can't reduce to any arbitrary sample rate.

              For LoFi effects it should be good enough though.

              Casey KolbC 2 Replies Last reply Reply Quote 2
              • Casey KolbC
                Casey Kolb @Christoph Hart
                last edited by

                @Christoph-Hart Sounds good! We don't need precision with the reduction, so it seems perfect for lofi effects, and we can modulate it now which is awesome!

                Casey Kolb
                Founder & CEO of Lunacy Audio
                Composer | Producer | Software Developer

                1 Reply Last reply Reply Quote 0
                • Casey KolbC
                  Casey Kolb @Christoph Hart
                  last edited by Casey Kolb

                  @Christoph-Hart Running into a slightly weird issue with the custom bitcrusher scriptnode module within CUBE. For some reason the bit rate will create a perpetual fuzzy signal even after the sound has finished.

                  Here's an example:
                  https://www.dropbox.com/s/n3ehwtbvx18syii/Scriptnode Bitcrusher generating noise even without input.mov?dl=0

                  Casey Kolb
                  Founder & CEO of Lunacy Audio
                  Composer | Producer | Software Developer

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

                    @Casey-Kolb If you're modulating the bit crusher it will create varying DC offsets at low bit values. What's in the modulation chain?

                    Casey KolbC 1 Reply Last reply Reply Quote 0
                    • Casey KolbC
                      Casey Kolb @Christoph Hart
                      last edited by

                      @Christoph-Hart Just a global modulator LFO.

                      Casey Kolb
                      Founder & CEO of Lunacy Audio
                      Composer | Producer | Software Developer

                      Casey KolbC 1 Reply Last reply Reply Quote 0
                      • Casey KolbC
                        Casey Kolb @Casey Kolb
                        last edited by Casey Kolb

                        @Christoph-Hart Even without modulation, the bitcrusher node it scriptnode leaves a signal active perpetually if the bit rate is anything below 16. The meters will show signal.

                        Casey Kolb
                        Founder & CEO of Lunacy Audio
                        Composer | Producer | Software Developer

                        JL.LVJ 1 Reply Last reply Reply Quote 1
                        • JL.LVJ
                          JL.LV @Casey Kolb
                          last edited by

                          @Casey-Kolb I think thats DC offset, you would need to find a way to supress that. I think you would need something to stop th signal from going below -1 and above +1. I tried doing this with the clip node (by modifying the min/max) but it didnt work

                          Christoph HartC 1 Reply Last reply Reply Quote 1
                          • Christoph HartC
                            Christoph Hart @JL.LV
                            last edited by

                            @JL-LV No you don't get rid of DC offset by clipping to -1...1. What you need is a high pass filter (DC offset is a signal with the frequency 0Hz, so even a simple one pole high pass set to 20Hz will get rid of this).

                            Casey KolbC 1 Reply Last reply Reply Quote 1
                            • Casey KolbC
                              Casey Kolb @Christoph Hart
                              last edited by

                              @Christoph-Hart Great! That works for removing the phantom signal from the meter, but I'm still experiencing this weird static noise in my CUBE project: https://www.dropbox.com/s/n3ehwtbvx18syii/Scriptnode Bitcrusher generating noise even without input.mov?dl=0

                              Casey Kolb
                              Founder & CEO of Lunacy Audio
                              Composer | Producer | Software Developer

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

                                @Casey-Kolb Hmm, the problem is still the DC offset that the bit crusher introduces.

                                I've made another bitcrusher as snex_shape node which behaves better when modulating (and there's no DC offset introduced).

                                The snippet export doesn't work with SNEX nodes yet, so you have to do it manually:

                                1. Add a snex_shaper node.
                                2. Make sure you have a "SNEX code editor" floating tile somewhere (best place would be a tab in the scripting editor tabs).
                                3. Create a new file (call it bitcrush2). Click on the SNEX button. Then you should see the shaper class in the SNEX editor.
                                4. Enter the code below and press compile.
                                5. Add a parameter and set its range to 4-16 (or whatever bit range you want to support
                                6. Use and compile the node like any other.
                                template <int NumVoices> struct bitcrush2
                                {
                                	SNEX_NODE(bitcrush2);
                                	
                                	// Implement the Waveshaper here...
                                	
                                	float getSample(float input)
                                	{
                                		const float invStepSize = Math.pow(2.0f, bitDepth);
                                		const float stepSize = 1.0f / invStepSize;
                                			
                                		if(input > 0.0f)
                                			return (stepSize * Math.floor(input * invStepSize));
                                		else
                                			return (stepSize * Math.ceil(input * invStepSize));
                                	}
                                	// These functions are the glue code that call the function above
                                	template <typename T> void process(T& data)
                                	{
                                		for(auto ch: data)
                                		{
                                			for(auto& s: data.toChannelData(ch))
                                			{
                                				s = getSample(s);
                                			}
                                		}
                                	}
                                	template <typename T> void processFrame(T& data)
                                	{
                                		for(auto& s: data)
                                			s = getSample(s);
                                	}
                                	void reset()
                                	{
                                		
                                	}
                                	void prepare(PrepareSpecs ps)
                                	{
                                		
                                	}
                                	
                                	void setExternalData(const ExternalData& d, int index)
                                	{
                                	}
                                	
                                	float bitDepth = 16.0f;
                                	
                                	template <int P> void setParameter(double v)
                                	{
                                		bitDepth = v;
                                
                                	}
                                };
                                
                                Christoph HartC 1 Reply Last reply Reply Quote 2
                                • Christoph HartC
                                  Christoph Hart @Christoph Hart
                                  last edited by Christoph Hart

                                  @Christoph-Hart NVM, I've added this as additional mode to the bit crusher node. You can now choose between DC and Bipolar. I couldn't just change the bit crusher algorithm because it sounds very different, but when you want to modulate the bit depth, the new Bipolar mode is much better because it doesn't create a DC offset that is dependent on the bit depth parameter.

                                  (If you load an existing network, it will complain about a wrong parameter structure, but this is OK in this case).

                                  Casey KolbC 2 Replies Last reply Reply Quote 3
                                  • Casey KolbC
                                    Casey Kolb @Christoph Hart
                                    last edited by

                                    @Christoph-Hart Amazing! Will give this a spin :) Thank you

                                    Casey Kolb
                                    Founder & CEO of Lunacy Audio
                                    Composer | Producer | Software Developer

                                    1 Reply Last reply Reply Quote 0
                                    • Casey KolbC
                                      Casey Kolb @Christoph Hart
                                      last edited by Casey Kolb

                                      @Christoph-Hart @langermarc19 We're hitting a snag here with the bitcrusher in scriptnode. In the compiled VST plugin, it will output only the left channel when the bitcrusher is active, regardless of the mode, DC or Bipolar, and regardless of the bitrate. It seems to happen in most DAWs, but not in standalone.

                                      We're going to take a look at the node code for the bitcrusher, but any immediate thoughts?

                                      Casey Kolb
                                      Founder & CEO of Lunacy Audio
                                      Composer | Producer | Software Developer

                                      Matt_SFM orangeO 2 Replies Last reply Reply Quote 0
                                      • Matt_SFM
                                        Matt_SF @Casey Kolb
                                        last edited by

                                        @Casey-Kolb I won't be of much help, but I built a simple bitcrusher here and it works fine (I recall I'm using the bipolar mode)

                                        Develop branch
                                        Win10 & VS17 / Ventura & Xcode 14. 3

                                        1 Reply Last reply Reply Quote 0
                                        • B
                                          blezzbeats
                                          last edited by

                                          Kinda related: Is there any way to access the in-between sample rates of the bitcrusher effect with an integer or float? To get at the rates between 22-44khZ for example, and not just jump that big notch.

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

                                            @blezzbeats Do you mean the sample and hold module? The bitcrusher allows float bit rates.

                                            B 2 Replies Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            20

                                            Online

                                            1.7k

                                            Users

                                            11.9k

                                            Topics

                                            103.3k

                                            Posts