A method comprising: transforming a received signal into a plurality of samples based on a predefined signal sequence, the plurality samples being real-valued samples; determining respective sample thresholds for the plurality of samples; detecting for at least one peak sample and/or at least one valley sample in the plurality of samples by comparing the plurality of samples with the respective sample thresholds; determining a noise level based on remaining samples of the plurality of samples other than the at least one detected peak sample and/or the at least one detected valley sample; and detecting matching of one of the plurality of samples with the predefined signal sequence based on the noise level, wherein determining the respective sample thresholds comprises: for a given sample of the plurality of samples, determining the respective sample threshold for the given sample by averaging a predetermined number of samples before the given sample, wherein determining the respective sample threshold for the given sample comprises: in response to a first sample in the predetermined number of samples being detected as a peak sample or a valley sample, smoothing the first sample based on at least one sample before the first sample; and determining the respective sample threshold for the given sample by averaging the smoothed first sample and remaining samples of the predetermined number of samples other than the first sample, wherein determining the respective sample thresholds further comprises: in response to the number of samples among the plurality of samples before the given sample is lower than the predetermined number, padding copies of a number of other samples among the plurality of samples before the given sample. transforming a received signal into a plurality of samples based on a predefined signal sequence, the plurality samples being real-valued samples; determining respective sample thresholds for the plurality of samples; detecting for at least one peak sample and/or at least one valley sample in the plurality of samples by comparing the plurality of samples with the respective sample thresholds; determining a noise level based on remaining samples of the plurality of samples other than the at least one detected peak sample and/or the at least one detected valley sample; and detecting matching of one of the plurality of samples with the predefined signal sequence based on the noise level, wherein determining the respective sample thresholds comprises: for a given sample of the plurality of samples, determining the respective sample threshold for the given sample by averaging a predetermined number of samples before the given sample, wherein determining the respective sample threshold for the given sample comprises: in response to a first sample in the predetermined number of samples being detected as a peak sample or a valley sample, smoothing the first sample based on at least one sample before the first sample; and determining the respective sample threshold for the given sample by averaging the smoothed first sample and remaining samples of the predetermined number of samples other than the first sample, wherein determining the respective sample thresholds further comprises: in response to the number of samples among the plurality of samples before the given sample is lower than the predetermined number, padding copies of a number of other samples among the plurality of samples before the given sample. in response to a first sample in the predetermined number of samples being detected as a peak sample or a valley sample, smoothing the first sample based on at least one sample before the first sample; and determining the respective sample threshold for the given sample by averaging the smoothed first sample and remaining samples of the predetermined number of samples other than the first sample, wherein determining the respective sample thresholds further comprises: in response to the number of samples among the plurality of samples before the given sample is lower than the predetermined number, padding copies of a number of other samples among the plurality of samples before the given sample.