Ejemplo n.º 1
0
void save_switch(int dest, FunctionSwitch switch_type, int thold_sw)
{
    struct Mixer mix[4];
    struct Mixer thold;
    int use_thold = 0;
    int i;
    int sw = INPUT_GetFirstSwitch(mapped_std_channels.switches[switch_type]);
    int count = MIXER_GetMixers(dest, mix, 4);
    if(! count)
        return;
    if(thold_sw && count > 2 && mix[1].sw != mix[count-1].sw) {
        //Pitch uses thold
        thold = mix[count-1];
        use_thold = 1;
    }
    mix[0].sw = 0;
    for(i = 1; i < INPUT_NumSwitchPos(sw); i++) {
        if(i >= count)
            mix[i] = mix[i-1];
        mix[i].sw = sw + i;
    }
    if (use_thold) {
        mix[i] = thold;
        mix[i].sw = 0x80 | thold_sw;
        i++;
    }
    MIXER_SetMixers(mix, i);
}
Ejemplo n.º 2
0
void fix_mixer_dependencies(unsigned mixer_count)
{
    unsigned dependencies[NUM_SOURCES];
    unsigned placed[NUM_SOURCES];
    unsigned pos = 0;
    unsigned last_count = 0;
    unsigned i;
    struct Mixer mixers[NUM_MIXERS];
    memset(mixers, 0, sizeof(mixers));
    for (i = 0; i < NUM_MIXERS; i++) {
        mixers[i].src = 0;
    }
    memset(placed, 0, sizeof(placed));
    while(mixer_count || last_count != mixer_count) {
        last_count = mixer_count;
        for (i = 0; i < NUM_SOURCES; i++) {
            if (placed[i])
                continue;
            if (! find_dependencies(i, dependencies)) {
                placed[i] = 1;
                continue;
            }
            unsigned ok = 1;
            unsigned j;
            // determine if all dependencies have been placed
            for (j = 0; j < NUM_SOURCES; j++) {
                if (dependencies[i] && ! placed[i]) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                unsigned num = MIXER_GetMixers(i, &mixers[pos], NUM_MIXERS);
                pos += num;
                mixer_count -= num;
                placed[i] = 1;
            }
        }
    }
    //mixer_count s gauranteed to be 0 when we get here
    //if (mixer_count) {
    //    printf("Could not place all mixers!\n");
    //    return;
    //}
    for (i = 0; i < NUM_MIXERS; i++)
        Model.mixers[i] = mixers[i];
}