{"record":{"id":"1f0617e2d8f605ac","repo":"Comfy-Org/ComfyUI","slug":"a-cutoff-above-0-5-does-not-make-sense","errorCode":null,"errorMessage":"A cutoff above 0.5 does not make sense.","messagePattern":"A cutoff above 0\\.5 does not make sense\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/lightricks/vocoders/vocoder.py","lineNumber":70,"sourceCode":"        filter = filter_.view(1, 1, kernel_size)\n    return filter\n\n\nclass LowPassFilter1d(nn.Module):\n    def __init__(\n        self,\n        cutoff=0.5,\n        half_width=0.6,\n        stride=1,\n        padding=True,\n        padding_mode=\"replicate\",\n        kernel_size=12,\n    ):\n        super().__init__()\n        if cutoff < -0.0:\n            raise ValueError(\"Minimum cutoff must be larger than zero.\")\n        if cutoff > 0.5:\n            raise ValueError(\"A cutoff above 0.5 does not make sense.\")\n        self.kernel_size = kernel_size\n        self.even = kernel_size % 2 == 0\n        self.pad_left = kernel_size // 2 - int(self.even)\n        self.pad_right = kernel_size // 2\n        self.stride = stride\n        self.padding = padding\n        self.padding_mode = padding_mode\n        filter = kaiser_sinc_filter1d(cutoff, half_width, kernel_size)\n        self.register_buffer(\"filter\", filter)\n\n    def forward(self, x):\n        _, C, _ = x.shape\n        if self.padding:\n            x = F.pad(x, (self.pad_left, self.pad_right), mode=self.padding_mode)\n        return F.conv1d(x, comfy.model_management.cast_to(self.filter.expand(C, -1, -1), dtype=x.dtype, device=x.device), stride=self.stride, groups=C)\n\n\nclass UpSample1d(nn.Module):","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/lightricks/vocoders/vocoder.py#L52-L88","documentation":"Raised by LowPassFilter1d.__init__ when cutoff > 0.5. Cutoff is normalized to the Nyquist frequency (1.0 = Nyquist), so 0.5 already means quarter of the sample rate; anything above 0.5 cannot be represented by the sinc filter kernel. Fails at construction time with a clear ValueError.","triggerScenarios":"Passing cutoff > 0.5 to LowPassFilter1d or building the lightricks vocoder with an upsample-stage cutoff above 0.5 in its config.","commonSituations":"Porting a filter config from a library where cutoff is in Hz (e.g. 20000) instead of normalized units; hand-tuning anti-aliasing parameters without reading the normalization convention.","solutions":["Divide the desired Hz cutoff by the sample rate to normalize: cutoff_hz / sample_rate, and keep it <= 0.5","Use the default 0.5 for the broadest passband the filter supports","Verify each alias-free stage's cutoff in the vocoder config"],"exampleFix":"# before: cutoff given in Hz\nLowPassFilter1d(cutoff=20000)\n# after: normalized to sample rate (e.g. 48kHz -> ~0.42, or use max valid 0.5)\nLowPassFilter1d(cutoff=min(20000 / 48000, 0.5))","handlingStrategy":"validation","validationCode":"cutoff = min(desired_hz / sample_rate, 0.5)\nassert 0.0 <= cutoff <= 0.5, cutoff\nlpf = LowPassFilter1d(cutoff=cutoff)","typeGuard":"def normalized_cutoff(hz: float, sr: float) -> float:\n    c = hz / sr\n    if c > 0.5:\n        raise ValueError('cutoff exceeds Nyquist; reduce hz or sample rate')\n    return c","tryCatchPattern":null,"preventionTips":["Always convert Hz to normalized units before passing to alias-free filters","Document the [0, 0.5] convention wherever vocoder configs are edited"],"tags":["vocoder","audio","config","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}