Skip to content

Commit

Permalink
v0.1.0 Updated Fas Sync, Added Fas Looper Control
Browse files Browse the repository at this point in the history
  • Loading branch information
neroroxxx committed Aug 28, 2020
1 parent 8cbe4e4 commit e909293
Show file tree
Hide file tree
Showing 22 changed files with 848 additions and 518 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=BMC
version=0.0.19
version=0.1.0
author=Nero Rox
maintainer=Nero Rox <info@roxxxtar.com>
sentence=Badass MIDI Controller (BMC), a fully featured MIDI Controller with a Desktop Editor App. For 32-bit Teensy Only
Expand Down
8 changes: 8 additions & 0 deletions src/BMC-Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ class BMCApi : public BMC {
void onFasTunerReceived(void (*fptr)(BMCTunerData& data)){
callback.fasTunerReceived = fptr;
}
// triggered when the FAS Looper has been activated or stopped
void onFasLooperStateChange(void (*fptr)(bool state)){
callback.fasLooperStateChange = fptr;
}
// triggered when the FAS Looper data has been received
void onFasLooperReceived(void (*fptr)(uint8_t data, uint8_t position)){
callback.fasLooperReceived = fptr;
}
// triggered when FAS CPU usage has been received
void onFasCpuReceived(void (*fptr)(uint8_t n)){
callback.fasCpuReceived = fptr;
Expand Down
4 changes: 2 additions & 2 deletions src/BMC-Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

// BMC Version stored in EEPROM (for editor usage)
#define BMC_VERSION_MAJ 0
#define BMC_VERSION_MIN 0
#define BMC_VERSION_PATCH 19
#define BMC_VERSION_MIN 1
#define BMC_VERSION_PATCH 0

//16 bits unsigned, LSB byte is minor, MSB byte is major
#define BMC_VERSION ((BMC_VERSION_MAJ<<8) | BMC_VERSION_MIN)
Expand Down
18 changes: 11 additions & 7 deletions src/BMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BMC::BMC():
,helix(midi)
#endif
#ifdef BMC_USE_FAS
,fas(midi)
,fas(midi, globals)
#endif
#ifdef BMC_USE_KEMPER
,kemper(midi)
Expand Down Expand Up @@ -112,6 +112,10 @@ void BMC::begin(){

delay(100);

#ifdef BMC_USE_FAS
fas.begin();
#endif

// this flag will allow BMC to execute some code only the first time update() runs
// yes that code can run here instead HOWEVER by letting that code execute
// after the first loop we are allowing other classes with a begin() method
Expand Down Expand Up @@ -180,20 +184,20 @@ void BMC::update(){
callback.midUpdate();
}

#ifdef BMC_USE_HELIX
#ifdef BMC_USE_HELIX
helix.update();
#endif
#endif

#ifdef BMC_USE_FAS
#ifdef BMC_USE_FAS
fas.update();
if(fas.connectionStateChanged()){
editor.utilitySendFasState(fas.getConnectedDeviceId());
}
#endif
#endif

#ifdef BMC_USE_KEMPER
#ifdef BMC_USE_KEMPER
kemper.update();
#endif
#endif

// Read/Update the hardware: buttons, leds, pots, encoders
readHardware();
Expand Down
7 changes: 7 additions & 0 deletions src/BMC.debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void BMC::readDebug(){

#ifdef BMC_USE_FAS
BMC_PRINTLN("fasConnection = Toggle the connection state of a FAS device");
BMC_PRINTLN("fasDebug = Toggle Additional debug information of synced FAS device");
#endif

BMC_PRINTLN("storageDebug = Prints the time it takes to read/write/clear EEPROM everytime the actions happens");
Expand Down Expand Up @@ -84,6 +85,12 @@ void BMC::readDebug(){
fas.connect();
}
printDebugHeader(debugInput);

} else if(BMC_STR_MATCH(debugInput,"fasDebug")){
printDebugHeader(debugInput);
BMC_PRINTLN("FAS Debug:",globals.toggleFasDebug());
printDebugHeader(debugInput);

#endif
} else if(BMC_STR_MATCH(debugInput,"storageDebug")){
printDebugHeader(debugInput);
Expand Down
3 changes: 2 additions & 1 deletion src/BMC.editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ void BMC::assignStoreData(){
}
void BMC::assignSettings(){
// Set the global settings
valueTyper.setOffset(settings.getTyperOffSet());
midiClock.setMaster(settings.getMasterClock());
midiActiveSense.setOutputPorts(settings.getListenerPorts());
midi.setListenerEnable(settings.getIncomingListenerEnabled());
Expand All @@ -91,6 +90,8 @@ void BMC::assignSettings(){
midi.setClockListenerPort(settings.getClockInputPortBit());
editor.setChainingPort(settings.getChainingPort());

valueTyper.setOffset(settings.getTyperOffSet());

midi.setRouting(BMC_USB, settings.getUsbRouting());
#ifdef BMC_MIDI_SERIAL_A_ENABLED
midi.setRouting(BMC_SERIAL_A, settings.getSerialARouting());
Expand Down
22 changes: 9 additions & 13 deletions src/BMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,20 @@
#include "midi/BMC-MidiActiveSense.h"
#include "editor/BMC-Editor.h"



#ifdef BMC_USE_BEATBUDDY
#include "utility/BMC-BeatBuddy.h"
#if defined(BMC_USE_FAS)
#include "sync/fas/BMC-Fas.h"
#endif

#ifdef BMC_USE_HELIX
#include "utility/BMC-Helix.h"
#if defined(BMC_USE_KEMPER)
#include "sync/kemp/BMC-Kemp.h"
#endif

#ifdef BMC_USE_FAS
#include "addon/BMC-Fas-Def.h"
#include "addon/BMC-Fas-Struct.h"
#include "addon/BMC-Fas.h"
#if defined(BMC_USE_BEATBUDDY)
#include "sync/beatbuddy/BMC-BeatBuddy.h"
#endif

#ifdef BMC_USE_KEMPER
#include "addon/BMC-Kemper.h"
#if defined(BMC_USE_HELIX)
#include "sync/helix/BMC-Helix.h"
#endif

#if defined(BMC_MUX_AVAILABLE)
Expand Down Expand Up @@ -223,7 +219,7 @@ class BMC {
#endif

#if defined(BMC_USE_KEMPER)
// handles Kemper devices see src/addon/BMC-Kemper.h
// handles Kemper devices see src/sync/BMC-Kemper.h
BMCKemper kemper;
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/BMC.hardware.buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ void BMC::handleGlobalButton(uint8_t index, uint8_t t_trigger){
} else {
fas.connect();
}
} else if(byteA>=5){// looper
fas.looperControl(byteA-5);
}
break;
case BMC_BUTTON_EVENT_TYPE_FAS_PRESET:
Expand Down
15 changes: 15 additions & 0 deletions src/BMC.hardware.ledEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ uint8_t BMC::handleLedEvent(uint8_t index, uint32_t event, uint8_t ledType){
return fas.isTunerActive();
} else if(byteA==2){
return fas.tempoReceived() ? BMC_PULSE_LED_EVENT : BMC_IGNORE_LED_EVENT;
} else if(byteA==3){
return fas.looperStatus(BMC_FAS_LOOPER_STATE_PLAYING);
} else if(byteA==4){
return fas.looperStatus(BMC_FAS_LOOPER_STATE_RECORDING);
} else if(byteA==5){
return fas.looperStatus(BMC_FAS_LOOPER_STATE_OVERDUBBING);
} else if(byteA==6){ // recording OR looping
return fas.looperStatus(BMC_FAS_LOOPER_STATE_OVERDUBBING) ||
fas.looperStatus(BMC_FAS_LOOPER_STATE_RECORDING);
} else if(byteA==7){
return fas.looperStatus(BMC_FAS_LOOPER_STATE_REVERSED);
} else if(byteA==8){
return fas.looperStatus(BMC_FAS_LOOPER_STATE_HALF);
} else if(byteA==9){ // stopped but has a track recorded
return fas.looperStopped() && fas.looperTrackRecorded();
}
break;
case BMC_LED_EVENT_TYPE_FAS_PRESET:
Expand Down
1 change: 1 addition & 0 deletions src/editor/BMC-Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BMCEditor {
BMC-Editor.cpp
*/
BMCEditor(bmcStore& t_store, BMCMidi& t_midi, BMCSettings& t_settings, BMCMessenger& t_messenger);

void begin();
void update();
bool readyToReload();
Expand Down
3 changes: 3 additions & 0 deletions src/editor/BMC-Editor.midi.global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ void BMCEditor::globalBuildInfoMessage(){// BMC_GLOBALF_BUILD_INFO
#ifdef BMC_USE_POT_TOE_SWITCH
bitWrite(buildData,17,1);
#endif
#ifdef BMC_USE_FAS3
bitWrite(buildData,18,1);
#endif

// remove after out of beta
bitWrite(buildData, 31, 1);
Expand Down
File renamed without changes.
27 changes: 26 additions & 1 deletion src/addon/BMC-Fas-Def.h → src/sync/fas/BMC-Fas-Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#ifndef BMC_FAS_DEF_H
#define BMC_FAS_DEF_H


// Fractal Compatible Device IDs
#define BMC_FAS_DEVICE_ID_AXE_FX_II 0x03
#define BMC_FAS_DEVICE_ID_AXE_FX_II_XL 0x06
#define BMC_FAS_DEVICE_ID_AXE_FX_II_XL_PLUS 0x07
#define BMC_FAS_DEVICE_ID_AX8 0x08
#define BMC_FAS_DEVICE_ID_AXE_FX_III 0x10
#define BMC_FAS_DEVICE_ID_FM3 0x11

// Fractal Block IDs
#define BMC_FAS_BLOCK_CPR 100
Expand Down Expand Up @@ -147,6 +148,30 @@
#ifndef BMC_FAS_CC_SCENE_DEC
#define BMC_FAS_CC_SCENE_DEC 124
#endif
#ifndef BMC_FAS_CC_LOOPER_RECORD
#define BMC_FAS_CC_LOOPER_RECORD 28
#endif
#ifndef BMC_FAS_CC_LOOPER_PLAY
#define BMC_FAS_CC_LOOPER_PLAY 29
#endif
#ifndef BMC_FAS_CC_LOOPER_ONCE
#define BMC_FAS_CC_LOOPER_ONCE 30
#endif
#ifndef BMC_FAS_CC_LOOPER_DUB
#define BMC_FAS_CC_LOOPER_DUB 31
#endif
#ifndef BMC_FAS_CC_LOOPER_REVERSE
#define BMC_FAS_CC_LOOPER_REVERSE 32
#endif
#ifndef BMC_FAS_CC_LOOPER_BYPASS
#define BMC_FAS_CC_LOOPER_BYPASS 33
#endif
#ifndef BMC_FAS_CC_LOOPER_HALF
#define BMC_FAS_CC_LOOPER_HALF 120
#endif
#ifndef BMC_FAS_CC_LOOPER_UNDO
#define BMC_FAS_CC_LOOPER_UNDO 121
#endif

// BLOCK PARAMETERS

Expand Down
43 changes: 33 additions & 10 deletions src/addon/BMC-Fas-Struct.h → src/sync/fas/BMC-Fas-Struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
See LICENSE file in the project root for full license information.
Wrapper to control/read from Fractal Audio Devices
Currently only supports Axe Fx II/XL/+ and AX8
Support for Axe Fx 3 and FM3 is planned for the future
*/
#ifndef BMC_FAS_STRUCT_H
#define BMC_FAS_STRUCT_H
Expand All @@ -13,7 +17,7 @@

#if defined(BMC_USE_FAS)

#include "addon/BMC-Fas-Def.h"
#include "sync/fas/BMC-Fas-Def.h"

// Fractal Device ID, only AX8 supported at the moment
// ------------------------
Expand All @@ -28,6 +32,7 @@
// 0x08 AX8
// 0x0A FX8 mk2
// 0x10 Axe-Fx III
// 0x11 FM3

struct BMCFasBlocks {
uint8_t id = 0;
Expand Down Expand Up @@ -123,23 +128,40 @@ struct BMCFasBlockStates {
}
};
struct BMCFasLooper {
bool enabled = false;
uint8_t data;
uint8_t position;
void set(uint8_t t_data, uint8_t t_position){
data = t_data;
position = t_position;
}
bool recording(){ return bitRead(data, 0); }
bool play(){ return bitRead(data, 1); }
bool once(){ return bitRead(data, 2); }
bool overdub(){ return bitRead(data, 3); }
bool reverse(){ return bitRead(data, 4); }
bool half(){ return bitRead(data, 5); }
bool undo(){ return bitRead(data, 6); }
void changeState(bool value){
enabled = value;
}
bool getStates(uint8_t bit=255){
if(bit<=6){
return bitRead(data, bit);
} else {
return data;
}
return false;
}
bool isEnabled(){ return enabled; }
bool recording(){ return bitRead(data, BMC_FAS_LOOPER_STATE_RECORDING); }
bool playing(){ return bitRead(data, BMC_FAS_LOOPER_STATE_PLAYING); }
bool once(){ return bitRead(data, BMC_FAS_LOOPER_STATE_ONCE); }
bool overdubbing(){ return bitRead(data, BMC_FAS_LOOPER_STATE_OVERDUBBING); }
bool reversed(){ return bitRead(data, BMC_FAS_LOOPER_STATE_REVERSED); }
bool half(){ return bitRead(data, BMC_FAS_LOOPER_STATE_HALF); }
bool undo(){ return bitRead(data, BMC_FAS_LOOPER_STATE_UNDO); }


uint8_t getPosition(){ return position; }
void reset(){
data = 0;
position = 0;
// do not reset the enabled as it's controller by BMC Settings.
//enabled = false;
}
};

Expand All @@ -156,7 +178,6 @@ struct BMCFasData {
BMCFasBlockStates blocks;
BMCFasLooper looper;


uint16_t parameters[8];
uint16_t parametersX[8];
uint16_t parametersY[8];
Expand Down Expand Up @@ -219,7 +240,9 @@ struct BMCFasData {
}
return 255;
}

bool getLooperState(){
return looper.isEnabled();
}


void setIdAndPort(uint8_t t_id, uint8_t t_port){
Expand Down
Loading

0 comments on commit e909293

Please sign in to comment.