Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send volume changes to controller #310

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/controller/binding.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef int LupppAction;
class Binding
{
public:
Binding() : status(0), data(0), action(0), active(1),
Binding() : status(0), data(0), echo(1), action(0), active(1),
track(-2),scene(-1),send(-1)
{
ID = privateID++;
Expand All @@ -38,6 +38,7 @@ public:

unsigned char status;
unsigned char data;
unsigned char echo;

/// the action this binding relates to: this is an integer based on the
/// event.hxx enumeration of event types
Expand Down
13 changes: 7 additions & 6 deletions src/controller/controller.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <string>

#include "../event.hxx"
#include "../gridlogic.hxx"

/** Controller
Expand Down Expand Up @@ -64,16 +65,16 @@ public:
/// master
virtual void masterInputVol(float f) {}
virtual void masterInputTo(int to,float f) {}
virtual void masterInputToActive(int to,float f) {}
virtual void masterVolume(float f) {}
virtual void masterInputToActive(int to, bool a) {}
virtual void masterVolume(float f, Event::SOURCE s) {}
virtual void masterReturnVolume(float f) {}
virtual void metronomeEnable(bool b) {}

/// FX
virtual void trackSend(int t, int send, float v) {}
virtual void trackSend(int t, int send, float v, Event::SOURCE s) {}
virtual void trackSendActive(int t, int send, bool a) {}

virtual void trackJackSend(int t, float v) {}
virtual void trackJackSend(int t, float v, Event::SOURCE s) {}
virtual void trackJackSendActivate(int t, bool a) {}

/// Time
Expand All @@ -84,9 +85,9 @@ public:
virtual void specialScene(int t, int scene) {}

/// track functionality
virtual void pan(int t, float p) {}
virtual void pan(int t, float p, Event::SOURCE s) {}
virtual void mute(int t, bool b) {}
virtual void volume(int t, float f) {}
virtual void volume(int t, float f, Event::SOURCE s) {}
virtual void progress(int t, int s, float f) {}
virtual void recordArm(int t, bool r) {}
virtual void setSceneState(int track, int scene, GridLogic::State s) {}
Expand Down
115 changes: 102 additions & 13 deletions src/controller/genericmidi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,61 @@ std::string GenericMIDI::getEmail()
return email;
}

void GenericMIDI::volume(int t, float f)
void GenericMIDI::masterVolume(float f, Event::SOURCE s)
{

for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);

if ( b->action == MASTER_VOL) {
if ( b->echo || s != Event::SOURCE_MIDI ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = f * 127;
writeMidi( data );
return;
}
}
}
}

void GenericMIDI::volume(int t, float f, Event::SOURCE s)
{

for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);

if ( b->action == TRACK_VOLUME && b->track == t ) {
if ( b->echo || s != SOURCE_MIDI ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = f * 127;
writeMidi( data );
return;
}
}
}
}

void GenericMIDI::pan(int t, float f, Event::SOURCE s)
{

for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);

if ( b->action == TRACK_PAN && b->track == t ) {
if ( b->echo || s != SOURCE_MIDI ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = 0.5 * (f + 1) * 127;
writeMidi( data );
return;
}
}
}
}

void GenericMIDI::recordArm(int t, bool enabled)
Expand Down Expand Up @@ -160,19 +212,21 @@ void GenericMIDI::metronomeEnable(bool enabled)
}
}

void GenericMIDI::trackSend(int t, int send, float v)
void GenericMIDI::trackSend(int t, int send, float v, Event::SOURCE s)
{

for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);

if ( b->action == TRACK_SEND && b->track == t && b->send == send ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = v * 127;
writeMidi( data );
return;
if ( b->echo || s != SOURCE_MIDI ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = v * 127;
writeMidi( data );
return;
}
}
}
}
Expand All @@ -193,13 +247,39 @@ void GenericMIDI::trackSendActive(int t, int send, bool a)
}
}

void GenericMIDI::trackJackSend(int t, float v)
void GenericMIDI::trackJackSend(int t, float v, Event::SOURCE s)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);

if ( b->action == TRACK_JACKSEND && b->track == t ) {
if ( b->echo || s != SOURCE_MIDI ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = v * 127;
writeMidi( data );
return;
}
}
}

}

void GenericMIDI::trackJackSendActivate(int t, bool a)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);

if ( b->action == TRACK_JACKSEND_ACTIVATE && b->track == t ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = a ? 127 : 0;
writeMidi( data );
return;
}
}

}

Expand Down Expand Up @@ -251,10 +331,13 @@ void GenericMIDI::midi(unsigned char* midi)

switch( b->action ) {
case Event::TRACK_VOLUME:
jack->getLogic()->trackVolume( b->track, value );
jack->getLogic()->trackVolume( b->track, value, Event::SOURCE_MIDI );
break;
case Event::TRACK_PAN:
jack->getLogic()->trackPan( b->track, 2 * value - 1, Event::SOURCE_MIDI );
break;
case Event::TRACK_SEND:
jack->getLogic()->trackSend( b->track, b->send, value );
jack->getLogic()->trackSend( b->track, b->send, value, Event::SOURCE_MIDI );
break;
case Event::TRACK_SEND_ACTIVE:
jack->getLogic()->trackSendActive( b->track, b->send, b->active );
Expand All @@ -263,7 +346,7 @@ void GenericMIDI::midi(unsigned char* midi)
jack->getLogic()->trackRecordArm( b->track, b->active );
break;
case Event::TRACK_JACKSEND:
jack->getLogic()->trackJackSend(b->track,value);
jack->getLogic()->trackJackSend( b->track, value, Event::SOURCE_MIDI );
break;
case Event::TRACK_JACKSEND_ACTIVATE:
jack->getLogic()->trackJackSendActivate(b->track,b->active);
Expand Down Expand Up @@ -327,7 +410,7 @@ void GenericMIDI::midi(unsigned char* midi)
break;

case Event::MASTER_VOL:
jack->getLogic()->trackVolume( -1 , value );
jack->getLogic()->trackVolume( -1 , value, Event::SOURCE_MIDI );
break;
}
}
Expand Down Expand Up @@ -571,6 +654,12 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
tmp->status = statusJson->valueint;
tmp->data = dataJson->valueint;

// gets the echo value from the JSON string
cJSON* echoJson = cJSON_GetObjectItem( binding, "echo" );
if ( echoJson ) {
tmp->echo = echoJson->valueint;
}

// gets the Action type from the JSON string
cJSON* activeJson = cJSON_GetObjectItem( binding, "active" );
if ( activeJson ) {
Expand Down
9 changes: 6 additions & 3 deletions src/controller/genericmidi.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef LUPPP_GENERIC_MIDI_H
#define LUPPP_GENERIC_MIDI_H

#include "../event.hxx"
#include "controller.hxx"

#include <string>
Expand Down Expand Up @@ -56,16 +57,18 @@ public:

void launchScene( int scene );

void volume(int t, float f);
void masterVolume(float f, Event::SOURCE s);
void volume(int t, float f, Event::SOURCE s);
void pan(int t, float f, Event::SOURCE s);


void recordArm(int t, bool b);
void setSceneState(int track, int clip, GridLogic::State s);

void trackSend(int t, int send, float v);
void trackSend(int t, int send, float v, Event::SOURCE s);
void trackSendActive(int t, int send, bool a);

virtual void trackJackSend(int t, float v);
virtual void trackJackSend(int t, float v, Event::SOURCE s);
virtual void trackJackSendActivate(int t, bool a);

/// footswitch -> scene launch controls
Expand Down
24 changes: 12 additions & 12 deletions src/controller/guicontroller.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ void LupppGUI::masterInputTo(int to,float f)
writeToGuiRingbuffer( &e );
}

void LupppGUI::masterInputToActive(int to,float f)
void LupppGUI::masterInputToActive(int to, bool a)
{
EventMasterInputToActive e( (Event::INPUT_TO)to, f );
EventMasterInputToActive e( (Event::INPUT_TO)to, a );
writeToGuiRingbuffer( &e );
}

void LupppGUI::masterVolume(float f)
void LupppGUI::masterVolume(float f, SOURCE s)
{
EventMasterVol e( f );
EventMasterVol e( f, s );
writeToGuiRingbuffer( &e );
}

Expand All @@ -77,9 +77,9 @@ void LupppGUI::recordArm(int t, bool r)
writeToGuiRingbuffer( &e );
}

void LupppGUI::trackSend(int t, int send, float r)
void LupppGUI::trackSend(int t, int send, float r, SOURCE s)
{
EventTrackSend e( t, static_cast<Event::SEND_TYPE>(send), r );
EventTrackSend e( t, static_cast<Event::SEND_TYPE>(send), r, s );
writeToGuiRingbuffer( &e );
}

Expand All @@ -95,9 +95,9 @@ void LupppGUI::trackSendActive(int t, int send, bool a)
writeToGuiRingbuffer( &e );
}

void LupppGUI::trackJackSend(int t, float v)
void LupppGUI::trackJackSend(int t, float v, SOURCE s)
{
EventTrackJackSend e(t,v);
EventTrackJackSend e( t, v, s );
writeToGuiRingbuffer(&e);
}

Expand Down Expand Up @@ -136,15 +136,15 @@ void LupppGUI::bpm(int bpm)
writeToGuiRingbuffer( &e );
}

void LupppGUI::volume(int t, float f)
void LupppGUI::volume(int t, float f, SOURCE s)
{
EventTrackVol e( t, f );
EventTrackVol e( t, f, s );
writeToGuiRingbuffer( &e );
}

void LupppGUI::pan(int t, float p)
void LupppGUI::pan(int t, float p, SOURCE s)
{
EventTrackPan e( t, p );
EventTrackPan e( t, p, s );
writeToGuiRingbuffer( &e );
}

Expand Down
12 changes: 6 additions & 6 deletions src/controller/guicontroller.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ public:
return "Luppp GUI";
}

void masterVolume(float f);
void masterVolume(float f, SOURCE s);
void masterReturnVolume(float f);
void masterInputVol(float v);
void masterInputTo(int to,float f);
void masterInputToActive(int to,float f);
void masterInputToActive(int to,bool a);

void metronomeEnable(bool b);

void trackSend(int t, int send, float r);
void trackSend(int t, int send, float r, SOURCE s);
void trackSendActive(int t, int send, bool a);

virtual void trackJackSend(int t, float v);
virtual void trackJackSend(int t, float v, SOURCE s);
virtual void trackJackSendActivate(int t, bool a);

void bpm(int bpm);
void tapTempo( bool b );

void specialScene(int t, int scene);

void pan(int t, float p);
void pan(int t, float p, SOURCE s);
void mute(int t, bool b);
void volume(int t, float f);
void volume(int t, float f, SOURCE s);
void progress(int t, int s, float p);
void recordArm(int t, bool b);
void launchScene( int scene );
Expand Down
Loading