public int getSample()
    {
        if (!enabled) return 0;

        // Decrement Counter
        counter -= psg_cycles;

        // Counter Expired
        if (counter < 0)
        {
            // Toggle Amplitude Flip Flop
            amplitude_flipflop = !amplitude_flipflop;;

            // Update Frequency from Channel 2
            if (use_chan2_freq) frequency = chan2.frequency;

            // Reload counter
            while (counter < 0)
            {
                if (frequency > 0)
                    counter+=frequency;
                else
                    counter=1; // so we don't get stuck in an endless loop
            }

            // We only want to do this once per cycle
            if (amplitude_flipflop)
                shift = (shift>>1) | (PARITY[(shift & tapped_bits) & 0x0F]<<15);
        }

        if ((shift&0x01) == 0x00)
            return 0; // Noise channel does not output negative values
        else
            return (15 - (volume&0x0f)); // ie 0 is 15, 1 is 14 etc
    }