// Copyright 2022-2023 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. /* Tests that routing of mixer inputs behaves as expected * * The device supports MAX_MIX_COUNT mixers each with MIX_INPUTS inputs. * * This test also assumes/checks that the default routing into each of the MIX_INPUTS inputs into * each of the M mixer units is as follows: * * MIXER[0]: * USB_FROM_HOST[0] -> MIXER[0].INPUT[0] * USB_FROM_HOST[1] -> MIXER[0].INPUT[1] * ... USB_TO_HOST[0] -> MIXER[0].INPUT[NUM_USB_CHAN_OUT] USB_TO_HOST[1] -> MIXER[0].INPUT[NUM_USB_CHAN_OUT+1] ... * MIXER[MAX_MIX_COUNT-1]: * USB_FROM_HOST[0] -> MIXER[MAX_MIX_COUNT-1].INPUT[0] * USB_FROM_HOST[1] -> MIXER[MAX_MIX_COUNT-1].INPUT[1] * ... * */ #include #include #include "platform.h" #include "xua.h" #include "debug_print.h" #include "assert.h" #include "random.h" #ifndef TEST_ITERATIONS #define TEST_ITERATIONS (300) #endif #include "./../test_mixer_routing_output/src/mixer_test_shared.h" struct ModelMixer { uint32_t deviceMap[NUM_USB_CHAN_OUT]; uint32_t hostMap[NUM_USB_CHAN_IN]; uint32_t mixMap_input[MAX_MIX_COUNT]; uint32_t mixMap_src[MAX_MIX_COUNT]; uint32_t mixOutput[MAX_MIX_COUNT]; }; void InitModel(struct ModelMixer &modelMixer) { for(size_t i = 0; i < NUM_USB_CHAN_OUT; i++) { modelMixer.deviceMap[i] = i; } for(size_t i = 0; i < NUM_USB_CHAN_IN; i++) { modelMixer.hostMap[i] = NUM_USB_CHAN_OUT+i; } for(size_t i = 0; i < MAX_MIX_COUNT; i++) { // This test only allows for one "active" input to each mixer modelMixer.mixMap_src[i] = i; modelMixer.mixMap_input[i] = i; uint32_t sample = i; SET_SOURCE(sample, SRC_HOST); SET_CHANNEL(sample, i); modelMixer.mixOutput[i] = sample; } } void GenExpectedSamples(struct ModelMixer &modelMixer, uint32_t modelOut[NUM_USB_CHAN_OUT], uint32_t modelIn[NUM_USB_CHAN_IN]) { /* First generate model mix outputs - run MIX tiles to allow mix inputs derived from mix outputs to propagate */ for(int j = 0; j < MAX_MIX_COUNT; j++) { for(size_t i = 0; i < MAX_MIX_COUNT; i++) { int src = modelMixer.mixMap_src[i]; modelMixer.mixOutput[i] = CreateSample(modelMixer.mixOutput, src); } } for(size_t i = 0; i