forked from PAWPAW-Mirror/lib_xua
merge testing branch and osx updates into branch
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
all:
|
||||
g++ -g -o xmos_mixer OSX/usb_mixer.cpp mixer_app.cpp -I. -IOSX OSX/libusb-1.0.0.dylib -arch x86_64
|
||||
|
||||
@@ -140,33 +140,33 @@ int usb_audio_class_get(unsigned char bRequest, unsigned char cs, unsigned char
|
||||
bRequest,
|
||||
(cs<<8) | cn, /* wValue */
|
||||
(unitID & 0xff) << 8 | 0x0,
|
||||
data,
|
||||
wLength,
|
||||
0);
|
||||
data,
|
||||
wLength,
|
||||
0);
|
||||
}
|
||||
|
||||
/* Issue a generic control/class SET request to a specific unit in the Audio Interface */
|
||||
int usb_audio_class_set(unsigned char bRequest, unsigned char cs, unsigned char cn, unsigned short unitID, unsigned short wLength, unsigned char *data)
|
||||
{
|
||||
return libusb_control_transfer(devh,
|
||||
USB_REQUEST_TO_DEV,
|
||||
return libusb_control_transfer(devh,
|
||||
USB_REQUEST_TO_DEV,
|
||||
bRequest,
|
||||
(cs<<8) | cn, /* wValue */
|
||||
(cs<<8) | cn, /* wValue */
|
||||
(unitID & 0xff) << 8 | 0x0,
|
||||
data,
|
||||
wLength,
|
||||
0);
|
||||
data,
|
||||
wLength,
|
||||
0);
|
||||
}
|
||||
|
||||
/* Note, this never get cached in an object since it can change on the device side */
|
||||
int usb_mixer_mem_get(unsigned int mixer, unsigned offset, unsigned char *data)
|
||||
{
|
||||
return libusb_control_transfer(devh,
|
||||
USB_REQUEST_FROM_DEV, /* nRequest */
|
||||
MEM, /* bRequest */
|
||||
offset, /* wValue */
|
||||
(usb_mixers->usb_mixer[mixer].id & 0xff) << 8 | 0x0, /* wIndex */
|
||||
data, 64, 0);
|
||||
return libusb_control_transfer(devh,
|
||||
USB_REQUEST_FROM_DEV, /* nRequest */
|
||||
MEM, /* bRequest */
|
||||
offset, /* wValue */
|
||||
(usb_mixers->usb_mixer[mixer].id & 0xff) << 8 | 0x0, /* wIndex */
|
||||
data, 64, 0);
|
||||
}
|
||||
|
||||
static const unsigned char *find_input_term_unit_by_id(const unsigned char *data, int length, int id)
|
||||
@@ -253,7 +253,7 @@ static double dev_get_mixer_value(unsigned int mixer, unsigned int nodeId)
|
||||
{
|
||||
// MU_MIXER_CONTROL 0x01
|
||||
short data;
|
||||
usb_audio_class_get(CUR, 0x01<<8, nodeId, usb_mixers->usb_mixer[mixer].id, 2,(unsigned char *) &data);
|
||||
usb_audio_class_get(CUR, ((unsigned char) (0x01<<8)), nodeId, usb_mixers->usb_mixer[mixer].id, 2,(unsigned char *) &data);
|
||||
return ((double) data / 256);
|
||||
}
|
||||
|
||||
@@ -436,8 +436,17 @@ int addStrings(const unsigned char *data, int length, int mixer_index, int id, i
|
||||
/* Returns the source of an mix sel output */
|
||||
static unsigned char get_mixsel_value(unsigned int mixer, unsigned int channel)
|
||||
{
|
||||
|
||||
unsigned char bRequest = CUR;
|
||||
//unsigned cs = CS_XU_SEL;
|
||||
unsigned char cs = 1; /* Note, currently the host app configures all mix sel's indentically, so if we get one they all should match */
|
||||
unsigned char cn = channel;
|
||||
unsigned short unitId = usb_mixers->usb_mixSel[mixer].id;
|
||||
unsigned short wLength = 1;
|
||||
unsigned char data[64];
|
||||
usb_audio_class_get(CUR, CS_XU_SEL, channel, usb_mixers->usb_mixSel[mixer].id, 1, (unsigned char *)data);
|
||||
|
||||
usb_audio_class_get(CUR, cs, cn, unitId, wLength, (unsigned char *)data);
|
||||
|
||||
return data[0];
|
||||
}
|
||||
|
||||
@@ -783,25 +792,27 @@ int usb_mixer_get_layout(unsigned int mixer, unsigned int *inputs, unsigned int
|
||||
/* MixSel getters and setters */
|
||||
char *usb_mixsel_get_input_string(unsigned int mixer, unsigned int input)
|
||||
{
|
||||
return usb_mixers->usb_mixSel[mixer].inputStrings[input];
|
||||
return usb_mixers->usb_mixSel[mixer].inputStrings[input];
|
||||
}
|
||||
|
||||
int usb_mixsel_get_input_count(unsigned int mixer)
|
||||
{
|
||||
return usb_mixers->usb_mixSel[mixer].numInputs;
|
||||
return usb_mixers->usb_mixSel[mixer].numInputs;
|
||||
}
|
||||
|
||||
int usb_mixsel_get_output_count(unsigned int mixer)
|
||||
{
|
||||
return usb_mixers->usb_mixSel[mixer].numOutputs;
|
||||
return usb_mixers->usb_mixSel[mixer].numOutputs;
|
||||
}
|
||||
|
||||
char *usb_mixer_get_input_name(unsigned int mixer, unsigned int input) {
|
||||
return usb_mixers->usb_mixer[mixer].input_names[input];
|
||||
char *usb_mixer_get_input_name(unsigned int mixer, unsigned int input)
|
||||
{
|
||||
return usb_mixers->usb_mixer[mixer].input_names[input];
|
||||
}
|
||||
|
||||
char *usb_mixer_get_output_name(unsigned int mixer, unsigned int output) {
|
||||
return usb_mixers->usb_mixer[mixer].output_names[output];
|
||||
char *usb_mixer_get_output_name(unsigned int mixer, unsigned int output)
|
||||
{
|
||||
return usb_mixers->usb_mixer[mixer].output_names[output];
|
||||
}
|
||||
|
||||
unsigned char usb_mixsel_get_state(unsigned int mixer, unsigned int channel)
|
||||
@@ -811,13 +822,19 @@ unsigned char usb_mixsel_get_state(unsigned int mixer, unsigned int channel)
|
||||
|
||||
void usb_mixsel_set_state(unsigned int mixer, unsigned int dst, unsigned int src)
|
||||
{
|
||||
// write to device
|
||||
usb_audio_class_set(CUR, CS_XU_SEL, dst, usb_mixers->usb_mixSel[mixer].id, 1, (unsigned char *)&src);
|
||||
// Write to device
|
||||
// Note, we are updating inputs to all mixers here with a hard-coded 0, though the device allows
|
||||
// for separate input mapping per mixer
|
||||
unsigned bRequest = CUR;
|
||||
unsigned cs = 0;
|
||||
unsigned cn = usb_mixers->usb_mixSel[mixer].id;
|
||||
unsigned wLength = 1;
|
||||
usb_audio_class_set(CUR, 0, dst, usb_mixers->usb_mixSel[mixer].id, wLength, (unsigned char *)&src);
|
||||
|
||||
// update object state
|
||||
// Update object state
|
||||
usb_mixers->usb_mixSel[mixer].state[dst] = src;
|
||||
|
||||
// update local object strings
|
||||
// Update local object strings
|
||||
// TODO we don't really need to store strings since we can look them up...*/
|
||||
strcpy(usb_mixers->usb_mixer[mixer].input_names[dst], usb_mixers->usb_mixSel[mixer].inputStrings[src]);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
The XMOS USB Audio L2 Reference Design contains an 18x8 mixer unit
|
||||
The XMOS USB Audio Reference Design, by default, contains an 18x8 mixer unit
|
||||
(note that at sample rates above 96Khz only the first two outputs are
|
||||
enabled).
|
||||
|
||||
@@ -29,7 +29,6 @@ should always be 0):
|
||||
|
||||
--help
|
||||
|
||||
|
||||
--display-info
|
||||
|
||||
Show information about the device.
|
||||
@@ -105,11 +104,4 @@ Show the DAW output channel map sources.
|
||||
--vendor-audio-request-get bRequest, ControlSelector, ChannelNumber, UnitId
|
||||
|
||||
--vendor-audio-request-set bRequest, ControlSelector, ChannelNumber, UnitId, Data[0], Data[1],...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -176,7 +176,6 @@ void display_available_mixer_sources(int mixIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Gets the current mixer inputs from the device an displays them */
|
||||
void display_mixer_sources(int mixerIndex)
|
||||
{
|
||||
@@ -191,7 +190,7 @@ void display_mixer_sources(int mixerIndex)
|
||||
for(int i = 0; i < usb_mixsel_get_output_count(mixerIndex); i++)
|
||||
{
|
||||
int inputChan = (int)usb_mixsel_get_state(mixerIndex, i);
|
||||
char *str = usb_mixer_get_input_name(mixerIndex,i);
|
||||
char *str = usb_mixer_get_input_name(mixerIndex,inputChan);
|
||||
printf(" Mixer input %d: Source chan id: %d (%s)\n", i, inputChan, str);
|
||||
}
|
||||
}
|
||||
@@ -565,27 +564,26 @@ int main (int argc, char **argv) {
|
||||
{
|
||||
display_daw_channel_map_sources();
|
||||
}
|
||||
else if (strcmp(argv[1], "--set-aud-channel-map") == 0)
|
||||
{
|
||||
unsigned int dst = 0;
|
||||
unsigned int src = 0;
|
||||
if (argc != 4)
|
||||
{
|
||||
usage_error();
|
||||
return -1;
|
||||
}
|
||||
dst = atoi(argv[2]);
|
||||
src = atoi(argv[3]);
|
||||
|
||||
|
||||
else if (strcmp(argv[1], "--set-aud-channel-map") == 0)
|
||||
{
|
||||
unsigned int dst = 0;
|
||||
unsigned int src = 0;
|
||||
if (argc < 4) {
|
||||
usage_error();
|
||||
return -1;
|
||||
}
|
||||
dst = atoi(argv[2]);
|
||||
src = atoi(argv[3]);
|
||||
|
||||
usb_set_aud_channel_map(dst, src);
|
||||
}
|
||||
|
||||
usb_set_aud_channel_map(dst, src);
|
||||
}
|
||||
else if (strcmp(argv[1], "--set-daw-channel-map") == 0)
|
||||
{
|
||||
unsigned int dst = 0;
|
||||
unsigned int src = 0;
|
||||
if (argc < 4) {
|
||||
if (argc != 4)
|
||||
{
|
||||
usage_error();
|
||||
return -1;
|
||||
}
|
||||
@@ -593,8 +591,6 @@ int main (int argc, char **argv) {
|
||||
src = atoi(argv[3]);
|
||||
|
||||
usb_set_usb_channel_map(dst, src);
|
||||
|
||||
|
||||
}
|
||||
else if(strcmp(argv[1], "--get-mixer-levels-input") == 0 ||
|
||||
strcmp(argv[1],"--get-mixer-levels-output") == 0)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Sample code for a host usb mixer app (not this is a host/pc program and cannot be built in the XDE)
|
||||
Reference in New Issue
Block a user