• Software
  • RE: Input and Biquad/QuadBiquad.h and Source...

in a relatively simple form, a distortion effect looks like this:

# include <libraries/math_neon/math_neon.h> // this at the top

//this in render, within the usual nested `for` loops:
float in = audioRead(context, n, c);
float out =  tanhf_neon(in * gain); // using tanh for distortion. Experiment with other functions here
audioWrite(context, n, c, out);

and then you adjust the gain parameter to taste. In many cases, there would be low-pass filters or more complex filterbanks following (and possibly preceding) the gain stage. There may be oversampling to reduce aliasing, compression, multiband distortion, whatever. But the core is up there in the middle of the three lines.

    giuliomoro

    Yes sir...I will test it and promptly. Thank you.

    Seth

    P.S. Who knows? Maybe a real violin player will tune it proper and play it well w/ the distortion and the amplifier...

    giuliomoro

    Hello Sir...is the source supposed to promote some type of gain or distortion? I am asking b/c I applied the source w/ some extra tidbits of source.

    It seems I am in the same spot. Anyway, do I need to make the bool class in .cpp file aware of my interactions/source within render?

    Seth

    P.S. I am asking b/c I will read more on math_neon.h soon but I seem to be lost in space. Ha. Anyway, please let me know if you know of a nice place to start for readin' about math_neon.h. I found a couple of posts in this forum about math_neon.h and I see what you are talking about in these posts...

    Also...

    am I allowed to use more than one boot setup class in the source?

      giuliomoro

      Sir,

      Sorry for all these posts. I looked up the math_neon.h file and there is nothing in it on the docs. Is that on purpose?

      Seth

      P.S. It just references another file, #inculde <math_neon.h>, and ends. Anyway, please let me know what you think...I am not sure exactly how to use this file yet.

        silver2row am I allowed to use more than one boot setup class in the source?

        you can only have one setup() function in a project.

        silver2row I looked up the math_neon.h file and there is nothing in it on the docs. Is that on purpose?

        there is not much to know about it. It contains fast implementations of some of the math functions available in the standard C library. See, e.g.: https://github.com/BelaPlatform/Bela/wiki/Fast-math-functions, or The Source https://github.com/giuliomoro/math-neon.

        silver2row Anyway, do I need to make the bool class in .cpp file aware of my interactions/source within render?

        I have no idea what this means.

        The full file would look like this:

        #include <Bela.h>
        #include <libraries/math_neon/math_neon.h>
        
        bool setup(BelaContext *context, void *userData)
        {
        	return true;
        }
        
        void render(BelaContext *context, void *userData)
        {
        	for(unsigned int n = 0; n < context->audioFrames; ++n)
        	{
        		for(unsigned int c = 0; c < context->audioInChannels && c < context->audioOutChannels; ++c)
        		{
        			float gain = 1;
        			float in = audioRead(context, n, c);
        			float out =  tanhf_neon(in * gain); // using tanh for distortion. Experiment with other functions here
        			audioWrite(context, n, c, out);
        		}
        	}
        }
        
        void cleanup(BelaContext *context, void *userData)
        {}

          giuliomoro

          Hello Sir,

          Okay...thank you for the links to math_neon.h and where it is derived. I will test the source you provided again.

          ...

          I tried some other source, I can show you if you are interested, that you can probably pick apart to make me understand exactly what I have done but...

          I think you are right. I should keep it simple until I get a greater grasp on the ideas and source.

          Oh! No issue on what you do not understand from what I typed. I need the bool setup to initialize the source and void render to use it.

          Seth

          P.S. I was adding in the QuadBiquad.h and vertex.h and math_neon.h all together to test the source. I got one script working but I usually produce first and learn what it is I have done. "Not easy on the brain!" Thank you, again!

          I'm curious if you want distortion or a filter sound? Or maybe some of both?

          To be clear on terms, "distortion" is usually taken to mean a mathematically nonlinear function that creates harmonics that aren't naturally in the source material.

          A filter can selectively make certain frequency components more or less audible (like filterbanks or audio EQ).

          Modulated filters can create a form of distortion (like frequency shifting) but we don't often call it distortion since this term is often reserved primarily for waveshaping functions.

          Maybe some more explanation for what type of effect you want to perform on the violin somebody can give some specific help. Perhaps the Biquad is the thing you want and you only need some ideas to make this change the sound of the violin in a way you can easily hear.

          Maybe you want some distortion like suggested by @giuliomoro where you clip the signal and make it sound more like electric guitar.

          For example, I have coded a variety of sound effects which can be implemented on Bela that somebody could use for many fun experiments with a violin. These aren't simple enough for me to recommend them as examples for learning how to use Bela. The examples provided by the Bela team are better for learning because they are short and focus on one thing at a time.

          https://github.com/transmogrifox/transmogriFX_bela

          Everything works as-is, but you need to have something connected to the Analog Inputs to adjust levels or you might get settings stuck in very strange positions...and you need switches on digital inputs.

            as far as i get it, you want to have this violin open to the public, or at least have it played by people who don't normally play the violin? nice. 🙂
            so i understand that you would prefer some sort of 'different', 'unexpected' or 'surprising' sound to come out of the speaker, instead of just a badly played violin. hah.

            and while trying out all the examples may be a good starting point, i have to agree with @[deleted] and @[deleted] that this conversation would become easier once you decide what you want to do with the sound to make it surprising.
            you could have distortion, but only on the lower notes. you could have the higher notes be chopped up with a tremolo and disappear into an echo. or maybe you want to trigger Winston Churchill speech samples and speed them up as the violin gets louder?

            people here are more than willing to help you get the results you want - but it's kind of hard to help you if you don't know what you want to achieve. 🙂

            (that said, i can only help you if you choose to go with Pd - my C++ is still at kindergarten level.)

              Remork and ryjobil

              Hello,

              I guess anything outside of the regular sound would be nice. And yes, I am not a violin/fiddle player. I wanted people to use BELA, the BBB, and play this fiddle with their own adaptation of instrument playing.

              ...

              I will try the link soon. Thank you both for replying.

              Seth

              P.S. So, in hindsight, I would have been preparing for months for this Faire but they only gave me a short window of notification. So, w/out further ado, off to look over the link.

                silver2row
                Here's a vocoder I got working.

                https://github.com/transmogrifox/Bela_Misc/tree/master/vocoder

                That certainly does something out of the ordinary. It's plug 'n' play as-is, but the trick is you need a second audio source going into ADC channel 1, which requires a preamp and some circuit work. Coding it to take the second source from either the other audio channel or even synthesizing some sort of signals internally (like sampling random numbers) could be fun.

                Here's another crazy sound, but probably takes some more coding to make it more hands-free. I'm getting the impression you don't have much time to put together applications with control surfaces, knobs or other interactive sensors so I'm trying to focus on things that are likely to work without needing anything more than an instrument input. Is this correct?

                This,
                https://github.com/transmogrifox/transmogriFX_bela/blob/master/src/sample_hold_modulator.cpp
                Connected into this,
                https://github.com/transmogrifox/transmogriFX_bela/blob/master/src/envelope_filter.cpp

                Can get you sounds like this,

                Here is a sample of the vocoder. You can see a box to the right, which is a microphone preamp that I built. It's cheap and easy to make, but if you have or can get a commercial mic preamp that will work fine.

                  ryjobil

                  Hello,

                  You are right. I have until 3:30 today. So, I am out of luck I guess. No issue. When I return and start to use BELA more, I can start to learn about it more. I only made it to the sixth rendition of lectures on BELA via YouTube.com.

                  So, although BELA will not be showing up w/ me this time, as I had to focus on some attention getters and other hardware-software related things, I will learn more about what exactly is offered via BELA, the BBB, and music.

                  Seth

                  P.S. I really thank you and the other two people for helping me along my short journey of reaching out. I think all the work that has been put in for the repositories is worth it and I will learn more about them in time. Please forgive me.

                  Oh and I watched the two videos. That vocoder thing is nice! The first video is nice too, i.e. esp. w/ the bouyant sounds of melodic wish-wash. Yea and yes sir, nice! I think the vocoder will be nice for the violin once I figure out how to play a little more. I can try on guitar soon but the violin is my new intermediary of time consumption.

                    ryjobil

                    Hello,

                    Well...I went and did not conquer. The violin was out of tune and my rosined bow was not rosined enough. Now, I can start on the circuit construction and ideas for the BELA platform/Cape.

                    Seth

                    P.S. Thank you...I did enjoy it. I will most likely try to finish the rest of the ideas on Youtube.com for the BELA lectures and then proceed to circuits, vocoder, and other ideas.

                    ryjobil

                    Hello...I looked over the source in the github repo.

                    It is fine and okay by me but...

                    I have not figured out how to make any of it work just yet. I have four strings on this violin and six strings on my guitar.

                    I am not getting any pause of sound or change in sounds. I made another post on this blog site to better suit the needs of quick viewers.

                    Seth

                    P.S. If there is a particular circuit to make that is specific, please let me know. I will make this circuit and proceed. Anyway, I am very excited to make this 'heavily rosined' bow make angelic sounds of beauty once and for all. Ha. So in hindsight, I will keep trying and learn more about different circuits while I stay patient for replies.

                      silver2row
                      The vocoder has the best instructions. If you make the connections as diagrammed on the github README.md then the vocoder will work. You will need a microphone preamp for the ADC CH1 connection
                      https://github.com/transmogrifox/Bela_Misc/tree/master/vocoder

                      The "klingon tone" will also work without external connections because the defaults are set to something that will change the sound, and quick review of the code shows it starts in an active state:
                      https://github.com/transmogrifox/Bela_Misc/tree/master/klingon_tone
                      You can do more with knobs connected, but it will do something audibly different without.

                      The sample/hold modulator, ADSR and state variable filter require more understanding of Bela and the code. The TransmogriFX repo ( https://github.com/transmogrifox/transmogriFX_bela/tree/master/src ) works as a complete system but it requires a combination of correct hardware connections and an understanding of what the hardware inputs do in the code -- neither of which are documented yet, so you have to study the code and experiment to figure out my particular way of doing things to make it work.

                        ryjobil

                        Yes sir,

                        I will keep attempting the source learning. Also, I will try to build the preamp for the ADC connection.

                        Seth

                        P.S. I should have something done in the next couple of months. I am slow on building but things come together in the end. Thank you for supporting this channel. I appreciate your time a neat videos, i.e. esp. the vocoder playing.

                        ryjobil quick review of the code shows it starts in an active state

                        i was under the impression that the default was 'bypass = true'.
                        i should think that it therefore starts in bypass?

                          Remork i was under the impression that the default was 'bypass = true'.
                          i should think that it therefore starts in bypass?

                          While it is true that make_klingon(...) will create a Klingon Tone initialized to bypass state, the specific sketch referenced sets it to active state when you start the sketch.

                          See render.cpp, in function setup(...)

                              //Bypass is the least intuitive function:
                              // If second argument is true, it forces bypass state.
                              // If second argument is false, it toggles bypass state.
                              // The second call below is all that is needed after make_klingon(), since the constructor function
                              // sets bypass state to true.  A call to kot_set_bypass(kot, false) would then toggle to active-state
                              // since it is already initialized to bypass state (true).
                              // However for clarity in the example it is explicitly set to true, then toggled to demonstrate the normal sequence when
                              // the current bypass state is unknown.
                              kot_set_bypass(kot, true);
                              kot_set_bypass(kot, false);

                          Notice I fixed the comment here, but haven't pushed a fix to the comment in the code, so you will see a discrepancy if you read this section of the code before I get around to fixing it.

                            8 days later

                            ryjobil ,

                            Okay...things are settling down again (maybe). So, I looked throughout the over-the-1500 lines of code in render.cpp.

                            I came up empty so far.

                            ...

                            I have not found exactly where this specific set of lines are located. Um, are you sure they are in render.cpp? And if they are in render.cpp, which setup (This_Or_That) function should I look to when looking for this specific set of calls.

                            Seth

                            P.S.

                            bool kot_set_bypass(klingon* kot, bool bypass)
                            {
                            	if(!bypass)
                            	{
                            		if(kot->bypass)
                            			kot->bypass = false;
                            		else
                                    {
                                        kot->bypass = true;
                                    }
                            	}
                            	else
                            	{
                            		kot->bypass = true;
                            	}
                            
                            	return kot->bypass;
                            }

                            Is this it? I found this in klingon.cpp. Oh! Is it in this repo, https://github.com/transmogrifox/Bela_Misc, and not this one...https://github.com/transmogrifox/transmogriFX_bela?

                            Hello Once More,

                            ryjobil and Remork ...

                            ...

                            Um...hmm. I added the scripts to the folder in the form of a .zip file like stated in the instructions for using BELA.local.

                            This section of .zip dropping worked but I am receiving an odd error:

                            Makefile:153: *** Invalid/empty project. A project needs to have at least one .cpp or .c or .cc or _main.pd or _main.scd or _main.csd or run.sh file.  Stop.

                            So, I was thinking that, I am solely guessing here, the Makefile in question here has limitations that I should overcome and quickly. Does this sound correct?

                            Seth

                            P.S. The Makefile is missing but I have not used a Makefile thus far from what I have understood. So, it is hidden maybe?