• General
  • Bela_Misc from https://github.com/silver2row/Bela_Misc

Running project ...
Segmentation fault
make: *** [runide] Error 139

Above is where you can find my error. First, it was the issue of printing to console too quickly which cut off the Bela IDE.

Now, I am getting the runide Error 139 as my default error. Where would I find the Makefile or does anyone know of a solution to Error 139?

Seth

A-Okay and I found the Makefile.

runide: ## Run PROJECT for IDE (foreground, no buffering)
runide: stop Bela $(RUN_PREREQUISITES)
        $(AT) sync& cd $(RUN_FROM) && $(RUN_IDE_COMMAND)

This seems to halt execution for some reason. I have not studied too long on the Makefile but I will keep at it.

Seth

And Me Again,

So, I figured out that my files were off and it was not the IDE with the Makefile. So, I adjusted the source in a file.

Every thing now links properly but kills the build with this bunch of data:

 ...done
Build finished
Running project ...
Bela stopped

I am not sure what to do now.

Seth

    Here is the klingon_tone.cpp file:

    //
    // klingon-tone sketch,
    //
    
    
    #include <Bela.h>
    #include <stdlib.h>
    #include <math.h>
    
    #include "klingon.h"
    
    #define N_KNOBS         5
    #define DRIVE           0
    #define TONE            1
    #define LEVEL           2
    #define DRY		3
    #define BOOST           4
    
    float *ch0, *ch1;
    int gAudioFramesPerAnalogFrame;
    int gStartup_Control_Delay;
    
    // klingon-tone implementation based conceptually on typical guitar stompbox OD like King of Tone
    klingon* kot;
    
    //
    //Control functions related struct and processing
    //
    
    typedef struct knobs_t
    {
        float fs;
        float ifs;
        int N;
        int channel;
    
        bool active;
    
        int active_timer;
        int active_time;
    
        float *frame;
        float b0;
        int scan_time;
        float dk_thrs;
    
        float y1, y2;
        float s0;
        int scan_timer;
    } knobs;
    
    knobs* make_knob(knobs* k, int channel, int N, float fs, float scan_time, float active_time, float tau, float thrs)
    {
        k = (knobs*) malloc(sizeof(knobs));
        k->frame = (float*) malloc(sizeof(float)*N);
        k->fs = fs;
        k->ifs = 1.0/fs;
        k->N = N;
        k->channel = channel;
    
        for(int i = 0; i < N; i++)
            k->frame[i] = 0.0;
    
        k->b0 =  expf(-k->ifs/tau);
        k->scan_time = ((int) (fs*scan_time)) / N;
        k->active_time = ((int) (fs*active_time) ) / N;
        k->dk_thrs = thrs;
    
        k->y1 = k->y2 = 0.0;
        k->scan_timer = 0;
        k->active = false;
        k->active_timer = 0;
    
        return k;
    }
    
    //
    //Filter analog inputs
    // Detect changes in position
    //
    
    void knob_filter_run(knobs* k)
    {
        float x = 0.0;
        //2 first order low-pass filters on analog inputs to smooth knob controls
        for(int i = 0; i < k->N; i++)
        {
            x = k->frame[i];
            k->y1 = x + (k->y1 - x) * k->b0;
            x = k->y1;
            k->y2 = x + (k->y2 - x) * k->b0;
        }
    
        //then check for changes
        if(++k->scan_timer >= k->scan_time)
        {
            k->scan_timer = 0;
            float dk = fabs(k->y2 - k->s0);
            if(dk > k->dk_thrs)
            {
                k->active_timer = k->active_time;
                //rt_printf("KNOB dk: %d, %f\n", k->channel, k->y2);
            }
    
            k->s0 = k->y2;
        }
        if(k->active_timer > 0)
        {
            if(k->active == false)
                rt_printf("KNOB is ACTIVE: %d, %f\n", k->channel, k->y2);
            k->active = true;
            k->active_timer--;
        }
        else
        {
            if(k->active == true)
            {
                rt_printf("KNOB %d is INACTIVE.  Value: %f\n", k->channel, k->y2);
            }
            k->active = false;
            k->active_timer = 0;
        }
    }
    
    void
    knob_destructor(knobs* k)
    {
    	free(k);
    }
    
    //Control knobs:
    knobs **kp;
    
    // Extract a single audio channel from BelaContext and format for effect code input
    void format_audio_buffer(BelaContext* context, float *outbuffer, int channel)
    {
        for(unsigned int n = 0; n < context->audioFrames; n++) {
            // Read the audio input and half the amplitude
            outbuffer[n] = audioRead(context, n, channel);
        }
    }
    
    // Extract a single analog channel from BelaContext and format for flanger code input
    void format_analog_buffer(BelaContext* context, knobs *k)
    {
        float ain = k->y1; //starts out with previous value -- just to initialize with something sane and make the compiler happy
        for(unsigned int n = 0; n < k->N; n++)
        {
            if(!(n % gAudioFramesPerAnalogFrame))
            {
                 ain = analogRead(context, n/gAudioFramesPerAnalogFrame, k->channel);
            }
            // double-stuff it
            k->frame[n] = ain;
        }
        knob_filter_run(k);
    
        if(gStartup_Control_Delay <= 0)
    	{
    		if(gStartup_Control_Delay == 0)
    		{
    			rt_printf("Startup Delay Expired\n");
    			gStartup_Control_Delay = -1;
    		}
    
    	    if(k->active)
    	    {
    	        switch(k->channel)
    	        {
    	            case DRIVE:
    	                kot_set_drive(kot, map(k->y2, 0.0, 1.0, 12.0, 45.0) );
    	                break;
    	            case TONE:
    	                kot_set_tone(kot, map(k->y2, 0.0, 1.0, -60.0, 0.0) );
    	                break;
    	            case LEVEL:
    	                kot_set_level(kot, map(k->y2, 0.0, 1.0, -40.0, 0.0) );
    	                break;
    	            case BOOST:
    	            	kot_set_boost(kot, k->y2);
    	                break;
    	            case DRY:
    	            	kot_set_mix(kot, powf(10.0, map(k->y2, 0.0, 1.0, -60.0, 0.0)/20.0) );
    	                break;
    	            default:
    	                break;
    	        }
    	    }
    	}
    	else
    		gStartup_Control_Delay--;
    }
    
    bool setup(BelaContext *context, void *userData)
    {
        ch0 = (float*) malloc(sizeof(float)*context->audioFrames);
        ch1 = (float*) malloc(sizeof(float)*context->audioFrames);
    
        // Create the klingon : make_klingon() initializes sane (usable) default settings
        kot = make_klingon(kot, 1, context->audioFrames, context->audioSampleRate);
    
        //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 false, then toggled to demonstrate the normal sequence when
        // the current bypass state is unknown.
        kot_set_bypass(kot, true);
        kot_set_bypass(kot, false);
    
        //Setup analog control input functions
        kp = (knobs**) malloc(sizeof(knobs*)*N_KNOBS);
        for(int i = 0; i < N_KNOBS; i++)
        {
    //make_knob(knobs* k, int channel, int N, float fs, float scan_time, float active_time, float tau, float thrs)
            kp[i] = make_knob(kp[i], i, context->audioFrames, context->audioSampleRate, 0.15, 1.0 , 0.01, 0.005);
    
        }
    
        gAudioFramesPerAnalogFrame = context->audioFrames / context->analogFrames;
        gStartup_Control_Delay = (int) (context->audioSampleRate*2.0);
    
        return true;
    }
    
    void render(BelaContext *context, void *userData)
    {
        //separate audio inputs into their own buffers
        format_audio_buffer(context, ch1, 1);
        format_audio_buffer(context, ch0, 0);
    
        //Scan analog inputs and set settings
        for(int i = 0; i < N_KNOBS; i++)
            format_analog_buffer(context, kp[i]);
    
    
        //Run the klingon on ch0
        klingon_tick(kot, ch0);
    
        //Send it to the output
        for(unsigned int n = 0; n < context->audioFrames; n++)
        {
            // Write klingon through ch0, pass-through ch1
            audioWrite(context, n, 0, ch0[n]);
            audioWrite(context, n, 1, ch1[n]);
        }
    }
    
    void cleanup(BelaContext *context, void *userData)
    {
        //
        //  Deallocate memory allocated during program execution
        //
    
        free(ch0);
        free(ch1);
        klingon_cleanup(kot);
    
        //Setup analog control input functions
        for(int i = 0; i < N_KNOBS; i++)
        {
    		//deallocate memory from knobs
            knob_destructor(kp[i]);
        }
        free(kp);
    }

    Also, the file(s) can be found here: https://github.com/silver2row/Bela_Misc/tree/master/klingon_tone

    Seth

    P.S. I do not have any knobs. Maybe this is the reason I am getting a Stopping Bela prompt as output?

    Also...I see I did not upload the .txt files to the IDE:

    // Set up interpolation table
        const char* soft_file = "soft_clip.txt";
        const char* hard_file = "hard_clip.txt";
        const char* limit_file = "output_limit.txt";

    I will try with these .txt files to see if this is indeed the error generated but without notification...

    You probably mean render.cpp as the file in question. Please hold...

    Also, I got the files to run again...

    Bela stopped
    Building project ...
    Build finished
    Running project ...
    KNOB is ACTIVE: 0, 0.008343
    KNOB is ACTIVE: 3, 0.002147
    KNOB 0 is INACTIVE.  Value: 0.008910
    KNOB 3 is INACTIVE.  Value: 0.002220
    Startup Delay Expired

    So, something with the knobs in the source need to be altered or removed for now, i.e. I am not using knobs.

    Here is render.cpp:

    //
    // klingon-tone sketch,
    //
    
    
    #include <Bela.h>
    #include <stdlib.h>
    // #include <libraries/math_neon/math_neon.h>
    #include <math.h>
    
    #include "klingon.h"
    
    #define N_KNOBS         5
    #define DRIVE           0
    #define TONE            1
    #define LEVEL           2
    #define DRY		3
    #define BOOST           4
    
    float *ch0, *ch1;
    int gAudioFramesPerAnalogFrame;
    int gStartup_Control_Delay;
    
    // klingon-tone implementation based conceptually on typical guitar stompbox OD like King of Tone
    klingon* kot;
    
    //
    //Control functions related struct and processing
    //
    
    typedef struct knobs_t
    {
        float fs;
        float ifs;
        int N;
        int channel;
    
        bool active;
    
        int active_timer;
        int active_time;
    
        float *frame;
        float b0;
        int scan_time;
        float dk_thrs;
    
        float y1, y2;
        float s0;
        int scan_timer;
    } knobs;
    
    knobs* make_knob(knobs* k, int channel, int N, float fs, float scan_time, float active_time, float tau, float thrs)
    {
        k = (knobs*) malloc(sizeof(knobs));
        k->frame = (float*) malloc(sizeof(float)*N);
        k->fs = fs;
        k->ifs = 1.0/fs;
        k->N = N;
        k->channel = channel;
    
        for(int i = 0; i < N; i++)
            k->frame[i] = 0.0;
    
        k->b0 =  expf(-k->ifs/tau);
        k->scan_time = ((int) (fs*scan_time)) / N;
        k->active_time = ((int) (fs*active_time) ) / N;
        k->dk_thrs = thrs;
    
        k->y1 = k->y2 = 0.0;
        k->scan_timer = 0;
        k->active = false;
        k->active_timer = 0;
    
        return k;
    }
    
    //
    //Filter analog inputs
    // Detect changes in position
    //
    
    void knob_filter_run(knobs* k)
    {
        float x = 0.0;
        //2 first order low-pass filters on analog inputs to smooth knob controls
        for(int i = 0; i < k->N; i++)
        {
            x = k->frame[i];
            k->y1 = x + (k->y1 - x) * k->b0;
            x = k->y1;
            k->y2 = x + (k->y2 - x) * k->b0;
        }
    
        //then check for changes
        if(++k->scan_timer >= k->scan_time)
        {
            k->scan_timer = 0;
            float dk = fabs(k->y2 - k->s0);
            if(dk > k->dk_thrs)
            {
                k->active_timer = k->active_time;
                //rt_printf("KNOB dk: %d, %f\n", k->channel, k->y2);
            }
    
            k->s0 = k->y2;
        }
        if(k->active_timer > 0)
        {
            if(k->active == false)
                rt_printf("KNOB is ACTIVE: %d, %f\n", k->channel, k->y2);
            k->active = true;
            k->active_timer--;
        }
        else
        {
            if(k->active == true)
            {
                rt_printf("KNOB %d is INACTIVE.  Value: %f\n", k->channel, k->y2);
            }
            k->active = false;
            k->active_timer = 0;
        }
    }
    
    void
    knob_destructor(knobs* k)
    {
    	free(k);
    }
    
    //Control knobs:
    knobs **kp;
    
    // Extract a single audio channel from BelaContext and format for effect code input
    void format_audio_buffer(BelaContext* context, float *outbuffer, int channel)
    {
        for(unsigned int n = 0; n < context->audioFrames; n++) {
            // Read the audio input and half the amplitude
            outbuffer[n] = audioRead(context, n, channel);
        }
    }
    
    // Extract a single analog channel from BelaContext and format for flanger code input
    void format_analog_buffer(BelaContext* context, knobs *k)
    {
        float ain = k->y1; //starts out with previous value -- just to initialize with something sane and make the compiler happy
        for(unsigned int n = 0; n < k->N; n++)
        {
            if(!(n % gAudioFramesPerAnalogFrame))
            {
                 ain = analogRead(context, n/gAudioFramesPerAnalogFrame, k->channel);
            }
            // double-stuff it
            k->frame[n] = ain;
        }
        knob_filter_run(k);
    
        if(gStartup_Control_Delay <= 0)
    	{
    		if(gStartup_Control_Delay == 0)
    		{
    			rt_printf("Startup Delay Expired\n");
    			gStartup_Control_Delay = -1;
    		}
    
    	    if(k->active)
    	    {
    	        switch(k->channel)
    	        {
    	            case DRIVE:
    	                kot_set_drive(kot, map(k->y2, 0.0, 1.0, 12.0, 45.0) );
    	                break;
    	            case TONE:
    	                kot_set_tone(kot, map(k->y2, 0.0, 1.0, -60.0, 0.0) );
    	                break;
    	            case LEVEL:
    	                kot_set_level(kot, map(k->y2, 0.0, 1.0, -40.0, 0.0) );
    	                break;
    	            case BOOST:
    	            	kot_set_boost(kot, k->y2);
    	                break;
    	            case DRY:
    	            	kot_set_mix(kot, powf(10.0, map(k->y2, 0.0, 1.0, -60.0, 0.0)/20.0) );
    	                break;
    	            default:
    	                break;
    	        }
    	    }
    	}
    	else
    		gStartup_Control_Delay--;
    }
    
    bool setup(BelaContext *context, void *userData)
    {
        ch0 = (float*) malloc(sizeof(float)*context->audioFrames);
        ch1 = (float*) malloc(sizeof(float)*context->audioFrames);
    
        // Create the klingon : make_klingon() initializes sane (usable) default settings
        kot = make_klingon(kot, 1, context->audioFrames, context->audioSampleRate);
    
        //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 false, then toggled to demonstrate the normal sequence when
        // the current bypass state is unknown.
        kot_set_bypass(kot, true);
        kot_set_bypass(kot, false);
    
        //Setup analog control input functions
        kp = (knobs**) malloc(sizeof(knobs*)*N_KNOBS);
        for(int i = 0; i < N_KNOBS; i++)
        {
    //make_knob(knobs* k, int channel, int N, float fs, float scan_time, float active_time, float tau, float thrs)
            kp[i] = make_knob(kp[i], i, context->audioFrames, context->audioSampleRate, 0.15, 1.0 , 0.01, 0.005);
    
        }
    
        gAudioFramesPerAnalogFrame = context->audioFrames / context->analogFrames;
        gStartup_Control_Delay = (int) (context->audioSampleRate*2.0);
    
        return true;
    }
    
    void render(BelaContext *context, void *userData)
    {
        //separate audio inputs into their own buffers
        format_audio_buffer(context, ch1, 1);
        format_audio_buffer(context, ch0, 0);
    
        //Scan analog inputs and set settings
        for(int i = 0; i < N_KNOBS; i++)
            format_analog_buffer(context, kp[i]);
    
    
        //Run the klingon on ch0
        klingon_tick(kot, ch0);
    
        //Send it to the output
        for(unsigned int n = 0; n < context->audioFrames; n++)
        {
            // Write klingon through ch0, pass-through ch1
            audioWrite(context, n, 0, ch0[n]);
            audioWrite(context, n, 1, ch1[n]);
        }
    }
    
    void cleanup(BelaContext *context, void *userData)
    {
        //
        //  Deallocate memory allocated during program execution
        //
    
        free(ch0);
        free(ch1);
        klingon_cleanup(kot);
    
        //Setup analog control input functions
        for(int i = 0; i < N_KNOBS; i++)
        {
    		//deallocate memory from knobs
            knob_destructor(kp[i]);
        }
        free(kp);
    }

    Thank you...

    you need to remove the analysis folder and test_tonestack.cpp file from the klingon_tone project for it to run as a Bela project.

      Okay. I will remove test_tonestack.cpp like earlier when I built the files on the IDE in 2022.

      I will report back.

      Seth

      giuliomoro

      Do I need to install it as a .zip file or can I install the singular files in one lump part?

      Seth

      Sir,
      Look here:

      Building project ...
      make: Nothing to be done for 'all'.
      Build finished
      Running project ...
      KNOB is ACTIVE: 0, 0.027348
      KNOB is ACTIVE: 3, 0.003326
      KNOB is ACTIVE: 4, 0.020905
      KNOB 0 is INACTIVE.  Value: 0.022354
      KNOB 3 is INACTIVE.  Value: 0.002792
      KNOB 4 is INACTIVE.  Value: 0.020936
      Startup Delay Expired
      Bela stopped
      Building project ...
      Build finished
      Running project ...
      KNOB is ACTIVE: 0, 0.027597
      KNOB is ACTIVE: 3, 0.002321
      KNOB is ACTIVE: 4, 0.010049
      KNOB 0 is INACTIVE.  Value: 0.029029
      KNOB 3 is INACTIVE.  Value: 0.002823
      KNOB 4 is INACTIVE.  Value: 0.011579
      Bela stopped

      Does that seem right from this bit of data in png format?