Switch Bits Problem

Home Forums General Using Ctrlr Switch Bits Problem

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12550
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    OK I’m probably being really dumb and just need someone to point out the obvious mistake. However I seem unable crack this one. I have two instances where bits select options in Comboboxes the first method works the second method doesn’t.

    The first uses the last two bits thus (from KiwiTechnics manual):
    000000yx x = Off/On (set = On) y = Auto/Manual (set = Auto)

    This is my method, it works fine:

    byte = programData:getByte(59) 
    bi = BigInteger(byte)
    CS = bi:getBitRangeAsInt(0,1)
    CM = bi:getBitRangeAsInt(1,1)
    	if CS == 0 then
    	panel:getModulatorByName("Chorus On/Off"):setValueMapped ((00), false)
    	elseif CS == 1 then
    	if CM == 1 then
    	panel:getModulatorByName("Chorus On/Off"):setValueMapped ((01), false)
    	elseif CM == 0 then
    	panel:getModulatorByName("Chorus On/Off"):setValueMapped ((02), false)
    end

    The second uses the last three bits thus (from KiwiTechnics manual):
    00000yxw w = Gate (set = Gate – overrides x) x = Env 1/2 (set = Env2) y = LFO 1/2 (set = LFO2)

    This is my method, x and y seem to work fine however w does not work at all:

    byte = programData:getByte(62) 
    bi = BigInteger(byte)
    VS = bi:getBitRangeAsInt(0,1)
    VM = bi:getBitRangeAsInt(1,1)
    	if VS == 1 then
    	panel:getModulatorByName("VCA Mode"):setValueMapped ((00), false)
    	elseif VS == 0 then
    	if VM == 0 then
    	panel:getModulatorByName("VCA Mode"):setValueMapped ((01), false)
    	elseif VM == 1 then
    	panel:getModulatorByName("VCA Mode"):setValueMapped ((02), false)
    panel:getModulatorByName("VCA LFO Mod Source"):setValueMapped(bi:getBitRangeAsInt(2,1), false)
    end

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #12592
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    It’s your logic so i can’t really comment on that (i’d need to understand the whole program to understand this snippet).

    What i can propose, ident your code (better tabulation), if you can use pastebin.com to show us the code, explain why are you doin (00) (01) (02) where normal integer values are used, is “w” from the manual the variable VS in your code ?

    I recommend looking at the BigInteger (bi) when getting data to see what should happen and what is actualy happening

    console (bi:toString(2,8))
    
    #12596
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Hi Atom, yes the variable VS does refer to the “w” from the manual.

    The (00)(01)(02) in the method refers to the list of comboValues in the combobox.

    Update it seems that it is working! Your suggestion of checking the byte values in the console revelled that I was not getting the required byte back from the synth. Oddly this only affected one patch, the one I was using to test my script.

    Indenting code… when to tab that is the question?

    Thanks for your patience and assistance as always : )

    • This reply was modified 8 years, 8 months ago by lfo2vco.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13423
    msepsis
    Participant
    • Topics: 219
    • Replies: 732
    • Total: 951
    • ★★★

    Indenting code… when to tab that is the question?

    take your first example.. you’d want it to read something more like:

    http://pastebin.com/AAF3MFRP

    basically when you declare an “if” statement, the stuff after “then” should be indented. Then you back-tab when you want to close the “if” statement.. Especially in your example when you have embedded if statements it helps you understand what you’ve wrote and others understand when it comes time to help you out 🙂

    Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

    #13425
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Thanks msepsis a clear explanation. Oh, and thanks again for your explanation to my post ‘Help with Sysex please’ that really helped my get my panel going.

    By trial and error I am getting there. The panel now has a Save button that successfully dumps Sysex to the Kiwi-3P too! Almost done.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13443
    msepsis
    Participant
    • Topics: 219
    • Replies: 732
    • Total: 951
    • ★★★

    no problem on the help 🙂 This thread actually helped me out with getting and assigning parameter values from a program dump from the synth.. now i need to figure out how to send those values from two different knobs that control two different parameters to one sysex message.

    Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Using Ctrlr’ is closed to new topics and replies.
There is currently 0 users and 51 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr