[Coding] Several questions about the LXR code :-)

edited May 2014 in General
Hello,
I am at a point where I need to ask the community and julian some questions about the code:

1- int16_T (-32767 to + 32767) to float
2- Add more CC2 parameters
3- Add more sub page menu :-)
4- Refresh the LEDs
5- Refresh the values
  • int16_T (-32767 to + 32767) to float
I am trying to add some effects to the LXR machine. for instance here is a code to boost BASS:

    for(i=0;i<size;i++)
                buf[i] = BassBoost(buf[i]);
            break;

float BassBoost(float sample)
{
static float selectivity = 100.0, gain1= 50.0, gain2= 50.0, ratio = 50.0, cap;
gain1 = 1.0/(selectivity + 1.0);

cap= (sample + cap*selectivity )*gain1;
sample = saturate((sample + cap*ratio)*gain2);

return sample;
}


My issue is to convert -32767 +32767 values to FLOAT.. I am lost there :-(
could you help me ?
  • Add more CC2 parameters

I have an issue, I have exceeded the number of parameters (I added around 20 new parameters that exceed 256) ,

how can we add more parameters? 

  • Add more sub page menu :-)

I have an issue, I can't have more than 2 sub pages. Checking the code, I suppose it is normal as you only check if you have two pages.

how can we add more pages?

  •  Refresh the LEDs

How can I help on completing the following code to get LED ON/OFF?

frontParser_updateTrackLeds(const uint8_t trackNr, uint8_t patternNr)
{
    ....
for(i=start;i<(start+8);i++) //only send visible substeps
        {
            if(seq_isStepActive(trackNr,i,patternNr))
            {
                uart_sendFrontpanelByte(FRONT_STEP_LED_STATUS_BYTE);
                uart_sendFrontpanelByte(FRONT_LED_SEQ_SUB_STEP);
                uart_sendFrontpanelByte(i);
            }
        }
    }
}

  • Refresh the values

One of my funcioin is randomizing the values of the drum.. but values are not refreshed on the LCD. How could we change this?

Looking at the code I think we should send back to the front panel (throught frontpanelparser and uart...)

Can you help?

that's it!!!!

:-)

Comments

  • My issue is to convert -32767 +32767 values to FLOAT.. I am lost there

    when x is your value between -32767 and 32767,why not simply do a

    float y = x/32767.f;

    y would be a float between -1 and 1.

  • Add more CC2 parameters

    this could be complicated. I will have to look into it when I resume programming tomorrow.
    Can't say it without a look into the code and today is too late for something like that ;)
  • Add more sub menu pages

    In the lates firmware the global settings menu has 3 sub pages. maybe have a look there. The menu structure has to be changed quite a bit for that in menu.c on the AVR
  • Hello Julian and thanks for your answers !

    FLOAT

    I will make some test about transforming the UINT16 figures to floats using your techniques :-)
    I hope to deliver new FXs to the machine thanks to your trick ! I want as well to use the DSP math (LSR, LSL, QADD, etc...). let's see!

    For adding the CC2 parameters,
    I agree , it can be a difficult part ! so I will understand if you can't for the moment change the code. There are other priorities and I have a workaround!

    For the Subpages, I will check at the Global Setttings code, Thanks once more!

    Have a nice day :-)
  • I hope to deliver new FXs to the machine thanks to your trick ! I want as well to use the DSP math (LSR, LSL, QADD, etc...). let's see!
    Let me know if/when you start with this, I've done some cortex assembler re-writes in another project but haven't gotten around to doing anything concrete for LXR yet. I suspect there's a good boost to be had in the mixing code, but first I'd like to have a way of measuring where we are :)
  • Hello,
    I agree with you and I am also wondering where we are :-)
    I will give you updates on a regular basis.

    * I would be very interested by your other projects, are they on github?

    Right now, my main issue is translating UINT16 to FLOAT (-1.0 to +1.0) correctly. Undersand the MusicDSP algortihms, etc. I did some function to boost the bass, 3band EQ .. but the resulting sound is distorted !

    That's really what is stopping me for the moment. Well, meanwhile I play with the LXR of course!!!

    If you want you can stop reading my post here :-)

    Otherwise, I put below much more details about my plans:

    My philosophy is for the moment to write functions that answers my needs (I am selfish ;-) ) and release it early/often to get good ideas from the community (it helped me for the RND function for instance).

    I don't want to reinvent the wheel nor develop something that LXR community could have already done:-)

    I have to polish my current working function (the current functions are working but I am not happy when talking about refreshing values on the LCD  display nor about SAVE. Anyhow, these issues are not showstoppers, I will correct them little by little).

    Next, I would like to add sound design facilities and live oriented FX but my knowledge about coding is not as good as you think. I am more taking codes from other projects (open source, giving back the credits, etc) and reintegrate them into the LXR.

    I am telling you this as I would like to develop some new effects but I am not sure I will succeed :-(

    here is the functions I would like to add in the PERF menu:
    - A delay*: I have assembly code from the excellent opensource Sound art chameleon machine
    - A general filter or 3 band EQ.
    - Step sequence on the delay / general filter
    - Improve the OTO FX (I would like to use LSL/LSR arm assembly code instead of >> operator)

    * delay can be difficult due to the limit size of the buf[i] and the way it is created (each time a step is active). we may need to create a large buffer that handles long effects. you see I am not very good :-)

    well, I hope my english is not too much confusing and too verbose !
    Bye :-)

  • Well you have good goals, I'm more driven by implementation details than actual features :)

    By where we are I mean how many cycles are being used for specific operations, not necessarily the more philosophical question :) The other project was the PreenFM2, but I'm not sure if I pushed any of the assembler code since it's highly experimental an there's a danger of **==

    Are you sure you want uint16_t, which is unsigned? To convert to [-1,1] that would be something like float f = 1.f - 2.f *( (float)i / 65535.f ); but IIRC the data is int16_t. It should be possible to re-write effect to use fixed point instead and avoid the float/int conversions altogether.

    Long delay buffer might be difficult, there's only 64k of fast CCM ram and that runs out quickly...
  • Hello :-)

    "how many cycles are being used for specific operations"
    -> I see, my code is not optimzied at all, I wanted first to make it work. Now I am looking at this isue (N cycle).. and this is why I would like to change my OTO fx to use assembly code -> LSR , LSL Logical shift bits, etc. I have however an issue calling from the C langage the command LSR. I can call QADD but not LSR. Looking at the ST libs , I saw that QADD is defined but not LSR.. SO I created some assembly code using LSR command and this work. SO I will continue to develop my new OTO FX using assembly code and check the number of cycles :-)

    For the UINT_16.. I made a mistake in my english, I use INT16_T :-)
    SO I guess the formula float f = 1.f - 2.f *( (float)i / 65535.f ); is not anymore relevant in my case, no?
    would you mind giving me the new "float conversion" formula? I know I am chikky !!!

    Have a nice day!
  • The compiler will already use shift instructions, so you probably don't have to use an intrinsic for that. But the only way to know is to check the assembly output :) The main gains to be had are by better grouping of memory accesses and loops (gcc seems to suck at that) and avoiding pipeline stalls (especially for FPU).

    For the preenfm2 I would measure the cycles used by whole blocks of code (e.g. mixer) at runtime, and compare with a theoretically optimal version (usually by breaking it down to a cycles-per-sample value).

    Julian already gave a conversion from int16_t to (-1,1) above, it's just basic math. You might have to check for rounding/off-by-one since int16_t is (-32878,32767) and make sure to clamp correctly (SSAT) when converting back...

  • Oki ! thanks all these explanations :-)
    talk to you soon.
Sign In or Register to comment.