Jump to content

bank and patch up and down buttons


ssp
 Share

Recommended Posts

as the mb64e is not in "c" yet i have to use asm for this

Im trying to assign incremental functions to a set of 4 buttons, i did think of using meta events however im not sure how to go if i need to make a set of tables or not.

now the functions i want to use are the midi standard bank - and + also patch - and + so by using the buttons i can step up and down midi banks and patches on my synths.

the standard sysex functions called are as follows.

TIMESTAMP IN PORT STATUS DATA1 DATA2 CHAN NOTE EVENT

00001CAC 1 -- B0 00 01 1 --- CC: Bank MSB <---- this is the bank change command

00001CAC 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano <---- this is the patch change command

0000226A 1 -- B0 00 01 1 --- CC: Bank MSB

0000226A 1 -- C0 01 -- 1 --- PC: Brite Acc. Piano

0000277D 1 -- B0 00 01 1 --- CC: Bank MSB

0000278D 1 -- C0 02 -- 1 --- PC: Elec Grand Piano

00002C77 1 -- B0 00 01 1 --- CC: Bank MSB

00002C77 1 -- C0 03 -- 1 --- PC: Honky-Tonk Piano

00002DF0 1 -- B0 00 01 1 --- CC: Bank MSB

00002DF0 1 -- C0 04 -- 1 --- PC: Electric Piano 1

and here we change the banks, DATA 1 steps the bytes of each patch by 16 bytes ( i hope im right there) so from 50 to 5f steps up through patches 65 to 80

TIMESTAMP IN PORT STATUS DATA1 DATA2 CHAN NOTE EVENT

0001D2FF 1 -- B0 00 01 1 --- CC: Bank MSB

0001D2FF 1 -- C0 00 -- 1 --- PC: Acc. Grand Piano

0001E2B0 1 -- B0 00 01 1 --- CC: Bank MSB

0001E2B0 1 -- C0 10 -- 1 --- PC: Drawbar Organ

0001FC35 1 -- B0 00 01 1 --- CC: Bank MSB

0001FC35 1 -- C0 20 -- 1 --- PC: Acoustic Bass

000206A7 1 -- B0 00 01 1 --- CC: Bank MSB

000206A7 1 -- C0 30 -- 1 --- PC: String Ens 1

0002105D 1 -- B0 00 01 1 --- CC: Bank MSB

0002105D 1 -- C0 40 -- 1 --- PC: Soprano Sax

000214E4 1 -- B0 00 01 1 --- CC: Bank MSB

000214E4 1 -- C0 50 -- 1 --- PC: Lead1(square)

what i want to do is have the keys do a stepped decline or incremental mode that allows each press to step through or backwards through the banks/ patches and then be able to freely assign them to any button i wish as i would have done using the meta events feature with the editor.

so would i have to set up an incremental code string that holds each sysex byte all the way through from 00 to 5f for stepping upwards and then for declination i would reverse it 5f to 00.

The other reason for this is that i can set up several sets of these button features however give each set thier won midi channels and then use each set to control multiple softsynths in forte. so if i had say 4 softsynths running , i could have a bank/patch change set on channel 1 synth 1 and another on bank/patch channel 2 synth 2.

thanks

Link to comment
Share on other sites

ok today i did a quick test, using an encoder on a din sr i set the cc# to 0 and the min value to 0 and the max to 5, the reason for this is that the synth has 5 banks. when i turned the necoder it stepped nicely through the banks up and down with the turn of the encoder back and fore. now to apply this to a set of buttons i would need either a -1 or +1 byte assigned to each button, the same with patches. i cant find any subjects on the forum or ucapps that relate to this feature for making patch or bank buttons , the editor only has a bank feature for teh encoders, if you apply it to a button you only have a 0-127 state and a repeat press does not increment the patch it only jumps to the patch at the relative byte value, then back to the first patch on release.

how would i code a small script to achieve this function?

two buttons for bank and two buttons for patch labeled bank- bank+ patch- patch+

so the starting state for bank- is B0 00 00 a press of bank+ changes this to B0 00 01 which sets it to bank 2, pressing bank+ changes it to B0 00 02 which is bank 3, pressing bank- 2 times returns it to B0 00 00 bank 1.

and patch- initail state is C0 00 which is patch 1 then a press of patch+ gives you C0 01 which is patch 2 and then pressing patch- takes you back to C0 00 patch 1. basically the same function set as the banks however for the patches.

i cant find a cc# for patches that allows the stepping through of patches, if i can find this then i could assign an encoder to patches and have a button for the banks.

i am not sure if a step -1 and +1 function would need to be written in or a table of the complete sysex would be needed.

thanks

update: some of the softsynths im using will only respond to the sysex commands for bank and patch change they do not respond to the cc# of cc# 0 for bank and cc#32 for patch.

Edited by ssp
Link to comment
Share on other sites

Like I said in the chat for a simple +/-1 there's no need for tables. Simply increment and decrement your patch and bank.

My personal take on this would be to extend the MB64_BUTTON_Handler function in mb64_buttons.inc. Before the voodoo that happens there you could add sth along these lines (assuming you have 2 variables assigned called patch_num and bank_num):


sendpatchchange {
send bank and patch
}

if button id (MIOS_PARAMETER1) is Patch_Up
inc patch_num
if patch_num > 127
patch_num = 0
inc bank_num
if bank_num = 5
bank_num = 0
sendpatchchange
if button id (MIOS_PARAMETER1) is Patch_Down
dec patch_num
if patch_num > 127
patch_num = 127
dec bank_num
if bank_num > 5
bank_num = 5
sendpatchchange
if button id (MIOS_PARAMETER1) is Bank_Up
inc bank_num
if bank_num > 5
bank_num = 0
sendpatchchange
if button id (MIOS_PARAMETER1) is Bank_Down
dec bank_num
if bank_num > 5
bank_num = 0
sendpatchchange
[/code]

Obviously there's more elegant/faster ways, but this should do for starters.

Link to comment
Share on other sites

thanks nils, yes i understood that , however that would be in c and the mb64e isnt supporting c code yet.

ok so i just did a few changes to the encoders and realised that to change the patches its a program change not a cc# doh! so i assigned the program change to an encoder and bingo worked first time, so all that has to be done is to apply the two features to two sets of - and + buttons.

Link to comment
Share on other sites

  • 5 weeks later...

Simon asked me for help, but it's currently very difficult for me to find the time for giving an explicit example.

However, here some hints:

You need a variable which stores the patch number, another one which stores the bank number.

Search in app_defines.h for free locations.

E.g., 0x1d and 0x1e are not used yet (in MB64E!) - by adding

MY_PATCH_NUM EQU 0x1d
MY_PATCH_NUM EQU 0x1e[/code] these addresses are now yours! :) Now you have to create branches for all 4 buttons, similar to this example: http://svnmios.midibox.org/filedetails.php?repname=svn.mios&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox64e%2Fmeta_examples%2F2%2Fmb64e_meta.inc but you only need to consider the first four (MB64E_META_Handler_00 .. MB64E_META_Handler_03) - all others are not relevant and can be removed.
[code]
JUMPTABLE_2BYTES 4 ; 4 entries
rgoto MB64E_META_Handler_00
rgoto MB64E_META_Handler_01
rgoto MB64E_META_Handler_02
rgoto MB64E_META_Handler_03
Now you implement the functions based on Nil's pseudo code. "inc" (increment) can be done with "incf <variable-name>, F", such as "incf MY_PATCH_NUM, F" "if( patch_num > 127 )" is a bit complicated in assembly language. The easiest way is to check if the 8th bit is set, such as

btfsc PATCH_NUM, 7
clrf PATCH_NUM
[/code] (see datasheet for a description of these instructions) Such a simple check isn't possible for checks != 2^n, such as "if( bank_num > 5 )" There are instructions for such comparisons, and I also have some macros, but they are complicated to use (if I haven't programmed assembly for more than one year - like currently - I would need at least two tries to get this working ;)) So, it's easier to make an equivalence check, such as "if( bank_num == 5 ) bank_num = 0" Resulting instructions:
[code]
movf MY_BANK_NUM, W
xorlw 5
skpnz
clrf MY_BANK_NUM

Best Regards, Thorsten.

Link to comment
Share on other sites

thanks thorsten, i almost see what you mean now, i have some more reading to do again and lots of notes to make so i have reference again. I have been reading all my notes on the meta handler routine we did for the mmc unit and the mmc handlers so i am hoping that by the time i have read everything again and written some test code i will have a grasp of it again.

is it possible to say write something in "c" and then port it to the 452 core?

everyone has said i should move onto "c" now as it makes life much easier, i have found a website with details tutorials and tests so i am neck deep in that also.

so if i get that in my grasp or the basics i will try writing something and uploading the text here to see just how bad it is!.

thanks as always

Link to comment
Share on other sites

Hi Simon,

it was always unclear to me why you are not writing the whole application in C - it's much easier than adapting the assembly based MB64E firmware for your needs (especially since this firmware includes 90% features which you probably never use).

Another advantage: once you learned programming in C, you can re-use your code (and knowledge) for MIOS32 based applications later. :)

If you are searching for a text adventure, try the assembler approach.

But if you are searching for some sparetime fun (!), you should definitely go for C :)

Best Regards, Thorsten.

Link to comment
Share on other sites

hi thorsten.

the reason i stuck with the asm side of things was because i thought that the mb64e was still not ported to the new core unit, at the moment i think it still has not been ported or am i wrong? this was why i stayed using the assembler code.

is it possible to write something in c and still upload it to the 452's? this is what i am not dure of and also what has prevented myself from going to c. Im basically back to noob 101 again!

Link to comment
Share on other sites

it was always unclear to me why you are not writing the whole application in C - it's much easier than adapting the assembly based MB64E firmware for your needs (especially since this firmware includes 90% features which you probably never use).

A few years back I received exactly the same answer from Thorsten, and it turned out that he was completely right - with the MIOS C functions, everything I needed at that time could be implemented very easily. Go for it! :thumbsup:

Link to comment
Share on other sites

is it possible to write something in c and still upload it to the 452's? this is what i am not dure of and also what has prevented myself from going to c. Im basically back to noob 101 again!

Of course - just try out some examples from this page:

http://www.ucapps.de/mios8_c.html

E.g.

Sending MIDI events on button movements

Controlling 128 LEDs via MIDI

Sending 7bit MIDI events on rotary encoder movements

Printing values on a LCD

You can combine these examples to a bigger firmware and you could also adapt it for your own controlling requirements of course.

You won't need a Core32 for such experiments, and the 32k flash of PIC18F452 should be sufficient for your firmware.

It's really worth a try (as Ilmenator highlighted) :)

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...