2006-10-05 14:59:38 +02:00
|
|
|
/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
|
2003-10-28 10:57:13 +00:00
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de>
|
us428control 0.4.5
- A new command line option indicates which interface model is actually
present (-m us428|us224|mixxx) -- nb. the mixxx mode is actually
orthogonal to the us428 and us224 ones, which are in turn both mutually
exclusive, so that more than one -m option can be specified in the same
command line, for compatibility sake; default to us428 mode, of course.
- New BANK switching allows for mapping to a maximum of 32 (!) logical
channel-tracks. This introduces effective BANK L/R button functionality.
Under the default us428 mode it now offers a total of 4 switchable banks
(or layers) for the available 8 fader-channels; while in the new us224
mode, one can switch across 8 banks of 4 fader-channels each. Each
fader-channel maps sequentially (0-31) to a logical track in your DAW,
when connected in a MMC closed-loop. This only applies when not in INPUT
MONITOR mode.
- SELECT, REC, MUTE and SOLO state LEDs/buttons/channel functionality
are now split into INPUT MONITOR and BANK modes, so that each bank
(layer) has its own state. INPUT MONITOR mode gets its own independent
state, which is the only that affects the audio interface channel signal
volume (via respective faders) through the internal hardware mixer --
nb. this special mode deals exclusively to channel/faders 0 and 1 (A/B)
and eventually to 2 and 3 (C/D) which are only available on the US-428
and made accessible through modprobe'ing snd-usb-usx2y with nrpacks=1
and thus made usable via the special hwdep "rawusb" interface mode (ie.
hw:N,2).
- The new track-channel mapping gets effectively signaled through
correspondent but rather experimental MMC MASKED WRITE sub-commands for
RECORD, MUTE and SOLO arming. It is important to note that this late
SOLO sub-command is just some MMC implementation mockup of mine, as I
believe there's no support whatsoever for just that from the official
MIDI MMC RP-013 document (which I don't even have access to date:)
However, I've been prototyping around with this, to my own amusement and
home-brew audio/MIDI sequencer, qtractor:
http://qtractor.sourceforge.net
- NULL fader switch LED is now switchable on/off, but not actually of
any usefulness at this time ;)
I have tried to maintain all previous functionality as it were. Of
course I only tested this new stuff over my own US-224, for which it
surely needs the '-m us224' command-line option. This is also proposedto
be specified in a correspondent udev rule, for all this to work
correctly OOTB for the US-224 at least. US-428 owners don't need to
bother ;)
From: Rui Nuno Capela <rncbc@rncbc.org>
2007-02-15 00:22:20 +01:00
|
|
|
* Copyright (c) 2004-2007 by Rui Nuno Capela <rncbc@rncbc.org>
|
2003-10-28 10:57:13 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2017-11-14 14:46:35 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-10-28 10:57:13 +00:00
|
|
|
*/
|
|
|
|
|
|
2003-10-24 14:01:45 +00:00
|
|
|
#include "Cus428State.h"
|
|
|
|
|
|
2004-07-28 15:56:45 +00:00
|
|
|
// MMC Command Codes.
|
|
|
|
|
#define MMC_CMD_STOP 0x01
|
|
|
|
|
#define MMC_CMD_PLAY 0x02
|
|
|
|
|
#define MMC_CMD_DEFERRED_PLAY 0x03
|
|
|
|
|
#define MMC_CMD_FAST_FORWARD 0x04
|
|
|
|
|
#define MMC_CMD_REWIND 0x05
|
|
|
|
|
#define MMC_CMD_RECORD_STROBE 0x06
|
|
|
|
|
#define MMC_CMD_RECORD_EXIT 0x07
|
|
|
|
|
#define MMC_CMD_RECORD_PAUSE 0x08
|
|
|
|
|
#define MMC_CMD_PAUSE 0x09
|
|
|
|
|
#define MMC_CMD_EJECT 0x0a
|
|
|
|
|
#define MMC_CMD_CHASE 0x0b
|
|
|
|
|
#define MMC_CMD_COMMAND_ERROR_RESET 0x0c
|
|
|
|
|
#define MMC_CMD_MMC_RESET 0x0d
|
|
|
|
|
#define MMC_CMD_JOG_START 0x20
|
|
|
|
|
#define MMC_CMD_JOG_STOP 0x21
|
|
|
|
|
#define MMC_CMD_WRITE 0x40
|
|
|
|
|
#define MMC_CMD_MASKED_WRITE 0x41
|
|
|
|
|
#define MMC_CMD_READ 0x42
|
|
|
|
|
#define MMC_CMD_UPDATE 0x43
|
|
|
|
|
#define MMC_CMD_LOCATE 0x44
|
|
|
|
|
#define MMC_CMD_VARIABLE_PLAY 0x45
|
|
|
|
|
#define MMC_CMD_SEARCH 0x46
|
|
|
|
|
#define MMC_CMD_SHUTTLE 0x47
|
|
|
|
|
#define MMC_CMD_STEP 0x48
|
|
|
|
|
#define MMC_CMD_ASSIGN_SYSTEM_MASTER 0x49
|
|
|
|
|
#define MMC_CMD_GENERATOR_COMMAND 0x4a
|
|
|
|
|
#define MMC_CMD_MTC_COMMAND 0x4b
|
|
|
|
|
#define MMC_CMD_MOVE 0x4c
|
|
|
|
|
#define MMC_CMD_ADD 0x4d
|
|
|
|
|
#define MMC_CMD_SUBTRACT 0x4e
|
|
|
|
|
#define MMC_CMD_DROP_FRAME_ADJUST 0x4f
|
|
|
|
|
#define MMC_CMD_PROCEDURE 0x50
|
|
|
|
|
#define MMC_CMD_EVENT 0x51
|
|
|
|
|
#define MMC_CMD_GROUP 0x52
|
|
|
|
|
#define MMC_CMD_COMMAND_SEGMENT 0x53
|
|
|
|
|
#define MMC_CMD_DEFERRED_VARIABLE_PLAY 0x54
|
|
|
|
|
#define MMC_CMD_RECORD_STROBE_VARIABLE 0x55
|
|
|
|
|
#define MMC_CMD_WAIT 0x7c
|
|
|
|
|
#define MMC_CMD_RESUME 0x7f
|
|
|
|
|
|
us428control 0.4.5
- A new command line option indicates which interface model is actually
present (-m us428|us224|mixxx) -- nb. the mixxx mode is actually
orthogonal to the us428 and us224 ones, which are in turn both mutually
exclusive, so that more than one -m option can be specified in the same
command line, for compatibility sake; default to us428 mode, of course.
- New BANK switching allows for mapping to a maximum of 32 (!) logical
channel-tracks. This introduces effective BANK L/R button functionality.
Under the default us428 mode it now offers a total of 4 switchable banks
(or layers) for the available 8 fader-channels; while in the new us224
mode, one can switch across 8 banks of 4 fader-channels each. Each
fader-channel maps sequentially (0-31) to a logical track in your DAW,
when connected in a MMC closed-loop. This only applies when not in INPUT
MONITOR mode.
- SELECT, REC, MUTE and SOLO state LEDs/buttons/channel functionality
are now split into INPUT MONITOR and BANK modes, so that each bank
(layer) has its own state. INPUT MONITOR mode gets its own independent
state, which is the only that affects the audio interface channel signal
volume (via respective faders) through the internal hardware mixer --
nb. this special mode deals exclusively to channel/faders 0 and 1 (A/B)
and eventually to 2 and 3 (C/D) which are only available on the US-428
and made accessible through modprobe'ing snd-usb-usx2y with nrpacks=1
and thus made usable via the special hwdep "rawusb" interface mode (ie.
hw:N,2).
- The new track-channel mapping gets effectively signaled through
correspondent but rather experimental MMC MASKED WRITE sub-commands for
RECORD, MUTE and SOLO arming. It is important to note that this late
SOLO sub-command is just some MMC implementation mockup of mine, as I
believe there's no support whatsoever for just that from the official
MIDI MMC RP-013 document (which I don't even have access to date:)
However, I've been prototyping around with this, to my own amusement and
home-brew audio/MIDI sequencer, qtractor:
http://qtractor.sourceforge.net
- NULL fader switch LED is now switchable on/off, but not actually of
any usefulness at this time ;)
I have tried to maintain all previous functionality as it were. Of
course I only tested this new stuff over my own US-224, for which it
surely needs the '-m us224' command-line option. This is also proposedto
be specified in a correspondent udev rule, for all this to work
correctly OOTB for the US-224 at least. US-428 owners don't need to
bother ;)
From: Rui Nuno Capela <rncbc@rncbc.org>
2007-02-15 00:22:20 +01:00
|
|
|
// Available MMC Masked Write sub-commands (information fields).
|
|
|
|
|
#define MMC_CIF_TRACK_RECORD 0x4f
|
|
|
|
|
#define MMC_CIF_TRACK_MUTE 0x62
|
|
|
|
|
#define MMC_CIF_TRACK_SOLO 0x66 // Custom-implementation ;)
|
|
|
|
|
|
2004-07-28 15:56:45 +00:00
|
|
|
|
2003-10-24 14:01:45 +00:00
|
|
|
class Cus428Midi {
|
2006-10-05 14:59:38 +02:00
|
|
|
public:
|
2003-10-24 14:01:45 +00:00
|
|
|
Cus428Midi():
|
|
|
|
|
Seq(0){}
|
|
|
|
|
|
|
|
|
|
int CreatePorts(){
|
|
|
|
|
int Err;
|
|
|
|
|
if (0 <= (Err = snd_seq_open(&Seq, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK))) {
|
|
|
|
|
snd_seq_set_client_name(Seq, "US-428");
|
|
|
|
|
Err = snd_seq_create_simple_port(Seq, "Controls",
|
2003-11-25 11:52:00 +00:00
|
|
|
SND_SEQ_PORT_CAP_READ
|
2004-07-28 15:56:45 +00:00
|
|
|
|SND_SEQ_PORT_CAP_WRITE
|
2003-11-25 11:52:00 +00:00
|
|
|
|SND_SEQ_PORT_CAP_SUBS_READ
|
2004-07-28 15:56:45 +00:00
|
|
|
|SND_SEQ_PORT_CAP_SUBS_WRITE,
|
2003-11-25 11:52:00 +00:00
|
|
|
SND_SEQ_PORT_TYPE_MIDI_GENERIC);
|
2003-10-24 14:01:45 +00:00
|
|
|
if (Err >= 0) {
|
|
|
|
|
Port = Err;
|
|
|
|
|
snd_seq_ev_clear(&Ev);
|
|
|
|
|
snd_seq_ev_set_direct(&Ev);
|
|
|
|
|
snd_seq_ev_set_source(&Ev, Port);
|
|
|
|
|
snd_seq_ev_set_subs(&Ev);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Err;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-05 14:59:38 +02:00
|
|
|
int SendMidiControl(char Channel, char Param, char Val){
|
|
|
|
|
snd_seq_ev_set_controller(&Ev, Channel, Param, Val & 0x7F);
|
2003-10-24 14:01:45 +00:00
|
|
|
SubMitEvent();
|
|
|
|
|
return 0;
|
2006-10-05 14:59:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SendMidiNote(char Channel, char Note, char Val){
|
|
|
|
|
if (!Val)
|
|
|
|
|
snd_seq_ev_set_noteoff(&Ev, Channel, Note, Val & 0x7F);
|
|
|
|
|
else
|
|
|
|
|
snd_seq_ev_set_noteon(&Ev, Channel, Note, Val & 0x7F);
|
|
|
|
|
SubMitEvent();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2003-10-24 14:01:45 +00:00
|
|
|
|
2006-10-05 14:59:38 +02:00
|
|
|
int SendMidiControl(char Channel, Cus428State::eKnobs K, bool Down){
|
|
|
|
|
return SendMidiControl(Channel, KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
|
2003-10-24 14:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
2004-07-28 15:56:45 +00:00
|
|
|
// To parse and dispatch input MIDI events.
|
|
|
|
|
void ProcessMidiEvents();
|
|
|
|
|
|
|
|
|
|
// Send MMC command.
|
|
|
|
|
void SendMmcCommand(unsigned char MmcCmd, unsigned char *MmcData = 0, unsigned char MmcLen = 0);
|
|
|
|
|
|
|
|
|
|
// Made public for friendliness.
|
2003-10-24 14:01:45 +00:00
|
|
|
snd_seq_t *Seq;
|
2004-07-28 15:56:45 +00:00
|
|
|
|
2006-10-05 14:59:38 +02:00
|
|
|
private:
|
2003-10-24 14:01:45 +00:00
|
|
|
int Port;
|
|
|
|
|
snd_seq_event_t Ev;
|
|
|
|
|
int SubMitEvent(){
|
|
|
|
|
snd_seq_event_output(Seq, &Ev);
|
|
|
|
|
snd_seq_drain_output(Seq);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
static char KnobParam[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern Cus428Midi Midi;
|