Skip to content

Commit

Permalink
increasing preset/library size, not yet complete
Browse files Browse the repository at this point in the history
  • Loading branch information
neroroxxx committed Sep 13, 2020
1 parent 640091c commit 2529c18
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 46 deletions.
21 changes: 12 additions & 9 deletions docs/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# MIDI Events Library
BMC has an events library, these are events that are stored globally and can be used across hardware, these events contain MIDI Messages and are meant to make it easier to pre define some of your most used MIDI messages, for example, if you're a guitar player you'll likely want to use your controller to Engage/Bypass an effect on your processor, we'll use a delay as an example. This is commonly done with MIDI Control Change Messages, so let's say CC#100 is used to engage/bypass your Delay and your device is on Channel 1 and connected to Serial Port A, when you send CC#100 with value 127 the Delay is turned on, CC#100 with value 0 will bypass it.

BMC has a typedef for the library `bmcLibrary_t` this type will be a `uint8_t` if the library size is equal to or less than 255 and a `uint16_t` if it's more than 255.
This is to avoid using more RAM/EEPROM whenever the library size is 255 or less.

You can then create a Library message assigned to CC#100/CH#1/Value#127 and assign it to Serial Port A, do the same for Value#0 then set 2 button events one for PRESS and one for 2nd PRESS the PRESS trigger will send the engage library event and the 2nd PRESS will send the bypass message. Even better a library message for Control Change can be set to TOGGLE which will toggle the value sent so you only need 1 event to turn the Delay On/Off. **Toggling happens because BMC remembers the last value of any CC on any Channel that was sent or received and this feature is available across BMC**

Library Events also have their own PORT or PORT Preset, that means that you can assign the port that you want that preset to be sent to every time that library event is triggered. These are Global and do not change with page changes.
Expand All @@ -22,32 +25,32 @@ There are many API callbacks and functions available for use, these may not refl
```c++
// retrieve a Library event name
// must pass a pointer to your string with length >= BMC_NAME_LEN_LIBRARY
void getLibraryEventName(uint8_t n, char* t_string);
void getLibraryEventName(bmcLibrary_t n, char* t_string);

// send/execute a library event
void sendLibraryEvent(uint8_t n);
void sendLibraryEvent(bmcLibrary_t n);

// send a library even but override the port(s)
// example to send library event 0 to USB and Serial A ports at the same time
// sendLibraryEventToPorts(0, BMC_USB | BMC_SERIAL_A);
void sendLibraryEventToPorts(uint8_t n, uint8_t ports);
void sendLibraryEventToPorts(bmcLibrary_t n, uint8_t ports);

// retrieve the a library event as a 32-bit unsigned integer
uint32_t getLibraryEvent(uint8_t n);
uint32_t getLibraryEvent(bmcLibrary_t n);

// retrieve the status of a library event
uint8_t getLibraryEventStatus(uint8_t n);
uint8_t getLibraryEventStatus(bmcLibrary_t n);

// retrieve the channel of a library event
uint8_t getLibraryEventChannel(uint8_t n);
uint8_t getLibraryEventChannel(bmcLibrary_t n);

// retrieve the first MIDI word of a library event
uint8_t getLibraryEventData1(uint8_t n);
uint8_t getLibraryEventData1(bmcLibrary_t n);

// retrieve the second MIDI word of a library event
uint8_t getLibraryEventData2(uint8_t n);
uint8_t getLibraryEventData2(bmcLibrary_t n);

// retrieve the stored ports of a library event
uint8_t getLibraryEventPort(uint8_t n);
uint8_t getLibraryEventPort(bmcLibrary_t n);
```
##### CALLBACKS
20 changes: 14 additions & 6 deletions docs/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
# Presets
BMC Presets are basically collections of Library Events, you can compile presets to have up to 16 library events, you can also enable a startup preset which obviously will be executed upon BMC starting up. These are Global and do not change with page changes.

BMC has a typedef `bmcPreset_t` this will be either a `uint8_t` if the maximum number of presets compiled is 255 or less and `uint16_t` if the maximum number of presets compiled is higher than 255.

The same foes for the library in which case theres a typedef `bmcLibrary_t` which is a `uint8_t` if the library is equal to or less than 255 and a `uint16_t` if it's more than 255.

In either case this is to use less RAM/EEPROM depending of the size of the library and number of presets compiled.

BMC presets are also broken into banks, you select how many presets you want per bank in the config file maker, however, the maximum number of banks is locked at 255 and the maximum number of presets per bank is also and the output of (banks * presetsPerBank) can not exceed BMC_MAX_PRESETS.

Below is an example of how Library Events are part of Presets.

![Presets & Library](../images/presets-library.jpg)
Expand All @@ -20,16 +28,16 @@ There are many API callbacks and functions available for use, these may not refl
void getPresetName(char* t_string);

// retrieve a preset name
void getPresetName(uint8_t n, char* t_string);
void getPresetName(bmcPreset_t n, char* t_string);

// get how many library messages this preset has
uint8_t getPresetLength(uint8_t n);
uint8_t getPresetLength(bmcPreset_t n);

// get a library message id
uint8_t getPresetItem(uint8_t n, uint8_t e);
bmcLibrary_t getPresetItem(bmcPreset_t n, uint8_t e);

// get the current preset number
uint8_t getPreset();
bmcPreset_t getPreset();

// get the current preset bank
uint8_t getPresetBank();
Expand All @@ -38,7 +46,7 @@ uint8_t getPresetBank();
uint8_t getPresetInBank();

// change to a preset
void setPreset(uint8_t n);
void setPreset(bmcPreset_t n);

// go to the next preset
void presetUp(bool endless);
Expand Down Expand Up @@ -67,7 +75,7 @@ void presetInBankDown(bool endless);
##### CALLBACKS
```c++
// triggered when a BMC Preset has changed
void onPresetChange(void (*fptr)(uint8_t n));
void onPresetChange(void (*fptr)(bmcPreset_t n));
// triggered when a BMC Preset Bank has changed
void onPresetsBankChange(void (*fptr)(uint8_t n));
Expand Down
2 changes: 1 addition & 1 deletion src/BMC-Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class BMCApi : public BMC {
}
#endif
// triggered when a BMC Preset has changed
void onPresetChange(void (*fptr)(uint8_t n)){
void onPresetChange(void (*fptr)(bmcPreset_t n)){
callback.presetChanged = fptr;
}
// triggered when a BMC Preset Bank has changed
Expand Down
24 changes: 12 additions & 12 deletions src/BMC.midi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,29 @@ void BMC::incomingMidi(BMCMidiMessage message){
case BMC_NONE:
break;
case 1:
#if BMC_MAX_PAGE > 127
setPage((bank*128) + message.getData1());
#else
setPage(message.getData1());
#endif
#if BMC_MAX_PAGE > 127
setPage((bank*128) + message.getData1());
#else
setPage(message.getData1());
#endif
break;
case 2:
#if BMC_MAX_PRESETS > 127
presets.send((bank*128) + message.getData1());
#elif BMC_MAX_PRESETS > 0
presets.send(message.getData1());
#endif
#if BMC_MAX_PRESETS > 127
presets.send((bmcPreset_t) ((bank*128) + message.getData1()));
#elif BMC_MAX_PRESETS > 0
presets.send(message.getData1());
#endif
break;
}
} else if(message.isControlChange()){
// if BMC is set to listen to incoming messages, MIDI CC#0 on the
// specified channel is automatically the BANK control change
#if BMC_MAX_PAGE > 127 || BMC_MAX_PRESETS > 127
#if BMC_MAX_PAGE > 127 || BMC_MAX_PRESETS > 127
if(message.getData1() == 0){
bank = message.getData2() > 0 ? 1 : 0;
BMC_PRINTLN("MIDI Bank Changed", bank);
}
#endif
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utility/BMC-Callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class BMCCallbacks {
bool (*midiPreRoute)(BMCMidiMessage& data, uint8_t destinations);

void (*valueStream)(BMCValueStream item);
void (*presetChanged)(uint8_t n);
void (*presetChanged)(bmcPreset_t n);
void (*presetBankChanged)(uint8_t n);
void (*setListChanged)(uint8_t n);
void (*setListSongChanged)(uint8_t n);
Expand Down
2 changes: 1 addition & 1 deletion src/utility/BMC-Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class BMCLibrary {

#if BMC_MAX_CUSTOM_SYSEX > 0
BMCCustomSysEx& customSysEx;
void sendCustomSysEx(uint8_t index, uint8_t status, uint8_t ports){
void sendCustomSysEx(bmcLibrary_t index, uint8_t status, uint8_t ports){
uint8_t mode = BMC_CUSTOM_SYSEX_SEND_A;
if(status==0xF1){
mode = BMC_CUSTOM_SYSEX_SEND_B;
Expand Down
4 changes: 2 additions & 2 deletions src/utility/BMC-Presets.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class BMCPresets {
void scrollInBank(uint8_t t_amount, bool t_up, bool t_endless){
scrollInBank(t_amount, t_up, t_up, 0, BMC_MAX_PRESETS_PER_BANK-1);
}
void scrollInBank(uint8_t t_amount, uint8_t t_flags, uint8_t t_min, uint8_t t_max){
void scrollInBank(uint8_t t_amount, uint8_t t_flags, bmcPreset_t t_min, bmcPreset_t t_max){
scrollInBank(t_amount, bitRead(t_flags,0), bitRead(t_flags,1), t_min, t_max);
}
void scrollInBank(uint8_t t_amount, bool t_up, bool t_endless, uint8_t t_min, uint8_t t_max){
void scrollInBank(uint8_t t_amount, bool t_up, bool t_endless, bmcPreset_t t_min, bmcPreset_t t_max){
// first preset of bank
uint8_t s = bank * BMC_MAX_PRESETS_PER_BANK;
t_min += s;
Expand Down
16 changes: 2 additions & 14 deletions src/utility/BMC-Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,8 @@ class BMCSettings {
writeFlag(8, value);
}





// DATA BYTES
/*
// moved to settins.data[2] to increase value
uint8_t getButtonHoldThreshold(){
return settings.data[0] & 0x03;
}
void setButtonHoldThreshold(uint8_t value){
BMC_WRITE_BITS(settings.data[0],value,0x03,0);
}
*/
// data array

uint8_t getListenerChannel(){
return (settings.data[0]>>2) & 0x1F;
}
Expand Down

0 comments on commit 2529c18

Please sign in to comment.