learning the code

edited May 2015 in General
If I want to make features that I need/want I need to learn coding. So... Where do I start? What do I need?
All help is welcome :D

Thnx, C

Comments

  • edited May 2015
    it's on the wiki!
    how to get your dev environment set up:
    http://wiki.sonic-potions.com/index.php/Main_Page#Building_the_firmware_from_source

    where to get the source:
    https://github.com/SonicPotions/LXR

    this be a good place to start:
    http://wiki.sonic-potions.com/index.php/How_to_create_and_add_a_new_function_to_the_LXR

    ... though it doesn't cover everything by any means.

    my source:
    https://github.com/brendanclarke/LXR

    was there something specific you wanted to work on?
  • Well... I still think the way to select patterns while in voice mode is cumbersome. I would love to switch patterns without leaving voice mode
    Voice mode-> Perf mode -> select pattern -> voice mode.

    Another thing is solo, now shift + voice is unmute all until the selected voice but I never use that. Instead I prefer select + voice is solo.

    And a way to turn a knob without affecting the settings would be nice (don't like fetch)
  • In general, I try to add functions where there isn't an existing one, so the current manual always applies. a couple thoughts:
    - I don't think shift+play has any function yet. maybe 'next pattern'?
    - what is it you're trying to do with the knobs that you want them to 'not affect the settings'? The 3 standard potentiometer modes that frequently get implemented are 'jump', 'latch' (fetch), and 'scale'. There is (currently) no 'scale' pot mode on the LXR. would this help?
  • What I mean is, sometimes I want to adjust a parameter but the knob is in the wrong position . when it is a high impact parameter like bit reduction I would like the option to get the position I need without affecting the sound.
    And sometimes I would like to achieve the opposite, for instance, when you want to make a filter sweep from 0 to 100 but your knob is at 65 it would be nice to have the possibility to turn the knob all the way down without affecting the sound. Off course you can use and empty page for this but a dedicated function would be very helpful!


    I do understand what you mean with jump and latch but what do you mean with scale? is that like a fine tune setting?



    Reagrding the pattern selection: Shift play would be OK for me!
    Is shift rec used allready? Would be awesome to skip through the patterns in two directions!



    Thnx for thinking with me, much appreciated :D



    Cheers,
    C
  • edited May 2015
    yes, shift-rec allows you to select which automation track to record to and the quantization.

    'scale mode' in most instruments considers the direction you've turned the knob, relative to the parameter value. For example, if the parameter is at 80 and the knob is at 20, turning the knob down would reduce the parameter value from 80 - but much faster - so that when the knob reached 0, the parameter would also be 0. It's a nice 'compromise' setting, but can introduce some problems when the pot is at its limits!

    By all means, if you want to program in knob behaviour for what you want, go for it! But for something that specific, have you tried writing the parameters to an automation track instead and just switching patterns?

    I've also occasionally played around with a novel way of using the patterns in my firmware: Since you can copy individual tracks, and tracks copy from the *viewed* pattern rather than the *played* pattern, you can set up one or two 'template' patterns and have the rest as 'palette' patterns. Keep the 'template' playing and just view the 'palette' (shift-click the pattern in performance mode). You can now 'drop' tracks from your palette into the playing pattern without affecting the other tracks. You could, for example, have a pattern where all the tracks have filter sweep automation and then copy in the filter swept track when you want it.

    Hmm... there's a thought... maybe an option to copy automation only?
  • Hmm, Scale doesn't sound that appealing to me, also the resolution of the LXR is way to low for that imho.
    Maybe i should just get used to using the fetch mode...

    Your new way of using the patterns sounds quite interesting, really flexible!
    Copy automation only..? Things are getting complicated haha!

    Another question, you've put a lot of work in your version of the OS, do you know if Julian combines it with his version 1.0? I can imagine that combining his and your ideas + all the bugfixing makes one killing über OS !!!

    Cheers,
    C
  • the resolutions is too LOW! you would prefer to be able to sequence 1/256th notes? :D I'm not sure you're getting it... I need to make a video maybe. The idea is you use the sub-step resolution. So, if you wanted an 8 bar pattern, you still have 16th note resolution, but the 16th notes of the first bar, for example, are represented by the sub-steps of the first two main steps. You can also record straight into the scaled track via midi or the roll function and not mess with sub-steps at all.

    Julian is totally welcome to any of my additions :) That's the beauty of open source - it's all on github. Granted, my code could probably do with some optimization too.
  • Haha, noooo I mean the resolution of the knobs (0-127)!!! Sometimes I like a setting to be somewhere in between. Offcoarse this is one off the perks of a digital machine. Maybe i'm spoiled with my analog gear!
  • ah! too many simultaneous conversations! :)
    The resolution of the knobs is much better than that - i can't remember off hand what the resolution of the ADC is, but see for example the 'morph' parameter.
    Yes, the knob behaviour debate is indeed an old one :) remember, you can always edit a parameter directly from the encoder... I seem to remember that after clicking into a single parameter with the encoder, turning any of the other knobs kicks you out of that screen... maybe your troubles would be solved if it simply didn't do that?
  • edited May 2015

    I'm trying to learn the code too. My first goal is to use the for encoders while in editmode (after pressing the encoder) to tell the LXR that the active parameter become the LFO target of the same voice.My second goal is to use another encoder to change the depth of the LFO modulation.Then make the same thing for the velocity modulation with the two other encoder.i tried to modify the function in front -> LxrAvr -> Menu -> menu.c -> void menu_parseKnobValue(uint8_t potNr, uint8_t potValue)i write the following code before the original one, but i have just copy paste code for the LFO target (i don't understand  and it those nothing:

    screensaver_touch();

    if ((editModeActive != 0) && (potNr == 0)) {

    uint8_t activeParameter = menuIndex & MASK_PARAMETER;

    uint8_t activePage = (menuIndex&MASK_PAGE)>>PAGE_SHIFT;

    uint16_t paramNr = pgm_read_word(&menuPages[menu_activePage][activePage].bot1 + activeParameter);

    uint8_t *paramValue = &parameter_values[paramNr];

    menu_TargetVoiceGapIndex = getModTargetGapIndex(*paramValue);

    uint8_t value = (uint8_t)pgm_read_word(&modTargets[*paramValue].param);

    uint8_t upper,lower;

    upper = (uint8_t)((uint8_t)((value&0x80)>>7) | (((paramNr - PAR_TARGET_LFO1)&0x3f)<<1));

    lower = value&0x7f;

    frontPanel_sendData(CC_LFO_TARGET,upper,lower);

    }

    … other else if etc.

    screensaver_touch();

    //leave edit mode if active

    editModeActive = 0;

    the rest is the original code

    This code change nothing in the way the LXR is acting, i was hoping to turn the first encoder while in editmode to send the active parameter to the LFO target. No luck, so i'm asking myself if i'm totally wrong cause i'm a noob or if i'm missing something (certainly both).

    I'm trying to understand better the code cause i have another idea. While in editmode, use the button to select a value to load a kit, a pattern, change a parameter value etc. The most parameters have a value between 0 and 127. We have 8 button (osc, aeg,…, mix) and 16 for the steps. Imagine to press osc then a stepbutton to select a value between 1-16, aeg to then a stepbutton for a value between 17-32, …., mix for 113-128. Then use the voice, perf, step, load buttons to select a kit or load a pattern, or change a parameter with this value.

    i have code something a bit similar in renoise with duplex for the launchpad, but it was in lua.

  • quick point of terminology, potentiometer != encoder. The four knobs at the bottom are potentiometers or pots, the knob to the right is an encoder.

    I'd say the first thing is to edit menu_parseKnobValue and make sure you can get it to not kick you out of editModeActive on knob turn as a sanity check (ie, have it stay on the single-parameter-editing screen). Then try using an explicit paramNr rather than trying to get it from the active param to make sure that bit is ok. Try to get the parameter from the manu last, after you know everything else is ok.

    I haven't done too much with the mod destinations, but there is some hackishness with the way the parameters get moved around with them. You might also look in the function:
    static void menu_encoderChangeParameter

    where it says:
    case DTYPE_TARGET_SELECTION_LFO:

    to see how the lfo parameter is retreived there.

    good luck!
  • Thanks for the feedback,

    I was often using a wrong name to define knobs like potentiometer or encoder.

    "make sure you can get it to not kick you out of editModeActive on knob turn".

    I put the original code in a else{} at the end of my code, so the LXR stay in edit mode while turning a pot.

    "Try to get the parameter from the menu last", good idea, i will try to see how to send a specific parameter to the LFO target of the selected voice. And only after this is working, see how to translate the active parameter in editmode to an LFO target. I was trying to much different things at the same time.

  • I think that's the single biggest piece of advice I could give anyone working on code... "try the smallest possible change you can think of and test that first." :)

    good luck!
  • edited May 2015
    Hello everyone,
    I wrote a tutorial about the LXr programming on the WIki of the LXR sonic potion website.
    I know that the tutorial is not well written (it's a mess ;-) )  but I think you could start by having a look at it ;-)
    regards.
  • edited May 2015
    i would like a hint or two as to locating the DSP section of the code.  there are a lot of files.  i'm not lazy, i couldn't find them, and im hoping someone has already seen these files and can just tell me where to look.
  • Have a look here => master/mainboard/LxrStm32/src/DSPAudio/lfo.c is were the LFO is coded. And perhaps give a look at the modification from brendanclark to have a one shot LFO. Perhaps it can give you some inspiration.
  • great tip, thx!
  • edited June 2015

    A feed-back about my test to send a modulation target to the LFO while in editmode. I was trying to send the currently selected parameter to the LFO target, but "try the smallest possible change you can think of and test that first", make me realize that i was testing to do and understand to much things in the same time. So, I tried to send the coarse parameter (OSC), attack(AEG), decay(AEG), filter frequency (Filter), respectively with pot 1,2,3,4 while in edit mode to the LFO of the currently selected voice. So in the function menu_parseKnobValue() i make some changes like :

    uint8_t VNr = menu_getActiveVoice(); //max 6 => 0x6 = 0b110

    uint8_t incx = 0;

    if ((editModeActive != 0) && (potNr == 0)) {

    if (VNr == 0){

    incx = 2; /// 2 = coarse, 5 = attack, 6 = decay, 21 = filter freq

    ... other else if for other voices and pots 

    uint8_t inc = incx;

    if (inc != 0){

    uint16_t paramNr = pgm_read_word(&menuPages[VNr][6].bot8); /// the LFO mod parameter

    uint8_t *paramValue = &parameter_values[paramNr]; /// the LFO mod parameter value

    *paramValue = 0;

    *paramValue = (uint8_t)(*paramValue + inc);

    Then i use the code from "static void menu_encoderChangeParameter(int8_t inc)". And it works !!! Looking in the file /menuPages.h helps me to change the value in pgm_read_word ([VNr=the selected voice][6=the lfo page].bot8 = the 8th parameter from the LFO page. So the LXR act like I was turning the encoder from off  0 to incx value while in editmode. I find this cool to select four different parameter without the need to go to the LFO page. And then I got another idea…

  • To use the pots to change the original value of the parameter being modulated by the LFO. I will try to make it short. If I'm in edit mode and on the drum voice 3. When I turn the pot 1, the LFO will modulate the coarse parameter (not from the drum voice 3, but the voice selected in the LFO page). And the pot 1 will change the coarse value of the voice selected in the LFO page. Changing between 4 different target and there value at the same time is pretty cool.

    Then I realized another thing… If the mod value of the LFO is set to 0; I can select the LFO Voice parameter, press the encoder to go in edit mode, turn the encoder to select a voice, and turn a pot to change a value of this voice. A bit like a Matrix with four pot changing the same parameter on different voices. And it works :-))

  • xirso, have you seen the wishlist at the wiki?  do any of those items seem realistic to you or do you think they take too much CPU power?
  • edited June 2015
    it looks like most of the code of LXR is in C
  • I'm a noob about memory or CPU usage. I ask myself the same question. In my representation every change that affect sounds parameter and must be calculated in real time and affect different things, "like forward, backward, random, ping-pong" for the sequencer can be difficult. I imagine that when we change the sequencer direction it could affect LFO sync, step position of every track and sound etc. It's represent much info to transmit and receive. Other change seem's more cosmetic like "Change letter input when saving" or a question of workflow like "Select pattern in voice mode". But I'm unable to calculate how much things can be add or not. 
  • I have change my code concerning the edit mode. If your in edit mode, turning a pot will assign this parameter to this pot on the selected voice. So every time your in edit mode and turn a pot it will change the parameter assign to this pot on this voice. If you want to assign another parameter to a pot that's all ready have been assigned. Pressing shift and turning the pot will erase the previously assigned parameter. So four different pot can control four different value. I find this feature pretty nice. All seem's to work fine, but when i update the firmware, at the end of the process the LCD doesn't show "success, please reboot", the LXR is acting like i was starting it showing the firmware number and going in voice mode. The firmware is updated and all my code work. Strange, I don't understand why, i have only change the code in menu.c. And don't know why the LXR act like this?
    if someone want to try this feature or read dirty code, here are the menu.c and firmware files. Please, be sure to save all your work etc. before testing this. It's experimental.

    image image
  • I add some features in the 0.36 firmware (only changing the code in menu.c file), using main-step and sub-step value to select a preset number or change the pattern repeat and next value. More details in the pdf. And the firmware and the menu.c file, if you want to test it. All seems ok... But I have two questions
    In the original code:
    "DISABLE_CONV_WARNING" "END_DISABLE_CONV_WARNING" is used to avoid the warning during the compilation if we change a int to  a uint value?
    When i load a custom firmware, the lcd screen show:
    "please reboot" or "the parameters of the first page" or "strange characters". But, i don't understand why the screen isn't showing the same characters after the different firmware update? I turn off then on the lxr, and my firmware work always.
Sign In or Register to comment.