public void setFrequency(int f)
    {
        // Bit 2 Selects White/Sync noise
        if ((f & 0x04) == 0x04)
            tapped_bits = WHITE_NOISE;
        else
            tapped_bits = SYNC_NOISE;

        // Reset shift register to preset
        shift = RESET;

        switch(f&0x03)
        {
            case 0x00:
                frequency = 0x10; // 16
                use_chan2_freq = false;
                break;
            case 0x01:
                frequency = 0x20; // 32
                use_chan2_freq = false;
                break;
            case 0x02:
                frequency = 0x40; // 64
                use_chan2_freq = false;
                break;
            // Channel 2 Frequency
            case 0x03:
                frequency = chan2.frequency;
                use_chan2_freq = true;
                break;
            default:
                break;
        }
    }