|
Packit Service |
b98cfc |
/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
|
|
Packit Service |
b98cfc |
/*
|
|
Packit Service |
b98cfc |
* Controller for Tascam US-X2Y
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de>
|
|
Packit Service |
b98cfc |
* Copyright (c) 2004-2007 by Rui Nuno Capela <rncbc@rncbc.org>
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
b98cfc |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
b98cfc |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
b98cfc |
* (at your option) any later version.
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
b98cfc |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
b98cfc |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
b98cfc |
* GNU General Public License for more details.
|
|
Packit Service |
b98cfc |
*
|
|
Packit Service |
b98cfc |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
b98cfc |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
b98cfc |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
b98cfc |
*/
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
#include <stdio.h>
|
|
Packit Service |
b98cfc |
#include <string.h>
|
|
Packit Service |
b98cfc |
#include <alsa/asoundlib.h>
|
|
Packit Service |
b98cfc |
#include "Cus428Midi.h"
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
extern int verbose;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Differential wheel tracking constants.
|
|
Packit Service |
b98cfc |
#define W_DELTA_MAX 0xff
|
|
Packit Service |
b98cfc |
#define W_DELTA_MIN (W_DELTA_MAX >> 1)
|
|
Packit Service |
b98cfc |
// Shuttle speed wheel constants.
|
|
Packit Service |
b98cfc |
#define W_SPEED_MAX 0x3f
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void us428_lights::init_us428_lights()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
int i = 0;
|
|
Packit Service |
b98cfc |
memset(this, 0, sizeof(*this));
|
|
Packit Service |
b98cfc |
for (i = 0; i < 7; ++i)
|
|
Packit Service |
b98cfc |
Light[ i].Offset = i + 0x19;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::InitDevice(void)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
if (us428ctls_sharedmem->CtlSnapShotLast >= 0)
|
|
Packit Service |
b98cfc |
SliderChangedTo(eFaderM, ((unsigned char*)(us428ctls_sharedmem->CtlSnapShot + us428ctls_sharedmem->CtlSnapShotLast))[eFaderM]);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
int Cus428State::LightSend()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
int Next = us428ctls_sharedmem->p4outLast + 1;
|
|
Packit Service |
b98cfc |
if(Next < 0 || Next >= N_us428_p4out_BUFS)
|
|
Packit Service |
b98cfc |
Next = 0;
|
|
Packit Service |
b98cfc |
memcpy(&us428ctls_sharedmem->p4out[Next].lights, Light, sizeof(us428_lights));
|
|
Packit Service |
b98cfc |
us428ctls_sharedmem->p4out[Next].type = eLT_Light;
|
|
Packit Service |
b98cfc |
return us428ctls_sharedmem->p4outLast = Next;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::SliderSend(int S)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::SendVolume(usX2Y_volume &V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
int Next = us428ctls_sharedmem->p4outLast + 1;
|
|
Packit Service |
b98cfc |
if (Next < 0 || Next >= N_us428_p4out_BUFS)
|
|
Packit Service |
b98cfc |
Next = 0;
|
|
Packit Service |
b98cfc |
memcpy(&us428ctls_sharedmem->p4out[Next].vol, &V, sizeof(V));
|
|
Packit Service |
b98cfc |
us428ctls_sharedmem->p4out[Next].type = eLT_Volume;
|
|
Packit Service |
b98cfc |
us428ctls_sharedmem->p4outLast = Next;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::UserSliderChangedTo(int S, unsigned char New)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
SliderSend(S);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::SliderChangedTo(int S, unsigned char New)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
if (StateInputMonitor() && S <= eFader3 || S == eFaderM) {
|
|
Packit Service |
b98cfc |
usX2Y_volume &V = Volume[S >= eFader4 ? eFader4 : S];
|
|
Packit Service |
b98cfc |
V.SetTo(S, New);
|
|
Packit Service |
b98cfc |
if (S == eFaderM || !LightIs(eL_Mute0 + S))
|
|
Packit Service |
b98cfc |
SendVolume(V);
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
UserSliderChangedTo(S, New);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::UserKnobChangedTo(eKnobs K, bool V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
switch (K) {
|
|
Packit Service |
b98cfc |
case eK_STOP:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob STOP now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) TransportToggle(T_STOP);
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, K, V);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_PLAY:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob PLAY now %i", V);
|
|
Packit Service |
b98cfc |
if (V) TransportToggle(T_PLAY);
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_Play));
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, K, V);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_REW:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob REW now %i", V);
|
|
Packit Service |
b98cfc |
if (V) TransportToggle(T_REW);
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_Rew));
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, K, V);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_FFWD:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob FFWD now %i", V);
|
|
Packit Service |
b98cfc |
if (V) TransportToggle(T_F_FWD);
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_FFwd));
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, K, V);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_RECORD:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob RECORD now %i", V);
|
|
Packit Service |
b98cfc |
if (V) TransportToggle(T_RECORD);
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_Record));
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, K, V);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_SET:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob SET now %i\n", V);
|
|
Packit Service |
b98cfc |
bSetLocate = V;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_LOCATE_L:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob LOCATE_L now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
if (bSetLocate)
|
|
Packit Service |
b98cfc |
aWheel_L = aWheel;
|
|
Packit Service |
b98cfc |
else {
|
|
Packit Service |
b98cfc |
aWheel = aWheel_L;
|
|
Packit Service |
b98cfc |
LocateSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_LOCATE_R:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob LOCATE_R now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
if (bSetLocate)
|
|
Packit Service |
b98cfc |
aWheel_R = aWheel;
|
|
Packit Service |
b98cfc |
else {
|
|
Packit Service |
b98cfc |
aWheel = aWheel_R;
|
|
Packit Service |
b98cfc |
LocateSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_REC:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob REC now %i\n", V);
|
|
Packit Service |
b98cfc |
bSetRecord = V;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_SOLO:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob SOLO now %i", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
bool bSolo = ! LightIs(eL_Solo);
|
|
Packit Service |
b98cfc |
if (StateInputMonitor()) {
|
|
Packit Service |
b98cfc |
if (bSolo) {
|
|
Packit Service |
b98cfc |
MuteInputMonitor = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = SoloInputMonitor;
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
SoloInputMonitor = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = MuteInputMonitor;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
if (bSolo) {
|
|
Packit Service |
b98cfc |
Mute[aBank] = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = Solo[aBank];
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Solo[aBank] = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = Mute[aBank];
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
LightSet(eL_Solo, bSolo);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_Solo));
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_NULL:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob NULL now %i", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
bool bNull = ! LightIs(eL_Null);
|
|
Packit Service |
b98cfc |
LightSet(eL_Null, bNull);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_Null));
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_BANK_L:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob BANK_L now %i", V);
|
|
Packit Service |
b98cfc |
if (V) BankSet(aBank - 1);
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_BankL));
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_BANK_R:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob BANK_R now %i", V);
|
|
Packit Service |
b98cfc |
if (V) BankSet(aBank + 1);
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_BankR));
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
default:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob %i now %i\n", K, V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, K, V);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::KnobChangedTo(eKnobs K, bool V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// switch (K & ~(StateInputMonitor() ? 3 : -1)) {
|
|
Packit Service |
b98cfc |
switch (K & ~3) {
|
|
Packit Service |
b98cfc |
case eK_Select0:
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
int S = eL_Select0 + (K & 7);
|
|
Packit Service |
b98cfc |
Light[eL_Select0 / 8].Value = 0;
|
|
Packit Service |
b98cfc |
LightSet(S, !LightIs(S));
|
|
Packit Service |
b98cfc |
if (bSetRecord) {
|
|
Packit Service |
b98cfc |
int R = eL_Rec0 + (K & 7);
|
|
Packit Service |
b98cfc |
LightSet(R, !LightIs(R));
|
|
Packit Service |
b98cfc |
if (!StateInputMonitor()) {
|
|
Packit Service |
b98cfc |
SendMaskedWrite(MMC_CIF_TRACK_RECORD,
|
|
Packit Service |
b98cfc |
Y * aBank + (K & 7), LightIs(R));
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_Mute0:
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
int M = eL_Mute0 + (K & 7);
|
|
Packit Service |
b98cfc |
LightSet(M, !LightIs(M));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
if (StateInputMonitor()) {
|
|
Packit Service |
b98cfc |
if (LightIs(eL_Solo)) {
|
|
Packit Service |
b98cfc |
for (int i = 0; i < 5; ++i) {
|
|
Packit Service |
b98cfc |
usX2Y_volume V = Volume[i];
|
|
Packit Service |
b98cfc |
if (!LightIs(eL_Mute0 + i) || (MuteInputMonitor & (1 << i)))
|
|
Packit Service |
b98cfc |
V.LH = V.LL = V.RL = V.RH = 0;
|
|
Packit Service |
b98cfc |
SendVolume(V);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
usX2Y_volume V = Volume[M - eL_Mute0];
|
|
Packit Service |
b98cfc |
if (LightIs(M))
|
|
Packit Service |
b98cfc |
V.LH = V.LL = V.RL = V.RH = 0;
|
|
Packit Service |
b98cfc |
SendVolume(V);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
if (LightIs(eL_Solo)) {
|
|
Packit Service |
b98cfc |
SendMaskedWrite(MMC_CIF_TRACK_SOLO,
|
|
Packit Service |
b98cfc |
Y * aBank + (K & 7), LightIs(M));
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
SendMaskedWrite(MMC_CIF_TRACK_MUTE,
|
|
Packit Service |
b98cfc |
Y * aBank + (K & 7), LightIs(M));
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
default:
|
|
Packit Service |
b98cfc |
if (K == eK_InputMonitor) {
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob InputMonitor now %i", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
bool bInputMonitor = ! StateInputMonitor();
|
|
Packit Service |
b98cfc |
if (bInputMonitor) {
|
|
Packit Service |
b98cfc |
Select[aBank] = Light[0].Value;
|
|
Packit Service |
b98cfc |
Rec[aBank] = Light[1].Value;
|
|
Packit Service |
b98cfc |
Light[0].Value = SelectInputMonitor;
|
|
Packit Service |
b98cfc |
Light[1].Value = RecInputMonitor;
|
|
Packit Service |
b98cfc |
if (LightIs(eL_Solo)) {
|
|
Packit Service |
b98cfc |
Solo[aBank] = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = SoloInputMonitor;
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Mute[aBank] = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = MuteInputMonitor;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
SelectInputMonitor = Light[0].Value;
|
|
Packit Service |
b98cfc |
RecInputMonitor = Light[1].Value;
|
|
Packit Service |
b98cfc |
Light[0].Value = Select[aBank];
|
|
Packit Service |
b98cfc |
Light[1].Value = Rec[aBank];
|
|
Packit Service |
b98cfc |
if (LightIs(eL_Solo)) {
|
|
Packit Service |
b98cfc |
SoloInputMonitor = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = Solo[aBank];
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
MuteInputMonitor = Light[2].Value;
|
|
Packit Service |
b98cfc |
Light[2].Value = Mute[aBank];
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
LightSet(eL_InputMonitor, bInputMonitor);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf(" Light is %i\n", LightIs(eL_InputMonitor));
|
|
Packit Service |
b98cfc |
} else
|
|
Packit Service |
b98cfc |
UserKnobChangedTo(K, V);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::UserWheelChangedTo(E_In84 W, char Diff)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
char Param;
|
|
Packit Service |
b98cfc |
switch (W) {
|
|
Packit Service |
b98cfc |
case eWheelPan:
|
|
Packit Service |
b98cfc |
Param = 0x4D;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheelGain:
|
|
Packit Service |
b98cfc |
Param = 0x48;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheelFreq:
|
|
Packit Service |
b98cfc |
Param = 0x49;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheelQ:
|
|
Packit Service |
b98cfc |
Param = 0x4A;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheel:
|
|
Packit Service |
b98cfc |
Param = 0x60;
|
|
Packit Service |
b98cfc |
// Update the absolute wheel position.
|
|
Packit Service |
b98cfc |
WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(15, Param, ((unsigned char *) us428_ctls)[W]);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428State::WheelChangedTo(E_In84 W, char Diff)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
if (W == eWheelPan && StateInputMonitor() && Light[0].Value) {
|
|
Packit Service |
b98cfc |
int index = 0;
|
|
Packit Service |
b98cfc |
while( index < 4 && (1 << index) != Light[0].Value)
|
|
Packit Service |
b98cfc |
index++;
|
|
Packit Service |
b98cfc |
if (index >= 4)
|
|
Packit Service |
b98cfc |
return;
|
|
Packit Service |
b98cfc |
Volume[index].PanTo(Diff, us428_ctls->Knob(eK_SET));
|
|
Packit Service |
b98cfc |
if (!LightIs(eL_Mute0 + index))
|
|
Packit Service |
b98cfc |
SendVolume(Volume[index]);
|
|
Packit Service |
b98cfc |
return;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
UserWheelChangedTo(W, Diff);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Convert time-code (hh:mm:ss:ff:fr) into absolute wheel position.
|
|
Packit Service |
b98cfc |
void Cus428State::LocateWheel ( unsigned char *tc )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
aWheel = (60 * 60 * 30) * (int) tc[0] // hh - hours [0..23]
|
|
Packit Service |
b98cfc |
+ ( 60 * 30) * (int) tc[1] // mm - minutes [0..59]
|
|
Packit Service |
b98cfc |
+ ( 30) * (int) tc[2] // ss - seconds [0..59]
|
|
Packit Service |
b98cfc |
+ (int) tc[3]; // ff - frames [0..29]
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Convert absolute wheel position into time-code (hh:mm:ss:ff:fr)
|
|
Packit Service |
b98cfc |
void Cus428State::LocateTimecode ( unsigned char *tc )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
int W = aWheel;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
tc[0] = W / (60 * 60 * 30); W -= (60 * 60 * 30) * (int) tc[0];
|
|
Packit Service |
b98cfc |
tc[1] = W / ( 60 * 30); W -= ( 60 * 30) * (int) tc[1];
|
|
Packit Service |
b98cfc |
tc[2] = W / ( 30); W -= ( 30) * (int) tc[2];
|
|
Packit Service |
b98cfc |
tc[3] = W;
|
|
Packit Service |
b98cfc |
tc[4] = 0;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Get the wheel differential.
|
|
Packit Service |
b98cfc |
void Cus428State::WheelDelta ( int W )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// Compute the wheel differential.
|
|
Packit Service |
b98cfc |
int dW = W - W0;
|
|
Packit Service |
b98cfc |
if (dW > 0 && dW > +W_DELTA_MIN)
|
|
Packit Service |
b98cfc |
dW -= W_DELTA_MAX;
|
|
Packit Service |
b98cfc |
else
|
|
Packit Service |
b98cfc |
if (dW < 0 && dW < -W_DELTA_MIN)
|
|
Packit Service |
b98cfc |
dW += W_DELTA_MAX;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
W0 = W;
|
|
Packit Service |
b98cfc |
aWheel += dW;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Can't be less than zero.
|
|
Packit Service |
b98cfc |
if (aWheel < 0)
|
|
Packit Service |
b98cfc |
aWheel = 0;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Now it's whether we're running transport already...
|
|
Packit Service |
b98cfc |
if (aWheelSpeed)
|
|
Packit Service |
b98cfc |
WheelShuttle(dW);
|
|
Packit Service |
b98cfc |
else
|
|
Packit Service |
b98cfc |
WheelStep(dW);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Get the wheel step.
|
|
Packit Service |
b98cfc |
void Cus428State::WheelStep ( int dW )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
unsigned char step;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
if (dW < 0)
|
|
Packit Service |
b98cfc |
step = (unsigned char) (((-dW & 0x3f) << 1) | 0x40);
|
|
Packit Service |
b98cfc |
else
|
|
Packit Service |
b98cfc |
step = (unsigned char) ((dW << 1) & 0x3f);
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_STEP, &step, sizeof(step));
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Set the wheel shuttle speed.
|
|
Packit Service |
b98cfc |
void Cus428State::WheelShuttle ( int dW )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
unsigned char shuttle[3];
|
|
Packit Service |
b98cfc |
int V, forward;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Update the current absolute wheel shuttle speed.
|
|
Packit Service |
b98cfc |
aWheelSpeed += dW;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Don't make it pass some limits...
|
|
Packit Service |
b98cfc |
if (aWheelSpeed < -W_SPEED_MAX) aWheelSpeed = -W_SPEED_MAX;
|
|
Packit Service |
b98cfc |
if (aWheelSpeed > +W_SPEED_MAX) aWheelSpeed = +W_SPEED_MAX;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Build the MMC-Shuttle command...
|
|
Packit Service |
b98cfc |
V = aWheelSpeed;
|
|
Packit Service |
b98cfc |
forward = (V >= 0);
|
|
Packit Service |
b98cfc |
if (!forward)
|
|
Packit Service |
b98cfc |
V = -(V);
|
|
Packit Service |
b98cfc |
shuttle[0] = (unsigned char) ((V >> 3) & 0x07); // sh
|
|
Packit Service |
b98cfc |
shuttle[1] = (unsigned char) ((V & 0x07) << 4); // sm
|
|
Packit Service |
b98cfc |
shuttle[2] = (unsigned char) 0; // sl
|
|
Packit Service |
b98cfc |
if (!forward)
|
|
Packit Service |
b98cfc |
shuttle[0] |= (unsigned char) 0x40;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_SHUTTLE, &shuttle[0], sizeof(shuttle));
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Send the MMC wheel locate command...
|
|
Packit Service |
b98cfc |
void Cus428State::LocateSend ()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
unsigned char MmcData[6];
|
|
Packit Service |
b98cfc |
// Timecode's embedded on MMC command.
|
|
Packit Service |
b98cfc |
MmcData[0] = 0x01;
|
|
Packit Service |
b98cfc |
LocateTimecode(&MmcData[1]);
|
|
Packit Service |
b98cfc |
// Send the MMC locate command...
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_LOCATE, MmcData, sizeof(MmcData));
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Toggle application transport state.
|
|
Packit Service |
b98cfc |
void Cus428State::TransportToggle ( unsigned char T )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
switch (T) {
|
|
Packit Service |
b98cfc |
case T_PLAY:
|
|
Packit Service |
b98cfc |
if (uTransport & T_PLAY) {
|
|
Packit Service |
b98cfc |
uTransport = T_STOP;
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_STOP);
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
uTransport &= T_RECORD;
|
|
Packit Service |
b98cfc |
uTransport |= T_PLAY;
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_PLAY);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case T_RECORD:
|
|
Packit Service |
b98cfc |
if (uTransport & T_RECORD) {
|
|
Packit Service |
b98cfc |
uTransport &= ~T_RECORD;
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_RECORD_EXIT);
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
uTransport &= T_PLAY;
|
|
Packit Service |
b98cfc |
uTransport |= T_RECORD;
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(uTransport & T_PLAY ? MMC_CMD_RECORD_STROBE : MMC_CMD_RECORD_PAUSE);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
default:
|
|
Packit Service |
b98cfc |
if (uTransport & T) {
|
|
Packit Service |
b98cfc |
uTransport = T_STOP;
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
uTransport = T;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
if (uTransport & T_STOP)
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_STOP);
|
|
Packit Service |
b98cfc |
if (uTransport & T_REW)
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_REWIND);
|
|
Packit Service |
b98cfc |
if (uTransport & T_F_FWD)
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_FAST_FORWARD);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
TransportSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Set application transport state.
|
|
Packit Service |
b98cfc |
void Cus428State::TransportSet ( unsigned char T, bool V )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
if (T == T_RECORD) {
|
|
Packit Service |
b98cfc |
uTransport |= T_RECORD;
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
uTransport = T;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
if (T == T_RECORD) {
|
|
Packit Service |
b98cfc |
uTransport &= ~T_RECORD;
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
uTransport = T_STOP;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
TransportSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Update transport status lights.
|
|
Packit Service |
b98cfc |
void Cus428State::TransportSend()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// Common ground for shuttle speed set.
|
|
Packit Service |
b98cfc |
if (uTransport & T_PLAY)
|
|
Packit Service |
b98cfc |
aWheelSpeed = ((W_SPEED_MAX + 1) >> 3);
|
|
Packit Service |
b98cfc |
else if (uTransport & T_REW)
|
|
Packit Service |
b98cfc |
aWheelSpeed = -(W_SPEED_MAX + 1);
|
|
Packit Service |
b98cfc |
else if (uTransport & T_F_FWD)
|
|
Packit Service |
b98cfc |
aWheelSpeed = +(W_SPEED_MAX + 1);
|
|
Packit Service |
b98cfc |
else
|
|
Packit Service |
b98cfc |
aWheelSpeed = 0;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Lightning feedback :)
|
|
Packit Service |
b98cfc |
LightSet(eL_Play, (uTransport & T_PLAY));
|
|
Packit Service |
b98cfc |
LightSet(eL_Record, (uTransport & T_RECORD));
|
|
Packit Service |
b98cfc |
LightSet(eL_Rew, (uTransport & T_REW));
|
|
Packit Service |
b98cfc |
LightSet(eL_FFwd, (uTransport & T_F_FWD));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Set new bank layer state.
|
|
Packit Service |
b98cfc |
void Cus428State::BankSet( int B )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
if (B >= 0 && B < cBanks) {
|
|
Packit Service |
b98cfc |
if (!StateInputMonitor()) {
|
|
Packit Service |
b98cfc |
bool bSolo = LightIs(eL_Solo);
|
|
Packit Service |
b98cfc |
Select[aBank] = Light[0].Value;
|
|
Packit Service |
b98cfc |
Rec[aBank] = Light[1].Value;
|
|
Packit Service |
b98cfc |
if (bSolo) {
|
|
Packit Service |
b98cfc |
Solo[aBank] = Light[2].Value;
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Mute[aBank] = Light[2].Value;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
Light[0].Value = Select[B];
|
|
Packit Service |
b98cfc |
Light[1].Value = Rec[B];
|
|
Packit Service |
b98cfc |
if (bSolo) {
|
|
Packit Service |
b98cfc |
Light[2].Value = Solo[B];
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Light[2].Value = Mute[B];
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
aBank = B;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
BankSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Update bank status lights.
|
|
Packit Service |
b98cfc |
void Cus428State::BankSend()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
LightSet(eL_BankL, (aBank == 0));
|
|
Packit Service |
b98cfc |
LightSet(eL_BankR, (aBank == cBanks - 1));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Reset MMC state.
|
|
Packit Service |
b98cfc |
void Cus428State::MmcReset()
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
W0 = 0;
|
|
Packit Service |
b98cfc |
aBank = 0;
|
|
Packit Service |
b98cfc |
aWheel = aWheel_L = aWheel_R = 0;
|
|
Packit Service |
b98cfc |
aWheelSpeed = 0;
|
|
Packit Service |
b98cfc |
bSetLocate = false;
|
|
Packit Service |
b98cfc |
bSetRecord = false;
|
|
Packit Service |
b98cfc |
uTransport = 0;
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
TransportSend();
|
|
Packit Service |
b98cfc |
LocateSend();
|
|
Packit Service |
b98cfc |
BankSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Process MMC maked-write sub-command.
|
|
Packit Service |
b98cfc |
void Cus428State::MaskedWrite ( unsigned char *data )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// data[0] - sub-command / information field.
|
|
Packit Service |
b98cfc |
// data[1] - target track bitmap byte address.
|
|
Packit Service |
b98cfc |
// data[2] - bitmap changed mask.
|
|
Packit Service |
b98cfc |
// data[3] - bitmap changed value.
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
int track = (data[1] > 0 ? (data[1] * 7) : 0) - 5;
|
|
Packit Service |
b98cfc |
for (int i = 0; i < 7; ++i) {
|
|
Packit Service |
b98cfc |
int mask = (1 << i);
|
|
Packit Service |
b98cfc |
if (data[2] & mask) {
|
|
Packit Service |
b98cfc |
// Only touch tracks that have the "mask" bit set.
|
|
Packit Service |
b98cfc |
int enable = (data[3] & mask);
|
|
Packit Service |
b98cfc |
int bank = (track / Y);
|
|
Packit Service |
b98cfc |
int N = (track % Y);
|
|
Packit Service |
b98cfc |
switch (data[0]) {
|
|
Packit Service |
b98cfc |
case MMC_CIF_TRACK_RECORD:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
fprintf(stderr, "TRACK RECORD(%d, %d).\n", track, enable);
|
|
Packit Service |
b98cfc |
if (!StateInputMonitor() && bank >= 0 && bank < cBanks) {
|
|
Packit Service |
b98cfc |
if (bank == aBank) {
|
|
Packit Service |
b98cfc |
LightSet(eL_Rec0 + N, enable);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
} else if (enable) {
|
|
Packit Service |
b98cfc |
Rec[bank] |= (1 << N);
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Rec[bank] &= ~(1 << N);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case MMC_CIF_TRACK_MUTE:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
fprintf(stderr, "TRACK MUTE(%d, %d).\n", track, enable);
|
|
Packit Service |
b98cfc |
if (!StateInputMonitor() && bank >= 0 && bank < cBanks) {
|
|
Packit Service |
b98cfc |
if (bank == aBank && !LightIs(eL_Solo)) {
|
|
Packit Service |
b98cfc |
LightSet(eL_Mute0 + N, enable);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
} else if (enable) {
|
|
Packit Service |
b98cfc |
Mute[bank] |= (1 << N);
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Mute[bank] &= ~(1 << N);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case MMC_CIF_TRACK_SOLO:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
fprintf(stderr, "TRACK SOLO(%d, %d).\n", track, enable);
|
|
Packit Service |
b98cfc |
if (!StateInputMonitor() && bank >= 0 && bank < cBanks) {
|
|
Packit Service |
b98cfc |
if (bank == aBank && LightIs(eL_Solo)) {
|
|
Packit Service |
b98cfc |
LightSet(eL_Mute0 + N, enable);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
} else if (enable) {
|
|
Packit Service |
b98cfc |
Solo[bank] |= (1 << N);
|
|
Packit Service |
b98cfc |
} else {
|
|
Packit Service |
b98cfc |
Solo[bank] &= ~(1 << N);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
default:
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
track++;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
// Send own MMC masked-write subcommand.
|
|
Packit Service |
b98cfc |
void Cus428State::SendMaskedWrite ( unsigned char scmd, int track, bool V )
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
unsigned char data[4];
|
|
Packit Service |
b98cfc |
int mask = (1 << (track < 2 ? track + 5 : (track - 2) % 7));
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
data[0] = scmd;
|
|
Packit Service |
b98cfc |
data[1] = (unsigned char) (track < 2 ? 0 : 1 + (track - 2) / 7);
|
|
Packit Service |
b98cfc |
data[2] = (unsigned char) mask;
|
|
Packit Service |
b98cfc |
data[3] = (unsigned char) (V ? mask : 0);
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
Midi.SendMmcCommand(MMC_CMD_MASKED_WRITE, &data[0], sizeof(data));
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
Cus428StateMixxx::Cus428StateMixxx(
|
|
Packit Service |
b98cfc |
struct us428ctls_sharedmem* Pus428ctls_sharedmem, int y)
|
|
Packit Service |
b98cfc |
: Cus428State(Pus428ctls_sharedmem, y)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
focus = 0;
|
|
Packit Service |
b98cfc |
eq = 0;
|
|
Packit Service |
b98cfc |
LightSet(eL_Low, 1);
|
|
Packit Service |
b98cfc |
LightSet(eL_LowMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_HiMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_High, 0);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428StateMixxx::UserKnobChangedTo(eKnobs K, bool V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
switch (K) {
|
|
Packit Service |
b98cfc |
case eK_BANK_L:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob BANK_L now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) LightSet(eL_BankL, !LightIs(eL_BankL));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(0, 51, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_BANK_R:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob BANK_R now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) LightSet(eL_BankR, !LightIs(eL_BankR));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(1, 51, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_REW:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob REW now %i\n", V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(focus, 60, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_FFWD:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob FFWD now %i\n", V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(focus, 61, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_STOP:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob STOP now %i\n", V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(focus, 62, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_PLAY:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob PLAY now %i\n", V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(focus, 63, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_RECORD:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob RECORD now %i\n", V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(focus, 64, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_LOW:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob LOW now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
eq = 0;
|
|
Packit Service |
b98cfc |
LightSet(eL_Low, 1);
|
|
Packit Service |
b98cfc |
LightSet(eL_LowMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_HiMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_High, 0);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_LOWMID:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob LOWMID now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
eq = 1;
|
|
Packit Service |
b98cfc |
LightSet(eL_Low, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_LowMid, 1);
|
|
Packit Service |
b98cfc |
LightSet(eL_HiMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_High, 0);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_HIMID:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob HIMID now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
eq = 2;
|
|
Packit Service |
b98cfc |
LightSet(eL_Low, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_LowMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_HiMid, 1);
|
|
Packit Service |
b98cfc |
LightSet(eL_High, 0);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_HIGH:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob HIGH now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
eq = 3;
|
|
Packit Service |
b98cfc |
LightSet(eL_Low, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_LowMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_HiMid, 0);
|
|
Packit Service |
b98cfc |
LightSet(eL_High, 1);
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_SET:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob SET now %i\n", V);
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(focus, 65, V ? 127 : 0);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_LOCATE_L:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob LOCATE_L now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
focus = 0;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eK_LOCATE_R:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob LOCATE_R now %i\n", V);
|
|
Packit Service |
b98cfc |
if (V) {
|
|
Packit Service |
b98cfc |
focus = 1;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
default:
|
|
Packit Service |
b98cfc |
if (verbose > 1)
|
|
Packit Service |
b98cfc |
printf("Knob %i now %i\n", K, V);
|
|
Packit Service |
b98cfc |
if (K >= eK_Select0 && K <= eK_Select0 + 7) {
|
|
Packit Service |
b98cfc |
if (V) LightSet(eL_Select0 + (K - eK_Select0), !LightIs(eL_Select0 + (K - eK_Select0)));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
} else if (K >= eK_Mute0 && K <= eK_Mute0 + 7) {
|
|
Packit Service |
b98cfc |
if (V) LightSet(eL_Mute0 + (K - eK_Mute0), !LightIs(eL_Mute0 + (K - eK_Mute0)));
|
|
Packit Service |
b98cfc |
LightSend();
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
Midi.SendMidiNote(0, K, V);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428StateMixxx::UserSliderChangedTo(int S, unsigned char New)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
// if (verbose > 1)
|
|
Packit Service |
b98cfc |
// printf("Slider : %d - %d - %d\n", S, New, ((unsigned char*)us428_ctls)[S]);
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(0, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
void Cus428StateMixxx::UserWheelChangedTo(E_In84 W, char Diff)
|
|
Packit Service |
b98cfc |
{
|
|
Packit Service |
b98cfc |
char Param;
|
|
Packit Service |
b98cfc |
char Value;
|
|
Packit Service |
b98cfc |
char Channel;
|
|
Packit Service |
b98cfc |
//if (verbose > 1)
|
|
Packit Service |
b98cfc |
// printf("Slider : %d - %d - %d\n", W, Diff, ((unsigned char *) us428_ctls)[W]);
|
|
Packit Service |
b98cfc |
|
|
Packit Service |
b98cfc |
Channel = 0;
|
|
Packit Service |
b98cfc |
switch (W) {
|
|
Packit Service |
b98cfc |
case eWheelGain:
|
|
Packit Service |
b98cfc |
Param = 0x48 + eq * 4;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheelFreq:
|
|
Packit Service |
b98cfc |
Param = 0x49 + eq * 4;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheelQ:
|
|
Packit Service |
b98cfc |
Param = 0x4A + eq * 4;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheelPan:
|
|
Packit Service |
b98cfc |
Param = 0x4B + eq * 4;
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
case eWheel:
|
|
Packit Service |
b98cfc |
Param = 0x60;
|
|
Packit Service |
b98cfc |
Channel = focus;
|
|
Packit Service |
b98cfc |
// Update the absolute wheel position.
|
|
Packit Service |
b98cfc |
//WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
|
|
Packit Service |
b98cfc |
break;
|
|
Packit Service |
b98cfc |
}
|
|
Packit Service |
b98cfc |
Value = 64 + Diff;
|
|
Packit Service |
b98cfc |
Midi.SendMidiControl(Channel, Param, Value);
|
|
Packit Service |
b98cfc |
//Midi.SendMidiControl(0, Param, ((unsigned char *) us428_ctls)[W]);
|
|
Packit Service |
b98cfc |
}
|